Skip to content

Commit ffba6fb

Browse files
committed
Merge main
2 parents c578054 + 697d65d commit ffba6fb

File tree

772 files changed

+29303
-24792
lines changed

Some content is hidden

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

772 files changed

+29303
-24792
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ function keep-modified-projects() {
191191
}
192192

193193
function check-targets() {
194+
# Do not use "check-all" here because if there is "check-all" plus a
195+
# project specific target like "check-clang", that project's tests
196+
# will be run twice.
194197
projects=${@}
195198
for project in ${projects}; do
196199
case ${project} in
@@ -216,7 +219,7 @@ function check-targets() {
216219
echo "check-lldb"
217220
;;
218221
pstl)
219-
echo "check-all"
222+
# Currently we do not run pstl tests in CI.
220223
;;
221224
libclc)
222225
# Currently there is no testing for libclc.

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,8 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
148148

149149
if (auto Entry = SM.getFileManager().getOptionalFileRef(Path)) {
150150
if (SourceTU) {
151-
auto &Replaces = DiagReplacements[*Entry];
152-
auto It = Replaces.find(R);
153-
if (It == Replaces.end())
154-
Replaces.emplace(R, SourceTU);
155-
else if (It->second != SourceTU)
151+
auto [It, Inserted] = DiagReplacements[*Entry].try_emplace(R, SourceTU);
152+
if (!Inserted && It->second != SourceTU)
156153
// This replacement is a duplicate of one suggested by another TU.
157154
return;
158155
}

clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,8 @@ void ChangeNamespaceTool::run(
606606
Result.Nodes.getNodeAs<DeclRefExpr>("func_ref")) {
607607
// If this reference has been processed as a function call, we do not
608608
// process it again.
609-
if (ProcessedFuncRefs.count(FuncRef))
609+
if (!ProcessedFuncRefs.insert(FuncRef).second)
610610
return;
611-
ProcessedFuncRefs.insert(FuncRef);
612611
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("func_decl");
613612
assert(Func);
614613
const auto *Context = Result.Nodes.getNodeAs<Decl>("dc");

clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ void ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
146146
}
147147
// Check if a definition in another namespace exists.
148148
const auto DeclName = CurDecl->getName();
149-
if (!DeclNameToDefinitions.contains(DeclName)) {
149+
auto It = DeclNameToDefinitions.find(DeclName);
150+
if (It == DeclNameToDefinitions.end()) {
150151
continue; // No definition in this translation unit, we can skip it.
151152
}
152153
// Make a warning for each definition with the same name (in other
153154
// namespaces).
154-
const auto &Definitions = DeclNameToDefinitions[DeclName];
155+
const auto &Definitions = It->second;
155156
for (const auto *Def : Definitions) {
156157
diag(CurDecl->getLocation(),
157158
"no definition found for %0, but a definition with "

clang-tools-extra/clangd/Headers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class IncludeStructure::RecordHeaders : public PPCallbacks {
7575
IDs.push_back(HID);
7676
}
7777
}
78-
Out->MainFileIncludesBySpelling.try_emplace(Inc.Written)
79-
.first->second.push_back(Out->MainFileIncludes.size() - 1);
78+
Out->MainFileIncludesBySpelling[Inc.Written].push_back(
79+
Out->MainFileIncludes.size() - 1);
8080
}
8181

8282
// Record include graph (not just for main-file includes)

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,8 +2282,7 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
22822282
elog("incomingCalls failed to convert location: {0}", Loc.takeError());
22832283
return;
22842284
}
2285-
auto It = CallsIn.try_emplace(R.Container, std::vector<Range>{}).first;
2286-
It->second.push_back(Loc->range);
2285+
CallsIn[R.Container].push_back(Loc->range);
22872286

22882287
ContainerLookup.IDs.insert(R.Container);
22892288
});

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv8m.main-none-eabi)
345345
set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
346346
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
347347
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
348+
set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING "")
348349
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
349350
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
350351
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
@@ -396,6 +397,7 @@ foreach(target riscv32-unknown-elf)
396397
set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
397398
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
398399
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
400+
set(RUNTIMES_${target}_LIBCXX_SHARED_OUTPUT_NAME "c++-shared" CACHE STRING "")
399401
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
400402
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
401403
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")

