Skip to content

Commit ccc8f71

Browse files
authored
merge main into amd-staging (llvm#2000)
2 parents 16b4168 + 1339654 commit ccc8f71

File tree

392 files changed

+2665
-16901
lines changed

Some content is hidden

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

392 files changed

+2665
-16901
lines changed

clang/docs/CommandGuide/clang.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ Language Selection and Mode Options
155155
156156
ISO C 2023 with GNU extensions
157157

158+
| ``c2y``
159+
160+
ISO C 202y
161+
162+
| ``gnu2y``
163+
164+
ISO C 202y with GNU extensions
165+
158166
The default C language standard is ``gnu17``, except on PS4, where it is
159167
``gnu99``.
160168

clang/include/clang/Basic/LangStandards.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ LANGSTANDARD(c2y, "c2y",
105105
LANGSTANDARD(gnu2y, "gnu2y",
106106
C, "Working Draft for ISO C2y with GNU extensions",
107107
LineComment | C99 | C11 | C17 | C23 | C2y | Digraphs | GNUMode | HexFloat)
108-
108+
// TODO: Add the iso9899:202y alias once ISO publishes the standard.
109109

110110
// C++ modes
111111
LANGSTANDARD(cxx98, "c++98",

clang/lib/AST/ASTImporter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,11 +2628,12 @@ ExpectedDecl ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) {
26282628
if (!Name) {
26292629
// This is an anonymous namespace. Adopt an existing anonymous
26302630
// namespace if we can.
2631-
// FIXME: Not testable.
2632-
if (auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2631+
DeclContext *EnclosingDC = DC->getEnclosingNamespaceContext();
2632+
if (auto *TU = dyn_cast<TranslationUnitDecl>(EnclosingDC))
26332633
MergeWithNamespace = TU->getAnonymousNamespace();
26342634
else
2635-
MergeWithNamespace = cast<NamespaceDecl>(DC)->getAnonymousNamespace();
2635+
MergeWithNamespace =
2636+
cast<NamespaceDecl>(EnclosingDC)->getAnonymousNamespace();
26362637
} else {
26372638
SmallVector<NamedDecl *, 4> ConflictingDecls;
26382639
auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5926,7 +5926,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
59265926
Triple.getArch() != llvm::Triple::x86_64)
59275927
D.Diag(diag::err_drv_unsupported_opt_for_target)
59285928
<< Name << Triple.getArchName();
5929-
} else if (Name == "LIBMVEC-X86") {
5929+
} else if (Name == "libmvec") {
59305930
if (Triple.getArch() != llvm::Triple::x86 &&
59315931
Triple.getArch() != llvm::Triple::x86_64)
59325932
D.Diag(diag::err_drv_unsupported_opt_for_target)

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
948948
std::optional<StringRef> OptVal =
949949
llvm::StringSwitch<std::optional<StringRef>>(ArgVecLib->getValue())
950950
.Case("Accelerate", "Accelerate")
951-
.Case("LIBMVEC", "LIBMVEC-X86")
951+
.Case("libmvec", "LIBMVEC-X86")
952952
.Case("MASSV", "MASSV")
953953
.Case("SVML", "SVML")
954954
.Case("SLEEF", "sleefgnuabi")

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ void Flang::addTargetOptions(const ArgList &Args,
491491
Triple.getArch() != llvm::Triple::x86_64)
492492
D.Diag(diag::err_drv_unsupported_opt_for_target)
493493
<< Name << Triple.getArchName();
494-
} else if (Name == "LIBMVEC-X86") {
494+
} else if (Name == "libmvec") {
495495
if (Triple.getArch() != llvm::Triple::x86 &&
496496
Triple.getArch() != llvm::Triple::x86_64)
497497
D.Diag(diag::err_drv_unsupported_opt_for_target)

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3070,18 +3070,24 @@ bool Sema::FindAllocationFunctions(
30703070
Filter.done();
30713071
}
30723072

3073+
auto GetRedeclContext = [](Decl *D) {
3074+
return D->getDeclContext()->getRedeclContext();
3075+
};
3076+
3077+
DeclContext *OperatorNewContext = GetRedeclContext(OperatorNew);
3078+
30733079
bool FoundGlobalDelete = FoundDelete.empty();
30743080
bool IsClassScopedTypeAwareNew =
30753081
isTypeAwareAllocation(IAP.PassTypeIdentity) &&
3076-
OperatorNew->getDeclContext()->isRecord();
3082+
OperatorNewContext->isRecord();
30773083
auto DiagnoseMissingTypeAwareCleanupOperator = [&](bool IsPlacementOperator) {
30783084
assert(isTypeAwareAllocation(IAP.PassTypeIdentity));
30793085
if (Diagnose) {
30803086
Diag(StartLoc, diag::err_mismatching_type_aware_cleanup_deallocator)
30813087
<< OperatorNew->getDeclName() << IsPlacementOperator << DeleteName;
30823088
Diag(OperatorNew->getLocation(), diag::note_type_aware_operator_declared)
30833089
<< OperatorNew->isTypeAwareOperatorNewOrDelete()
3084-
<< OperatorNew->getDeclName() << OperatorNew->getDeclContext();
3090+
<< OperatorNew->getDeclName() << OperatorNewContext;
30853091
}
30863092
};
30873093
if (IsClassScopedTypeAwareNew && FoundDelete.empty()) {
@@ -3224,15 +3230,15 @@ bool Sema::FindAllocationFunctions(
32243230
// deallocation function will be called.
32253231
if (Matches.size() == 1) {
32263232
OperatorDelete = Matches[0].second;
3233+
DeclContext *OperatorDeleteContext = GetRedeclContext(OperatorDelete);
32273234
bool FoundTypeAwareOperator =
32283235
OperatorDelete->isTypeAwareOperatorNewOrDelete() ||
32293236
OperatorNew->isTypeAwareOperatorNewOrDelete();
32303237
if (Diagnose && FoundTypeAwareOperator) {
32313238
bool MismatchedTypeAwareness =
32323239
OperatorDelete->isTypeAwareOperatorNewOrDelete() !=
32333240
OperatorNew->isTypeAwareOperatorNewOrDelete();
3234-
bool MismatchedContext =
3235-
OperatorDelete->getDeclContext() != OperatorNew->getDeclContext();
3241+
bool MismatchedContext = OperatorDeleteContext != OperatorNewContext;
32363242
if (MismatchedTypeAwareness || MismatchedContext) {
32373243
FunctionDecl *Operators[] = {OperatorDelete, OperatorNew};
32383244
bool TypeAwareOperatorIndex =
@@ -3241,16 +3247,15 @@ bool Sema::FindAllocationFunctions(
32413247
<< Operators[TypeAwareOperatorIndex]->getDeclName()
32423248
<< isPlacementNew
32433249
<< Operators[!TypeAwareOperatorIndex]->getDeclName()
3244-
<< Operators[TypeAwareOperatorIndex]->getDeclContext();
3250+
<< GetRedeclContext(Operators[TypeAwareOperatorIndex]);
32453251
Diag(OperatorNew->getLocation(),
32463252
diag::note_type_aware_operator_declared)
32473253
<< OperatorNew->isTypeAwareOperatorNewOrDelete()
3248-
<< OperatorNew->getDeclName() << OperatorNew->getDeclContext();
3254+
<< OperatorNew->getDeclName() << OperatorNewContext;
32493255
Diag(OperatorDelete->getLocation(),
32503256
diag::note_type_aware_operator_declared)
32513257
<< OperatorDelete->isTypeAwareOperatorNewOrDelete()
3252-
<< OperatorDelete->getDeclName()
3253-
<< OperatorDelete->getDeclContext();
3258+
<< OperatorDelete->getDeclName() << OperatorDeleteContext;
32543259
}
32553260
}
32563261

clang/test/Driver/fveclib.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang -### -c -fveclib=none %s 2>&1 | FileCheck --check-prefix=CHECK-NOLIB %s
22
// RUN: %clang -### -c -fveclib=Accelerate %s 2>&1 | FileCheck --check-prefix=CHECK-ACCELERATE %s
3-
// RUN: %clang -### -c -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-libmvec %s
3+
// RUN: %clang -### -c --target=x86_64-unknown-linux-gnu -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-libmvec %s
44
// RUN: %clang -### -c -fveclib=MASSV %s 2>&1 | FileCheck --check-prefix=CHECK-MASSV %s
55
// RUN: %clang -### -c -fveclib=Darwin_libsystem_m %s 2>&1 | FileCheck --check-prefix=CHECK-DARWIN_LIBSYSTEM_M %s
66
// RUN: %clang -### -c --target=aarch64 -fveclib=SLEEF %s 2>&1 | FileCheck --check-prefix=CHECK-SLEEF %s
@@ -21,7 +21,7 @@
2121

2222
// RUN: not %clang --target=x86 -c -fveclib=SLEEF %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
2323
// RUN: not %clang --target=x86 -c -fveclib=ArmPL %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
24-
// RUN: not %clang --target=aarch64 -c -fveclib=LIBMVEC-X86 %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
24+
// RUN: not %clang --target=aarch64 -c -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
2525
// RUN: not %clang --target=aarch64 -c -fveclib=SVML %s 2>&1 | FileCheck --check-prefix=CHECK-ERROR %s
2626
// CHECK-ERROR: unsupported option {{.*}} for target
2727

@@ -37,7 +37,7 @@
3737

3838
/* Verify that the correct vector library is passed to LTO flags. */
3939

40-
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=LIBMVEC -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBMVEC %s
40+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=libmvec -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-LIBMVEC %s
4141
// CHECK-LTO-LIBMVEC: "-plugin-opt=-vector-library=LIBMVEC-X86"
4242

4343
// RUN: %clang -### --target=powerpc64-unknown-linux-gnu -fveclib=MASSV -flto %s 2>&1 | FileCheck --check-prefix=CHECK-LTO-MASSV %s
@@ -58,8 +58,8 @@
5858

5959
/* Verify that -fmath-errno is set correctly for the vector library. */
6060

61-
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=LIBMVEC %s 2>&1 | FileCheck --check-prefix=CHECK-ERRNO-LIBMVEC %s
62-
// CHECK-ERRNO-LIBMVEC: "-fveclib=LIBMVEC"
61+
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fveclib=libmvec %s 2>&1 | FileCheck --check-prefix=CHECK-ERRNO-LIBMVEC %s
62+
// CHECK-ERRNO-LIBMVEC: "-fveclib=libmvec"
6363
// CHECK-ERRNO-LIBMVEC-SAME: "-fmath-errno"
6464

6565
// RUN: %clang -### --target=powerpc64-unknown-linux-gnu -fveclib=MASSV %s 2>&1 | FileCheck --check-prefix=CHECK-ERRNO-MASSV %s
@@ -110,7 +110,7 @@
110110
// CHECK-ENABLED-LAST: math errno enabled by '-ffp-model=strict' after it was implicitly disabled by '-fveclib=ArmPL', this may limit the utilization of the vector library [-Wmath-errno-enabled-with-veclib]
111111

112112
/* Verify no warning when math-errno is re-enabled for a different veclib (that does not imply -fno-math-errno). */
113-
// RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL -fmath-errno -fveclib=LIBMVEC %s 2>&1 | FileCheck --check-prefix=CHECK-REPEAT-VECLIB %s
113+
// RUN: %clang -### --target=aarch64-linux-gnu -fveclib=ArmPL -fmath-errno -fveclib=Accelerate %s 2>&1 | FileCheck --check-prefix=CHECK-REPEAT-VECLIB %s
114114
// CHECK-REPEAT-VECLIB-NOT: math errno enabled
115115

116116
/// Verify that vectorized routines library is being linked in.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++26 -fexceptions -DTRANSPARENT_DECL=0
2+
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++26 -fexceptions -DTRANSPARENT_DECL=1
3+
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++26 -fexceptions -DTRANSPARENT_DECL=2
4+
5+
// expected-no-diagnostics
6+
#if TRANSPARENT_DECL==2
7+
export module Testing;
8+
#endif
9+
10+
namespace std {
11+
template <class T> struct type_identity {};
12+
using size_t = __SIZE_TYPE__;
13+
enum class align_val_t : size_t {};
14+
struct destroying_delete_t { explicit destroying_delete_t() = default; };
15+
}
16+
17+
#if TRANSPARENT_DECL==0
18+
#define BEGIN_TRANSPARENT_DECL extern "C" {
19+
#define END_TRANSPARENT_DECL }
20+
#elif TRANSPARENT_DECL==1
21+
#define BEGIN_TRANSPARENT_DECL extern "C++" {
22+
#define END_TRANSPARENT_DECL }
23+
#elif TRANSPARENT_DECL==2
24+
#define BEGIN_TRANSPARENT_DECL export {
25+
#define END_TRANSPARENT_DECL }
26+
#else
27+
#error unexpected decl kind
28+
#endif
29+
30+
BEGIN_TRANSPARENT_DECL
31+
void *operator new(std::type_identity<int>, std::size_t, std::align_val_t);
32+
void operator delete[](std::type_identity<int>, void*, std::size_t, std::align_val_t);
33+
END_TRANSPARENT_DECL
34+
35+
void *operator new[](std::type_identity<int>, std::size_t, std::align_val_t);
36+
void operator delete(std::type_identity<int>, void*, std::size_t, std::align_val_t);
37+
38+
void foo() {
39+
int *iptr = new int;
40+
delete iptr;
41+
int *iarray = new int[5];
42+
delete [] iarray;
43+
}

clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,9 @@ int main(int argc, const char **argv) {
426426
OffloadBundler Bundler(BundlerConfig);
427427

428428
return doWork([&]() {
429-
if (Unbundle) {
430-
if (BundlerConfig.FilesType == "a")
431-
return Bundler.UnbundleArchive();
432-
else
433-
return Bundler.UnbundleFiles();
434-
} else
435-
return Bundler.BundleFiles();
429+
if (Unbundle)
430+
return (BundlerConfig.FilesType == "a") ? Bundler.UnbundleArchive()
431+
: Bundler.UnbundleFiles();
432+
return Bundler.BundleFiles();
436433
});
437434
}

0 commit comments

Comments
 (0)