Skip to content

Commit 2f29248

Browse files
committed
Merge branch 'main' into lower-taskloop-mlir
2 parents ee0e662 + dad3162 commit 2f29248

File tree

385 files changed

+2650
-16887
lines changed

Some content is hidden

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

385 files changed

+2650
-16887
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/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

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
}

clang/unittests/AST/ASTImporterTest.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10456,6 +10456,79 @@ TEST_P(ASTImporterOptionSpecificTestBase,
1045610456
EXPECT_EQ(ToFr1Imp, ToFr1);
1045710457
}
1045810458

10459+
struct ImportAndMergeAnonymousNamespace
10460+
: public ASTImporterOptionSpecificTestBase {
10461+
protected:
10462+
void test(const char *ToCode, const char *FromCode) {
10463+
Decl *ToTU = getToTuDecl(ToCode, Lang_CXX11);
10464+
Decl *FromTU = getTuDecl(FromCode, Lang_CXX11);
10465+
auto *FromNS = FirstDeclMatcher<NamespaceDecl>().match(
10466+
FromTU, namespaceDecl(isAnonymous()));
10467+
auto *ToNS = FirstDeclMatcher<NamespaceDecl>().match(
10468+
ToTU, namespaceDecl(isAnonymous()));
10469+
auto *FromF = FirstDeclMatcher<FunctionDecl>().match(
10470+
FromTU, functionDecl(hasName("f")));
10471+
auto *ImportedF = Import(FromF, Lang_CXX11);
10472+
EXPECT_TRUE(ImportedF);
10473+
EXPECT_EQ(ImportedF->getDeclContext(), ToNS);
10474+
auto *ImportedNS = Import(FromNS, Lang_CXX11);
10475+
EXPECT_EQ(ImportedNS, ToNS);
10476+
}
10477+
};
10478+
10479+
TEST_P(ImportAndMergeAnonymousNamespace, NamespaceInTU) {
10480+
const char *ToCode =
10481+
R"(
10482+
namespace {
10483+
}
10484+
)";
10485+
const char *FromCode =
10486+
R"(
10487+
namespace {
10488+
void f();
10489+
}
10490+
)";
10491+
test(ToCode, FromCode);
10492+
}
10493+
10494+
TEST_P(ImportAndMergeAnonymousNamespace, NamespaceInLinkageSpec) {
10495+
const char *ToCode =
10496+
R"(
10497+
extern "C" {
10498+
namespace {
10499+
}
10500+
}
10501+
)";
10502+
const char *FromCode =
10503+
R"(
10504+
extern "C" {
10505+
namespace {
10506+
void f();
10507+
}
10508+
}
10509+
)";
10510+
test(ToCode, FromCode);
10511+
}
10512+
10513+
TEST_P(ImportAndMergeAnonymousNamespace, NamespaceInNamespace) {
10514+
const char *ToCode =
10515+
R"(
10516+
namespace X {
10517+
namespace {
10518+
}
10519+
}
10520+
)";
10521+
const char *FromCode =
10522+
R"(
10523+
namespace X {
10524+
namespace {
10525+
void f();
10526+
}
10527+
}
10528+
)";
10529+
test(ToCode, FromCode);
10530+
}
10531+
1045910532
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
1046010533
DefaultTestValuesForRunOptions);
1046110534

@@ -10542,6 +10615,9 @@ INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportMatrixType,
1054210615
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportTemplateParmDeclDefaultValue,
1054310616
DefaultTestValuesForRunOptions);
1054410617

10618+
INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportAndMergeAnonymousNamespace,
10619+
DefaultTestValuesForRunOptions);
10620+
1054510621
// FIXME: Make ImportOpenCLPipe test work.
1054610622
// INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ImportOpenCLPipe,
1054710623
// DefaultTestValuesForRunOptions);

libcxx/include/__cxx03/__algorithm/equal.h

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -66,65 +66,6 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
6666
return std::equal(__first1, __last1, __first2, __equal_to());
6767
}
6868

69-
#if _LIBCPP_STD_VER >= 14
70-
71-
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
72-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(
73-
_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) {
74-
while (__first1 != __last1 && __first2 != __last2) {
75-
if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
76-
return false;
77-
++__first1;
78-
++__first2;
79-
}
80-
return __first1 == __last1 && __first2 == __last2;
81-
}
82-
83-
template <class _Tp,
84-
class _Up,
85-
class _Pred,
86-
class _Proj1,
87-
class _Proj2,
88-
__enable_if_t<__desugars_to_v<__equal_tag, _Pred, _Tp, _Up> && __is_identity<_Proj1>::value &&
89-
__is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
90-
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
91-
int> = 0>
92-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
93-
__equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {
94-
return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
95-
}
96-
97-
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
98-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
99-
equal(_InputIterator1 __first1,
100-
_InputIterator1 __last1,
101-
_InputIterator2 __first2,
102-
_InputIterator2 __last2,
103-
_BinaryPredicate __pred) {
104-
if constexpr (__has_random_access_iterator_category<_InputIterator1>::value &&
105-
__has_random_access_iterator_category<_InputIterator2>::value) {
106-
if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
107-
return false;
108-
}
109-
__identity __proj;
110-
return std::__equal_impl(
111-
std::__unwrap_iter(__first1),
112-
std::__unwrap_iter(__last1),
113-
std::__unwrap_iter(__first2),
114-
std::__unwrap_iter(__last2),
115-
__pred,
116-
__proj,
117-
__proj);
118-
}
119-
120-
template <class _InputIterator1, class _InputIterator2>
121-
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
122-
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
123-
return std::equal(__first1, __last1, __first2, __last2, __equal_to());
124-
}
125-
126-
#endif // _LIBCPP_STD_VER >= 14
127-
12869
_LIBCPP_END_NAMESPACE_STD
12970

13071
_LIBCPP_POP_MACROS

libcxx/include/__cxx03/__algorithm/for_each.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,6 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) {
3333
return __f;
3434
}
3535

36-
// __movable_box is available in C++20, but is actually a copyable-box, so optimization is only correct in C++23
37-
#if _LIBCPP_STD_VER >= 23
38-
template <class _SegmentedIterator, class _Function>
39-
requires __is_segmented_iterator<_SegmentedIterator>::value
40-
_LIBCPP_HIDE_FROM_ABI constexpr _Function
41-
for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) {
42-
ranges::__movable_box<_Function> __wrapped_func(in_place, std::move(__func));
43-
std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) {
44-
__wrapped_func =
45-
ranges::__movable_box<_Function>(in_place, std::for_each(__lfirst, __llast, std::move(*__wrapped_func)));
46-
});
47-
return std::move(*__wrapped_func);
48-
}
49-
#endif // _LIBCPP_STD_VER >= 23
50-
5136
_LIBCPP_END_NAMESPACE_STD
5237

5338
_LIBCPP_POP_MACROS

0 commit comments

Comments
 (0)