Skip to content

Commit b73591a

Browse files
committed
Merge tag 'llvmorg-19.1.4' into llvm-19.1.4
LLVM Release 19.1.4
2 parents b35599b + aadaa00 commit b73591a

File tree

57 files changed

+835
-271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+835
-271
lines changed

clang/include/clang/Basic/BuiltinsLoongArchLASX.def

+73-73
Large diffs are not rendered by default.

clang/include/clang/Basic/BuiltinsLoongArchLSX.def

+66-66
Large diffs are not rendered by default.

clang/lib/AST/Decl.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -2503,7 +2503,8 @@ bool VarDecl::isUsableInConstantExpressions(const ASTContext &Context) const {
25032503
if (!DefVD->mightBeUsableInConstantExpressions(Context))
25042504
return false;
25052505
// ... and its initializer is a constant initializer.
2506-
if (Context.getLangOpts().CPlusPlus && !DefVD->hasConstantInitialization())
2506+
if ((Context.getLangOpts().CPlusPlus || getLangOpts().C23) &&
2507+
!DefVD->hasConstantInitialization())
25072508
return false;
25082509
// C++98 [expr.const]p1:
25092510
// An integral constant-expression can involve only [...] const variables
@@ -2610,8 +2611,11 @@ bool VarDecl::hasICEInitializer(const ASTContext &Context) const {
26102611
}
26112612

26122613
bool VarDecl::hasConstantInitialization() const {
2613-
// In C, all globals (and only globals) have constant initialization.
2614-
if (hasGlobalStorage() && !getASTContext().getLangOpts().CPlusPlus)
2614+
// In C, all globals and constexpr variables should have constant
2615+
// initialization. For constexpr variables in C check that initializer is a
2616+
// constant initializer because they can be used in constant expressions.
2617+
if (hasGlobalStorage() && !getASTContext().getLangOpts().CPlusPlus &&
2618+
!isConstexpr())
26152619
return true;
26162620

26172621
// In C++, it depends on whether the evaluation at the point of definition

clang/lib/AST/Interp/Interp.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,10 @@ void diagnoseEnumValue(InterpState &S, CodePtr OpPC, const EnumDecl *ED,
925925
}
926926
}
927927

928+
// https://github.com/llvm/llvm-project/issues/102513
929+
#if defined(_WIN32) && !defined(__clang__) && !defined(NDEBUG)
930+
#pragma optimize("", off)
931+
#endif
928932
bool Interpret(InterpState &S, APValue &Result) {
929933
// The current stack frame when we started Interpret().
930934
// This is being used by the ops to determine wheter
@@ -949,6 +953,10 @@ bool Interpret(InterpState &S, APValue &Result) {
949953
}
950954
}
951955
}
956+
// https://github.com/llvm/llvm-project/issues/102513
957+
#if defined(_WIN32) && !defined(__clang__) && !defined(NDEBUG)
958+
#pragma optimize("", on)
959+
#endif
952960

953961
} // namespace interp
954962
} // namespace clang

clang/lib/CodeGen/CodeGenModule.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7080,8 +7080,8 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
70807080
// For C++ standard modules we are done - we will call the module
70817081
// initializer for imported modules, and that will likewise call those for
70827082
// any imports it has.
7083-
if (CXX20ModuleInits && Import->getImportedOwningModule() &&
7084-
!Import->getImportedOwningModule()->isModuleMapModule())
7083+
if (CXX20ModuleInits && Import->getImportedModule() &&
7084+
Import->getImportedModule()->isNamedModule())
70857085
break;
70867086

70877087
// For clang C++ module map modules the initializers for sub-modules are