clang/docs/ReleaseNotes.rst

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ C++ Specific Potentially Breaking Changes
9999
// Was error, now evaluates to false.
100100
constexpr bool b = f() == g();
101101
102+
- The warning ``-Wdeprecated-literal-operator`` is now on by default, as this is
103+
something that WG21 has shown interest in removing from the language. The
104+
result is that anyone who is compiling with ``-Werror`` should see this
105+
diagnostic. To fix this diagnostic, simply removing the space character from
106+
between the ``operator""`` and the user defined literal name will make the
107+
source no longer deprecated. This is consistent with `CWG2521 <https://cplusplus.github.io/CWG/issues/2521.html>_`.
108+
109+
.. code-block:: c++
110+
111+
// Now diagnoses by default.
112+
unsigned operator"" _udl_name(unsigned long long);
113+
// Fixed version:
114+
unsigned operator""_udl_name(unsigned long long);
115+
102116
ABI Changes in This Version
103117
---------------------------
104118

@@ -171,13 +185,12 @@ C++23 Feature Support
171185
^^^^^^^^^^^^^^^^^^^^^
172186
- Removed the restriction to literal types in constexpr functions in C++23 mode.
173187

188+
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
189+
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
190+
174191
C++20 Feature Support
175192
^^^^^^^^^^^^^^^^^^^^^
176193

177-
C++17 Feature Support
178-
^^^^^^^^^^^^^^^^^^^^^
179-
- The implementation of the relaxed template template argument matching rules is
180-
more complete and reliable, and should provide more accurate diagnostics.
181194

182195
Resolutions to C++ Defect Reports
183196
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -204,8 +217,7 @@ Resolutions to C++ Defect Reports
204217
(`CWG2351: void{} <https://cplusplus.github.io/CWG/issues/2351.html>`_).
205218

206219
- Clang now has improved resolution to CWG2398, allowing class templates to have
207-
default arguments deduced when partial ordering, and better backwards compatibility
208-
in overload resolution.
220+
default arguments deduced when partial ordering.
209221

210222
- Clang now allows comparing unequal object pointers that have been cast to ``void *``
211223
in constant expressions. These comparisons always worked in non-constant expressions.
@@ -217,6 +229,10 @@ Resolutions to C++ Defect Reports
217229
- Clang now allows trailing requires clause on explicit deduction guides.
218230
(`CWG2707: Deduction guides cannot have a trailing requires-clause <https://cplusplus.github.io/CWG/issues/2707.html>`_).
219231

232+
- Clang now diagnoses a space in the first production of a ``literal-operator-id``
233+
by default.
234+
(`CWG2521: User-defined literals and reserved identifiers <https://cplusplus.github.io/CWG/issues/2521.html>`_).
235+
220236
C Language Changes
221237
------------------
222238

@@ -336,10 +352,6 @@ Improvements to Clang's diagnostics
336352

337353
- Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.
338354

339-
- Clang now properly explains the reason a template template argument failed to
340-
match a template template parameter, in terms of the C++17 relaxed matching rules
341-
instead of the old ones.
342-
343355
- Don't emit duplicated dangling diagnostics. (#GH93386).
344356

