Skip to content

Commit fa77cf1

Browse files
authored
Merge branch 'main' into inbelic/wave-active-op
2 parents 3a13167 + f4cf624 commit fa77cf1

File tree

1,018 files changed

+43795
-38342
lines changed

Some content is hidden

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

1,018 files changed

+43795
-38342
lines changed

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/docs/ClangPlugins.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ The members of ``ParsedAttrInfo`` that a plugin attribute must define are:
9292
attribute, each of which consists of an attribute syntax and how the
9393
attribute name is spelled for that syntax. If the syntax allows a scope then
9494
the spelling must be "scope::attr" if a scope is present or "::attr" if not.
95-
* ``handleDeclAttribute``, which is the function that applies the attribute to
96-
a declaration. It is responsible for checking that the attribute's arguments
97-
are valid, and typically applies the attribute by adding an ``Attr`` to the
98-
``Decl``. It returns either ``AttributeApplied``, to indicate that the
99-
attribute was successfully applied, or ``AttributeNotApplied`` if it wasn't.
10095

10196
The members of ``ParsedAttrInfo`` that may need to be defined, depending on the
10297
attribute, are:
@@ -105,6 +100,18 @@ attribute, are:
105100
arguments to the attribute.
106101
* ``diagAppertainsToDecl``, which checks if the attribute has been used on the
107102
right kind of declaration and issues a diagnostic if not.
103+
* ``handleDeclAttribute``, which is the function that applies the attribute to
104+
a declaration. It is responsible for checking that the attribute's arguments
105+
are valid, and typically applies the attribute by adding an ``Attr`` to the
106+
``Decl``. It returns either ``AttributeApplied``, to indicate that the
107+
attribute was successfully applied, or ``AttributeNotApplied`` if it wasn't.
108+
* ``diagAppertainsToStmt``, which checks if the attribute has been used on the
109+
right kind of statement and issues a diagnostic if not.
110+
* ``handleStmtAttribute``, which is the function that applies the attribute to
111+
a statement. It is responsible for checking that the attribute's arguments
112+
are valid, and typically applies the attribute by adding an ``Attr`` to the
113+
``Stmt``. It returns either ``AttributeApplied``, to indicate that the
114+
attribute was successfully applied, or ``AttributeNotApplied`` if it wasn't.
108115
* ``diagLangOpts``, which checks if the attribute is permitted for the current
109116
language mode and issues a diagnostic if not.
110117
* ``existsInTarget``, which checks if the attribute is permitted for the given

clang/docs/ReleaseNotes.rst

Lines changed: 36 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

@@ -234,6 +250,8 @@ Non-comprehensive list of changes in this release
234250
- The floating point comparison builtins (``__builtin_isgreater``,
235251
``__builtin_isgreaterequal``, ``__builtin_isless``, etc.) and
236252
``__builtin_signbit`` can now be used in constant expressions.
253+
- Plugins can now define custom attributes that apply to statements
254+
as well as declarations.
237255

238256
New Compiler Flags
239257
------------------
@@ -336,10 +354,6 @@ Improvements to Clang's diagnostics
336354

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

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-
343357
- Don't emit duplicated dangling diagnostics. (#GH93386).
344358

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

388406
Improvements to Clang's time-trace
389407
----------------------------------
@@ -449,8 +467,6 @@ Bug Fixes to C++ Support
449467
- Correctly check constraints of explicit instantiations of member functions. (#GH46029)
450468
- When performing partial ordering of function templates, clang now checks that
451469
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.
454470
- Fixed an assertion failure about a constraint of a friend function template references to a value with greater
455471
template depth than the friend function template. (#GH98258)
456472
- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
@@ -488,9 +504,14 @@ Bug Fixes to C++ Support
488504
in certain friend declarations. (#GH93099)
489505
- Clang now instantiates the correct lambda call operator when a lambda's class type is
490506
merged across modules. (#GH110401)
507+
- Clang now uses the correct set of template argument lists when comparing the constraints of
508+
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
509+
a class template. (#GH102320)
491510
- Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
492511
- Fixed an assertion failure when invoking recovery call expressions with explicit attributes
493512
and undeclared templates. (#GH107047, #GH49093)
513+
- Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded
514+
parameter pack. (#GH109148)
494515

495516
Bug Fixes to AST Handling
496517
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -633,6 +654,9 @@ AST Matchers
633654

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

657+
- Ensure ``hasName`` matches template specializations across inline namespaces,
658+
making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent.
659+
636660
clang-format
637661
------------
638662

clang/examples/Attribute/Attribute.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,54 @@ struct ExampleAttrInfo : public ParsedAttrInfo {
9494
}
9595
return AttributeApplied;
9696
}
97+
98+
bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr,
99+
const Stmt *St) const override {
100+
// This attribute appertains to for loop statements only.
101+
if (!isa<ForStmt>(St)) {
102+
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
103+
<< Attr << Attr.isRegularKeywordAttribute() << "for loop statements";
104+
return false;
105+
}
106+
return true;
107+
}
108+
109+
AttrHandling handleStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &Attr,
110+
class Attr *&Result) const override {
111+
// We make some rules here:
112+
// 1. Only accept at most 3 arguments here.
113+
// 2. The first argument must be a string literal if it exists.
114+
if (Attr.getNumArgs() > 3) {
115+
unsigned ID = S.getDiagnostics().getCustomDiagID(
116+
DiagnosticsEngine::Error,
117+
"'example' attribute only accepts at most three arguments");
118+
S.Diag(Attr.getLoc(), ID);
119+
return AttributeNotApplied;
120+
}
121+
// If there are arguments, the first argument should be a string literal.
122+
if (Attr.getNumArgs() > 0) {
123+
auto *Arg0 = Attr.getArgAsExpr(0);
124+
StringLiteral *Literal =
125+
dyn_cast<StringLiteral>(Arg0->IgnoreParenCasts());
126+
if (!Literal) {
127+
unsigned ID = S.getDiagnostics().getCustomDiagID(
128+
DiagnosticsEngine::Error, "first argument to the 'example' "
129+
"attribute must be a string literal");
130+
S.Diag(Attr.getLoc(), ID);
131+
return AttributeNotApplied;
132+
}
133+
SmallVector<Expr *, 16> ArgsBuf;
134+
for (unsigned i = 0; i < Attr.getNumArgs(); i++) {
135+
ArgsBuf.push_back(Attr.getArgAsExpr(i));
136+
}
137+
Result = AnnotateAttr::Create(S.Context, "example", ArgsBuf.data(),
138+
ArgsBuf.size(), Attr.getRange());
139+
} else {
140+
Result = AnnotateAttr::Create(S.Context, "example", nullptr, 0,
141+
Attr.getRange());
142+
}
143+
return AttributeApplied;
144+
}
97145
};
98146

99147
} // namespace

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/ComputeDependence.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ ExprDependence computeDependence(ArrayInitLoopExpr *E);
133133
ExprDependence computeDependence(ImplicitValueInitExpr *E);
134134
ExprDependence computeDependence(InitListExpr *E);
135135
ExprDependence computeDependence(ExtVectorElementExpr *E);
136-
ExprDependence computeDependence(BlockExpr *E);
136+
ExprDependence computeDependence(BlockExpr *E,
137+
bool ContainsUnexpandedParameterPack);
137138
ExprDependence computeDependence(AsTypeExpr *E);
138139
ExprDependence computeDependence(DeclRefExpr *E, const ASTContext &Ctx);
139140
ExprDependence computeDependence(RecoveryExpr *E);

0 commit comments

Comments
 (0)