clang/lib/Format/UnwrappedLineParser.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,8 @@ void UnwrappedLineParser::parseStructuralElement(
20862086
case tok::kw_switch:
20872087
if (Style.Language == FormatStyle::LK_Java)
20882088
parseSwitch(/*IsExpr=*/true);
2089-
nextToken();
2089+
else
2090+
nextToken();
20902091
break;
20912092
case tok::kw_case:
20922093
// Proto: there are no switch/case statements.
@@ -2637,7 +2638,10 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
26372638
nextToken();
26382639
break;
26392640
case tok::kw_switch:
2640-
parseSwitch(/*IsExpr=*/true);
2641+
if (Style.Language == FormatStyle::LK_Java)
2642+
parseSwitch(/*IsExpr=*/true);
2643+
else
2644+
nextToken();
26412645
break;
26422646
case tok::kw_requires: {
26432647
auto RequiresToken = FormatTok;

clang/lib/Interpreter/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ set(LLVM_LINK_COMPONENTS
1414

1515
if (EMSCRIPTEN AND "lld" IN_LIST LLVM_ENABLE_PROJECTS)
1616
set(WASM_SRC Wasm.cpp)
17+
set(WASM_LINK lldWasm)
1718
endif()
1819

1920
add_clang_library(clangInterpreter
@@ -43,6 +44,7 @@ add_clang_library(clangInterpreter
4344
clangParse
4445
clangSema
4546
clangSerialization
47+
${WASM_LINK}
4648
)
4749

4850
if ((MINGW OR CYGWIN) AND BUILD_SHARED_LIBS)

clang/lib/Sema/SemaConcept.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ static const Expr *SubstituteConstraintExpressionWithoutSatisfaction(
967967
// parameters that the surrounding function hasn't been instantiated yet. Note
968968
// this may happen while we're comparing two templates' constraint
969969
// equivalence.
970-
LocalInstantiationScope ScopeForParameters(S);
970+
LocalInstantiationScope ScopeForParameters(S, /*CombineWithOuterScope=*/true);
971971
if (auto *FD = DeclInfo.getDecl()->getAsFunction())
972972
for (auto *PVD : FD->parameters()) {
973973
if (!PVD->isParameterPack()) {

clang/test/Headers/lasxintrin.c

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lasx
2+
// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lasx -flax-vector-conversions=none
3+
// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lasx -flax-vector-conversions=none -fno-signed-char
4+
5+
#include <lasxintrin.h>

clang/test/Headers/lsxintrin.c

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lsx
2+
// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lsx -flax-vector-conversions=none
3+
// RUN: %clang_cc1 %s -fsyntax-only -triple loongarch64 -target-feature +lsx -flax-vector-conversions=none -fno-signed-char
4+
5+
#include <lsxintrin.h>
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
6+
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %t/a.cpp -fmodule-file=a=%t/a.pcm -emit-llvm -o - | FileCheck %t/a.cpp
7+
8+
//--- a.cppm
9+
export module a;
10+
int func();
11+
static int a = func();
12+
13+
//--- a.cpp
14+
import a;
15+
16+
// CHECK-NOT: internal global
17+
// CHECK-NOT: __cxx_global_var_init
18+

clang/test/Sema/constexpr.c

+17
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,20 @@ void constexprif() {
364364
void constevalif() {
365365
if consteval (300) {} //expected-error {{expected '(' after 'if'}}
366366
}
367+
368+
struct S11 {
369+
int len;
370+
};
371+
void ghissue112516() {
372+
struct S11 *s11 = 0;
373+
constexpr int num = s11->len; // expected-error {{constexpr variable 'num' must be initialized by a constant expression}}
374+
void *Arr[num];
375+
}
376+
377+
void ghissue109095() {
378+
constexpr char c[] = { 'a' };
379+
constexpr int i = c[1]; // expected-error {{constexpr variable 'i' must be initialized by a constant expression}}\
380+
// expected-note {{declared here}}
381+
_Static_assert(i == c[0]); // expected-error {{static assertion expression is not an integral constant expression}}\
382+
// expected-note {{initializer of 'i' is not a constant expression}}
383+
}

clang/test/SemaTemplate/concepts-out-of-line-def.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -622,3 +622,19 @@ void A<T>::method(Ts&... ts)
622622
} {}
623623

624624
}
625+
626+
namespace GH114685 {
627+
628+
template <typename T> struct ptr {
629+
template <typename U>
630+
friend ptr<U> make_item(auto &&args)
631+
requires(sizeof(args) > 1);
632+
};
633+
634+
template <typename U>
635+
ptr<U> make_item(auto &&args)
636+
requires(sizeof(args) > 1) {}
637+
638+
ptr<char> p;
639+
640+
} // namespace GH114685

clang/unittests/Format/TokenAnnotatorTest.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -3412,6 +3412,13 @@ TEST_F(TokenAnnotatorTest, TemplateInstantiation) {
34123412
EXPECT_TOKEN(Tokens[18], tok::greater, TT_TemplateCloser);
34133413
}
34143414

3415+
TEST_F(TokenAnnotatorTest, SwitchInMacroArgument) {
3416+
auto Tokens = annotate("FOOBAR(switch);\n"
3417+
"void f() {}");
3418+
ASSERT_EQ(Tokens.size(), 12u) << Tokens;
3419+
EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_FunctionLBrace);
3420+
}
3421+
34153422
} // namespace
34163423
} // namespace format
34173424
} // namespace clang

cmake/Modules/LLVMVersion.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
77
set(LLVM_VERSION_MINOR 1)
88
endif()
99
if(NOT DEFINED LLVM_VERSION_PATCH)
10-
set(LLVM_VERSION_PATCH 3)
10+
set(LLVM_VERSION_PATCH 4)
1111
endif()
1212
if(NOT DEFINED LLVM_VERSION_SUFFIX)
1313
set(LLVM_VERSION_SUFFIX)

compiler-rt/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ include(CompilerRTUtils)
3939
include(CMakeDependentOption)
4040
include(GetDarwinLinkerVersion)
4141

42+
include(CheckCXXCompilerFlag)
43+
44+
# Check if we can compile with --no-default-config, or if that omits a config
45+
# file that is essential for the toolchain to work properly.
46+
#
47+
# Using CMAKE_REQUIRED_FLAGS to make sure the flag is used both for compilation
48+
# and for linking.
49+
#
50+
# Doing this test early on, to see if the flag works on the toolchain
51+
# out of the box. Later on, we end up adding -nostdlib and similar flags
52+
# to all test compiles, which easily can give false positives on this test.
53+
set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
54+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --no-default-config")
55+
check_cxx_compiler_flag("" COMPILER_RT_HAS_NO_DEFAULT_CONFIG_FLAG)
56+
set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}")
57+
4258
option(COMPILER_RT_BUILD_BUILTINS "Build builtins" ON)
4359
mark_as_advanced(COMPILER_RT_BUILD_BUILTINS)
4460
option(COMPILER_RT_DISABLE_AARCH64_FMV "Disable AArch64 Function Multi Versioning support" OFF)

compiler-rt/lib/builtins/int_math.h

+9-4
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@
6565
#define crt_copysign(x, y) __builtin_copysign((x), (y))
6666
#define crt_copysignf(x, y) __builtin_copysignf((x), (y))
6767
#define crt_copysignl(x, y) __builtin_copysignl((x), (y))
68-
#if __has_builtin(__builtin_copysignf128)
68+
// We define __has_builtin to always return 0 for GCC versions below 10,
69+
// but __builtin_copysignf128 is available since version 7.
70+
#if __has_builtin(__builtin_copysignf128) || \
71+
(defined(__GNUC__) && __GNUC__ >= 7)
6972
#define crt_copysignf128(x, y) __builtin_copysignf128((x), (y))
70-
#elif __has_builtin(__builtin_copysignq) || (defined(__GNUC__) && __GNUC__ >= 7)
73+
#elif __has_builtin(__builtin_copysignq)
7174
#define crt_copysignf128(x, y) __builtin_copysignq((x), (y))
7275
#endif
7376
#endif
@@ -80,9 +83,11 @@
8083
#define crt_fabs(x) __builtin_fabs((x))
8184
#define crt_fabsf(x) __builtin_fabsf((x))
8285
#define crt_fabsl(x) __builtin_fabsl((x))
83-
#if __has_builtin(__builtin_fabsf128)
86+
// We define __has_builtin to always return 0 for GCC versions below 10,
87+
// but __builtin_fabsf128 is available since version 7.
88+
#if __has_builtin(__builtin_fabsf128) || (defined(__GNUC__) && __GNUC__ >= 7)
8489
#define crt_fabsf128(x) __builtin_fabsf128((x))
85-
#elif __has_builtin(__builtin_fabsq) || (defined(__GNUC__) && __GNUC__ >= 7)
90+
#elif __has_builtin(__builtin_fabsq)
8691
#define crt_fabsf128(x) __builtin_fabsq((x))
8792
#endif
8893
#endif

compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,11 @@ size_t PageSize() {
239239
}
240240

241241
void SetThreadName(std::thread &thread, const std::string &name) {
242-
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
243-
defined(_GLIBCXX_GCC_GTHR_POSIX_H)
244-
(void)pthread_setname_np(thread.native_handle(), name.c_str());
245-
#else
242+
#ifndef __MINGW32__
243+
// Not setting the thread name in MinGW environments. MinGW C++ standard
244+
// libraries can either use native Windows threads or pthreads, so we
245+
// don't know with certainty what kind of thread handle we're getting
246+
// from thread.native_handle() here.
246247
typedef HRESULT(WINAPI * proc)(HANDLE, PCWSTR);
247248
HMODULE kbase = GetModuleHandleA("KernelBase.dll");
248249
proc ThreadNameProc =

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

+39-16
Original file line numberDiff line numberDiff line change
@@ -160,33 +160,56 @@ void SetSigProcMask(__sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) {
160160
CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, set, oldset));
161161
}
162162

