Skip to content

Commit 8b64272

Browse files
authored
Merge branch 'main' into convert-hlsl-buffer-types2
2 parents ddf3d05 + 16c8056 commit 8b64272

File tree

897 files changed

+40733
-38943
lines changed

Some content is hidden

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

897 files changed

+40733
-38943
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/ReleaseNotes.rst

Lines changed: 32 additions & 13 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

@@ -172,15 +186,11 @@ C++23 Feature Support
172186
- Removed the restriction to literal types in constexpr functions in C++23 mode.
173187

174188
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
175-
supported `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
189+
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
176190

177191
C++20 Feature Support
178192
^^^^^^^^^^^^^^^^^^^^^
179193

180-
C++17 Feature Support
181-
^^^^^^^^^^^^^^^^^^^^^
182-
- The implementation of the relaxed template template argument matching rules is
183-
more complete and reliable, and should provide more accurate diagnostics.
184194

185195
Resolutions to C++ Defect Reports
186196
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -207,8 +217,7 @@ Resolutions to C++ Defect Reports
207217
(`CWG2351: void{} <https://cplusplus.github.io/CWG/issues/2351.html>`_).
208218

209219
- Clang now has improved resolution to CWG2398, allowing class templates to have
210-
default arguments deduced when partial ordering, and better backwards compatibility
211-
in overload resolution.
220+
default arguments deduced when partial ordering.
212221

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

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+
223236
C Language Changes
224237
------------------
225238

@@ -339,10 +352,6 @@ Improvements to Clang's diagnostics
339352

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

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