345357
- Improved diagnostic when trying to befriend a concept. (#GH45182).
@@ -384,6 +396,10 @@ Improvements to Clang's diagnostics
384396
- The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``,
385397
instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being
386398
suboptimal in some way the error fails to mention (#GH111550).
399+
400+
- Clang now emits a ``-Wdepredcated-literal-operator`` diagnostic, even if the
401+
name was a reserved name, which we improperly allowed to suppress the
402+
diagnostic.
387403

388404
Improvements to Clang's time-trace
389405
----------------------------------
@@ -449,8 +465,6 @@ Bug Fixes to C++ Support
449465
- Correctly check constraints of explicit instantiations of member functions. (#GH46029)
450466
- When performing partial ordering of function templates, clang now checks that
451467
the deduction was consistent. Fixes (#GH18291).
452-
- Fixes to several issues in partial ordering of template template parameters, which
453-
were documented in the test suite.
454468
- Fixed an assertion failure about a constraint of a friend function template references to a value with greater
455469
template depth than the friend function template. (#GH98258)
456470
- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
@@ -633,6 +647,9 @@ AST Matchers
633647

634648
- Fixed a crash when traverse lambda expr with invalid captures. (#GH106444)
635649

650+
- Ensure ``hasName`` matches template specializations across inline namespaces,
651+
making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent.
652+
636653
clang-format
637654
------------
638655

clang/include/clang/AST/Attr.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,23 @@ class InheritableParamAttr : public InheritableAttr {
197197
}
198198
};
199199

200+
class InheritableParamOrStmtAttr : public InheritableParamAttr {
201+
protected:
202+
InheritableParamOrStmtAttr(ASTContext &Context,
203+
const AttributeCommonInfo &CommonInfo,
204+
attr::Kind AK, bool IsLateParsed,
205+
bool InheritEvenIfAlreadyPresent)
206+
: InheritableParamAttr(Context, CommonInfo, AK, IsLateParsed,
207+
InheritEvenIfAlreadyPresent) {}
208+
209+
public:
210+
// Implement isa/cast/dyncast/etc.
211+
static bool classof(const Attr *A) {
212+
return A->getKind() >= attr::FirstInheritableParamOrStmtAttr &&
213+
A->getKind() <= attr::LastInheritableParamOrStmtAttr;
214+
}
215+
};
216+
200217
class HLSLAnnotationAttr : public InheritableAttr {
201218
protected:
202219
HLSLAnnotationAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,

clang/include/clang/AST/OpenACCClause.h

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -119,32 +119,6 @@ class OpenACCSeqClause : public OpenACCClause {
119119
}
120120
};
121121

122-
// Not yet implemented, but the type name is necessary for 'seq' diagnostics, so
123-
// this provides a basic, do-nothing implementation. We still need to add this
124-
// type to the visitors/etc, as well as get it to take its proper arguments.
125-
class OpenACCGangClause : public OpenACCClause {
126-
protected:
127-
OpenACCGangClause(SourceLocation BeginLoc, SourceLocation EndLoc)
128-
: OpenACCClause(OpenACCClauseKind::Gang, BeginLoc, EndLoc) {
129-
llvm_unreachable("Not yet implemented");
130-
}
131-
132-
public:
133-
static bool classof(const OpenACCClause *C) {
134-
return C->getClauseKind() == OpenACCClauseKind::Gang;
135-
}
136-
137-
static OpenACCGangClause *
138-
Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
139-
140-
child_range children() {
141-
return child_range(child_iterator(), child_iterator());
142-
}
143-
const_child_range children() const {
144-
return const_child_range(const_child_iterator(), const_child_iterator());
145-
}
146-
};
147-
148122
// Not yet implemented, but the type name is necessary for 'seq' diagnostics, so
149123
// this provides a basic, do-nothing implementation. We still need to add this
150124
// type to the visitors/etc, as well as get it to take its proper arguments.
@@ -157,7 +131,7 @@ class OpenACCVectorClause : public OpenACCClause {
157131

158132
public:
159133
static bool classof(const OpenACCClause *C) {
160-
return C->getClauseKind() == OpenACCClauseKind::Gang;
134+
return C->getClauseKind() == OpenACCClauseKind::Vector;
161135
}
162136

163137
static OpenACCVectorClause *
@@ -177,13 +151,13 @@ class OpenACCVectorClause : public OpenACCClause {
177151
class OpenACCWorkerClause : public OpenACCClause {
178152
protected:
179153
OpenACCWorkerClause(SourceLocation BeginLoc, SourceLocation EndLoc)
180-
: OpenACCClause(OpenACCClauseKind::Gang, BeginLoc, EndLoc) {
154+
: OpenACCClause(OpenACCClauseKind::Worker, BeginLoc, EndLoc) {
181155
llvm_unreachable("Not yet implemented");
182156
}
183157

184158
public:
185159
static bool classof(const OpenACCClause *C) {
186-
return C->getClauseKind() == OpenACCClauseKind::Gang;
160+
return C->getClauseKind() == OpenACCClauseKind::Worker;
187161
}
188162

189163
static OpenACCWorkerClause *
@@ -535,6 +509,38 @@ class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithExprs {
535509
Expr *getIntExpr() { return hasIntExpr() ? getExprs()[0] : nullptr; };
536510
};
537511

512+
class OpenACCGangClause final
513+
: public OpenACCClauseWithExprs,
514+
public llvm::TrailingObjects<OpenACCGangClause, Expr *, OpenACCGangKind> {
515+
protected:
516+
OpenACCGangClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
517+
ArrayRef<OpenACCGangKind> GangKinds,
518+
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
519+
520+
OpenACCGangKind getGangKind(unsigned I) const {
521+
return getTrailingObjects<OpenACCGangKind>()[I];
522+
}
523+
524+
public:
525+
static bool classof(const OpenACCClause *C) {
526+
return C->getClauseKind() == OpenACCClauseKind::Gang;
527+
}
528+
529+
size_t numTrailingObjects(OverloadToken<Expr *>) const {
530+
return getNumExprs();
531+
}
532+
533+
unsigned getNumExprs() const { return getExprs().size(); }
534+
std::pair<OpenACCGangKind, const Expr *> getExpr(unsigned I) const {
535+
return {getGangKind(I), getExprs()[I]};
536+
}
537+
538+
static OpenACCGangClause *
539+
Create(const ASTContext &Ctx, SourceLocation BeginLoc,
540+
SourceLocation LParenLoc, ArrayRef<OpenACCGangKind> GangKinds,
541+
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
542+
};
543+
538544
class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {
539545
OpenACCNumWorkersClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
540546
Expr *IntExpr, SourceLocation EndLoc);

0 commit comments

Comments
 (0)