163+
# if SANITIZER_LINUX
164+
// Deletes the specified signal from newset, if it is not present in oldset
165+
// Equivalently: newset[signum] = newset[signum] & oldset[signum]
166+
static void KeepUnblocked(__sanitizer_sigset_t &newset,
167+
__sanitizer_sigset_t &oldset, int signum) {
168+
// FIXME: https://github.com/google/sanitizers/issues/1816
169+
if (SANITIZER_ANDROID || !internal_sigismember(&oldset, signum))
170+
internal_sigdelset(&newset, signum);
171+
}
172+
# endif
173+
163174
// Block asynchronous signals
164175
void BlockSignals(__sanitizer_sigset_t *oldset) {
165-
__sanitizer_sigset_t set;
166-
internal_sigfillset(&set);
167-
# if SANITIZER_LINUX && !SANITIZER_ANDROID
176+
__sanitizer_sigset_t newset;
177+
internal_sigfillset(&newset);
178+
179+
# if SANITIZER_LINUX
180+
__sanitizer_sigset_t currentset;
181+
182+
# if !SANITIZER_ANDROID
183+
// FIXME: https://github.com/google/sanitizers/issues/1816
184+
SetSigProcMask(NULL, &currentset);
185+
168186
// Glibc uses SIGSETXID signal during setuid call. If this signal is blocked
169187
// on any thread, setuid call hangs.
170188
// See test/sanitizer_common/TestCases/Linux/setuid.c.
171-
internal_sigdelset(&set, 33);
172-
# endif
173-
# if SANITIZER_LINUX
189+
KeepUnblocked(newset, currentset, 33);
190+
# endif // !SANITIZER_ANDROID
191+
174192
// Seccomp-BPF-sandboxed processes rely on SIGSYS to handle trapped syscalls.
175193
// If this signal is blocked, such calls cannot be handled and the process may
176194
// hang.
177-
internal_sigdelset(&set, 31);
195+
KeepUnblocked(newset, currentset, 31);
178196

197+
# if !SANITIZER_ANDROID
179198
// Don't block synchronous signals
180-
internal_sigdelset(&set, SIGSEGV);
181-
internal_sigdelset(&set, SIGBUS);
182-
internal_sigdelset(&set, SIGILL);
183-
internal_sigdelset(&set, SIGTRAP);
184-
internal_sigdelset(&set, SIGABRT);
185-
internal_sigdelset(&set, SIGFPE);
186-
internal_sigdelset(&set, SIGPIPE);
187-
# endif
199+
// but also don't unblock signals that the user had deliberately blocked.
200+
// FIXME: https://github.com/google/sanitizers/issues/1816
201+
KeepUnblocked(newset, currentset, SIGSEGV);
202+
KeepUnblocked(newset, currentset, SIGBUS);
203+
KeepUnblocked(newset, currentset, SIGILL);
204+
KeepUnblocked(newset, currentset, SIGTRAP);
205+
KeepUnblocked(newset, currentset, SIGABRT);
206+
KeepUnblocked(newset, currentset, SIGFPE);
207+
KeepUnblocked(newset, currentset, SIGPIPE);
208+
# endif //! SANITIZER_ANDROID
209+
210+
# endif // SANITIZER_LINUX
188211

189-
SetSigProcMask(&set, oldset);
212+
SetSigProcMask(&newset, oldset);
190213
}
191214

192215
ScopedBlockSignals::ScopedBlockSignals(__sanitizer_sigset_t *copy) {

compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(SANITIZER_UNITTESTS
1515
sanitizer_array_ref_test.cpp
1616
sanitizer_atomic_test.cpp
1717
sanitizer_bitvector_test.cpp
18+
sanitizer_block_signals.cpp
1819
sanitizer_bvgraph_test.cpp
1920
sanitizer_chained_origin_depot_test.cpp
2021
sanitizer_common_test.cpp

0 commit comments

Comments
 (0)