348357
- Improved diagnostic when trying to befriend a concept. (#GH45182).
@@ -387,6 +396,10 @@ Improvements to Clang's diagnostics
387396
- The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``,
388397
instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being
389398
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.
390403

391404
Improvements to Clang's time-trace
392405
----------------------------------
@@ -452,8 +465,6 @@ Bug Fixes to C++ Support
452465
- Correctly check constraints of explicit instantiations of member functions. (#GH46029)
453466
- When performing partial ordering of function templates, clang now checks that
454467
the deduction was consistent. Fixes (#GH18291).
455-
- Fixes to several issues in partial ordering of template template parameters, which
456-
were documented in the test suite.
457468
- Fixed an assertion failure about a constraint of a friend function template references to a value with greater
458469
template depth than the friend function template. (#GH98258)
459470
- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
@@ -491,9 +502,14 @@ Bug Fixes to C++ Support
491502
in certain friend declarations. (#GH93099)
492503
- Clang now instantiates the correct lambda call operator when a lambda's class type is
493504
merged across modules. (#GH110401)
505+
- Clang now uses the correct set of template argument lists when comparing the constraints of
506+
out-of-line definitions and member templates explicitly specialized for a given implicit instantiation of
507+
a class template. (#GH102320)
494508
- Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
495509
- Fixed an assertion failure when invoking recovery call expressions with explicit attributes
496510
and undeclared templates. (#GH107047, #GH49093)
511+
- Clang no longer crashes when a lambda contains an invalid block declaration that contains an unexpanded
512+
parameter pack. (#GH109148)
497513

498514
Bug Fixes to AST Handling
499515
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -636,6 +652,9 @@ AST Matchers
636652

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

655+
- Ensure ``hasName`` matches template specializations across inline namespaces,
656+
making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent.
657+
639658
clang-format
640659
------------
641660

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);

clang/include/clang/AST/DeclTemplate.h

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -781,15 +781,11 @@ class RedeclarableTemplateDecl : public TemplateDecl,
781781
EntryType *Entry, void *InsertPos);
782782

783783
struct CommonBase {
784-
CommonBase() : InstantiatedFromMember(nullptr, false) {}
784+
CommonBase() {}
785785

786786
/// The template from which this was most
787787
/// directly instantiated (or null).
788-
///
789-
/// The boolean value indicates whether this template
790-
/// was explicitly specialized.
791-
llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool>
792-
InstantiatedFromMember;
788+
RedeclarableTemplateDecl *InstantiatedFromMember = nullptr;
793789

794790
/// If non-null, points to an array of specializations (including
795791
/// partial specializations) known only by their external declaration IDs.
@@ -809,14 +805,19 @@ class RedeclarableTemplateDecl : public TemplateDecl,
809805
};
810806

811807
/// Pointer to the common data shared by all declarations of this
812-
/// template.
813-
mutable CommonBase *Common = nullptr;
808+
/// template, and a flag indicating if the template is a member
809+
/// specialization.
810+
mutable llvm::PointerIntPair<CommonBase *, 1, bool> Common;
811+
812+
CommonBase *getCommonPtrInternal() const { return Common.getPointer(); }
814813

815814
/// Retrieves the "common" pointer shared by all (re-)declarations of
816815
/// the same template. Calling this routine may implicitly allocate memory
817816
/// for the common pointer.
818817
CommonBase *getCommonPtr() const;
819818

819+
void setCommonPtr(CommonBase *C) const { Common.setPointer(C); }
820+
820821
virtual CommonBase *newCommon(ASTContext &C) const = 0;
821822

822823
// Construct a template decl with name, parameters, and templated element.
@@ -857,15 +858,22 @@ class RedeclarableTemplateDecl : public TemplateDecl,
857858
/// template<> template<typename T>
858859
/// struct X<int>::Inner { /* ... */ };
859860
/// \endcode
860-
bool isMemberSpecialization() const {
861-
return getCommonPtr()->InstantiatedFromMember.getInt();
861+
bool isMemberSpecialization() const { return Common.getInt(); }
862+
863+
/// Determines whether any redeclaration of this template was
864+
/// a specialization of a member template.
865+
bool hasMemberSpecialization() const {
866+
for (const auto *D : redecls()) {
867+
if (D->isMemberSpecialization())
868+
return true;
869+
}
870+
return false;
862871
}
863872

864873
/// Note that this member template is a specialization.
865874
void setMemberSpecialization() {
866-
assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
867-
"Only member templates can be member template specializations");
868-
getCommonPtr()->InstantiatedFromMember.setInt(true);
875+
assert(!isMemberSpecialization() && "already a member specialization");
876+
Common.setInt(true);
869877
}
870878

871879
/// Retrieve the member template from which this template was
@@ -905,12 +913,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
905913
/// void X<T>::f(T, U);
906914
/// \endcode
907915
RedeclarableTemplateDecl *getInstantiatedFromMemberTemplate() const {
908-
return getCommonPtr()->InstantiatedFromMember.getPointer();
916+
return getCommonPtr()->InstantiatedFromMember;
909917
}
910918

911919
void setInstantiatedFromMemberTemplate(RedeclarableTemplateDecl *TD) {
912-
assert(!getCommonPtr()->InstantiatedFromMember.getPointer());
913-
getCommonPtr()->InstantiatedFromMember.setPointer(TD);
920+
assert(!getCommonPtr()->InstantiatedFromMember);
921+
getCommonPtr()->InstantiatedFromMember = TD;
914922
}
915923

916924
/// Retrieve the "injected" template arguments that correspond to the
@@ -1989,6 +1997,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19891997
/// template arguments have been deduced.
19901998
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec,
19911999
const TemplateArgumentList *TemplateArgs) {
2000+
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
2001+
"A partial specialization cannot be instantiated from a template");
19922002
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
19932003
"Already set to a class template partial specialization!");
19942004
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -2000,6 +2010,8 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
20002010
/// Note that this class template specialization is an instantiation
20012011
/// of the given class template.
20022012
void setInstantiationOf(ClassTemplateDecl *TemplDecl) {
2013+
assert(!isa<ClassTemplatePartialSpecializationDecl>(this) &&
2014+
"A partial specialization cannot be instantiated from a template");
20032015
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
20042016
"Previously set to a class template partial specialization!");
20052017
SpecializedTemplate = TemplDecl;
@@ -2187,19 +2199,23 @@ class ClassTemplatePartialSpecializationDecl
21872199
/// struct X<int>::Inner<T*> { /* ... */ };
21882200
/// \endcode
21892201
bool isMemberSpecialization() const {
2190-
const auto *First =
2191-
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2192-
return First->InstantiatedFromMember.getInt();
2202+
return InstantiatedFromMember.getInt();
21932203
}
21942204

2195-
/// Note that this member template is a specialization.
2196-
void setMemberSpecialization() {
2197-
auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
2198-
assert(First->InstantiatedFromMember.getPointer() &&
2199-
"Only member templates can be member template specializations");
2200-
return First->InstantiatedFromMember.setInt(true);
2205+
/// Determines whether any redeclaration of this this class template partial
2206+
/// specialization was a specialization of a member partial specialization.
2207+
bool hasMemberSpecialization() const {
2208+
for (const auto *D : redecls()) {
2209+
if (cast<ClassTemplatePartialSpecializationDecl>(D)
2210+
->isMemberSpecialization())
2211+
return true;
2212+
}
2213+
return false;
22012214
}
22022215

2216+
/// Note that this member template is a specialization.
2217+
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
2218+
22032219
/// Retrieves the injected specialization type for this partial
22042220
/// specialization. This is not the same as the type-decl-type for
22052221
/// this partial specialization, which is an InjectedClassNameType.
@@ -2268,10 +2284,6 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl {
22682284
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
22692285
}
22702286

2271-
void setCommonPtr(Common *C) {
2272-
RedeclarableTemplateDecl::Common = C;
2273-
}
2274-
22752287
public:
22762288

22772289
friend class ASTDeclReader;
@@ -2754,6 +2766,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
27542766
/// template arguments have been deduced.
27552767
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec,
27562768
const TemplateArgumentList *TemplateArgs) {
2769+
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2770+
"A partial specialization cannot be instantiated from a template");
27572771
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27582772
"Already set to a variable template partial specialization!");
27592773
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
@@ -2765,6 +2779,8 @@ class VarTemplateSpecializationDecl : public VarDecl,
27652779
/// Note that this variable template specialization is an instantiation
27662780
/// of the given variable template.
27672781
void setInstantiationOf(VarTemplateDecl *TemplDecl) {
2782+
assert(!isa<VarTemplatePartialSpecializationDecl>(this) &&
2783+
"A partial specialization cannot be instantiated from a template");
27682784
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
27692785
"Previously set to a variable template partial specialization!");
27702786
SpecializedTemplate = TemplDecl;
@@ -2949,19 +2965,24 @@ class VarTemplatePartialSpecializationDecl
29492965
/// U* X<int>::Inner<T*> = (T*)(0) + 1;
29502966
/// \endcode
29512967
bool isMemberSpecialization() const {
2952-
const auto *First =
2953-
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2954-
return First->InstantiatedFromMember.getInt();
2968+
return InstantiatedFromMember.getInt();
29552969
}
29562970

2957-
/// Note that this member template is a specialization.
2958-
void setMemberSpecialization() {
2959-
auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
2960-
assert(First->InstantiatedFromMember.getPointer() &&
2961-
"Only member templates can be member template specializations");
2962-
return First->InstantiatedFromMember.setInt(true);
2971+
/// Determines whether any redeclaration of this this variable template
2972+
/// partial specialization was a specialization of a member partial
2973+
/// specialization.
2974+
bool hasMemberSpecialization() const {
2975+
for (const auto *D : redecls()) {
2976+
if (cast<VarTemplatePartialSpecializationDecl>(D)
2977+
->isMemberSpecialization())
2978+
return true;
2979+
}
2980+
return false;
29632981
}
29642982

2983+
/// Note that this member template is a specialization.
2984+
void setMemberSpecialization() { return InstantiatedFromMember.setInt(true); }
2985+
29652986
SourceRange getSourceRange() const override LLVM_READONLY;
29662987

29672988
void Profile(llvm::FoldingSetNodeID &ID) const {

clang/include/clang/AST/Expr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6413,9 +6413,9 @@ class BlockExpr : public Expr {
64136413
protected:
64146414
BlockDecl *TheBlock;
64156415
public:
6416-
BlockExpr(BlockDecl *BD, QualType ty)
6416+
BlockExpr(BlockDecl *BD, QualType ty, bool ContainsUnexpandedParameterPack)
64176417
: Expr(BlockExprClass, ty, VK_PRValue, OK_Ordinary), TheBlock(BD) {
6418-
setDependence(computeDependence(this));
6418+
setDependence(computeDependence(this, ContainsUnexpandedParameterPack));
64196419
}
64206420

64216421
/// Build an empty block expression.

0 commit comments

Comments
 (0)