Skip to content

Commit cd6c974

Browse files
authored
Merge branch 'main' into fix/100394
2 parents 8c32076 + 8b17916 commit cd6c974

File tree

401 files changed

+16484
-23483
lines changed

Some content is hidden

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

401 files changed

+16484
-23483
lines changed

clang/docs/ReleaseNotes.rst

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

@@ -177,10 +191,6 @@ C++23 Feature Support
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
@@ -637,6 +648,9 @@ AST Matchers
637648

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

651+
- Ensure ``hasName`` matches template specializations across inline namespaces,
652+
making `matchesNodeFullSlow` and `matchesNodeFullFast` consistent.
653+
640654
clang-format
641655
------------
642656

clang/include/clang/AST/OpenACCClause.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class OpenACCVectorClause : public OpenACCClause {
157157

158158
public:
159159
static bool classof(const OpenACCClause *C) {
160-
return C->getClauseKind() == OpenACCClauseKind::Gang;
160+
return C->getClauseKind() == OpenACCClauseKind::Vector;
161161
}
162162

163163
static OpenACCVectorClause *
@@ -183,7 +183,7 @@ class OpenACCWorkerClause : public OpenACCClause {
183183

184184
public:
185185
static bool classof(const OpenACCClause *C) {
186-
return C->getClauseKind() == OpenACCClauseKind::Gang;
186+
return C->getClauseKind() == OpenACCClauseKind::Worker;
187187
}
188188

189189
static OpenACCWorkerClause *

clang/include/clang/AST/PrettyPrinter.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,17 @@ class PrintingCallbacks {
5555
/// This type is intended to be small and suitable for passing by value.
5656
/// It is very frequently copied.
5757
struct PrintingPolicy {
58+
enum SuppressInlineNamespaceMode : uint8_t { None, Redundant, All };
59+
5860
/// Create a default printing policy for the specified language.
5961
PrintingPolicy(const LangOptions &LO)
6062
: Indentation(2), SuppressSpecifiers(false),
6163
SuppressTagKeyword(LO.CPlusPlus), IncludeTagDefinition(false),
6264
SuppressScope(false), SuppressUnwrittenScope(false),
63-
SuppressInlineNamespace(true), SuppressElaboration(false),
64-
SuppressInitializers(false), ConstantArraySizeAsWritten(false),
65-
AnonymousTagLocations(true), SuppressStrongLifetime(false),
66-
SuppressLifetimeQualifiers(false),
65+
SuppressInlineNamespace(SuppressInlineNamespaceMode::Redundant),
66+
SuppressElaboration(false), SuppressInitializers(false),
67+
ConstantArraySizeAsWritten(false), AnonymousTagLocations(true),
68+
SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
6769
SuppressTemplateArgsInCXXConstructors(false),
6870
SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
6971
Nullptr(LO.CPlusPlus11 || LO.C23), NullptrTypeInNamespace(LO.CPlusPlus),
@@ -141,10 +143,12 @@ struct PrintingPolicy {
141143
unsigned SuppressUnwrittenScope : 1;
142144

143145
/// Suppress printing parts of scope specifiers that correspond
144-
/// to inline namespaces, where the name is unambiguous with the specifier
146+
/// to inline namespaces.
147+
/// If Redudant, where the name is unambiguous with the specifier removed.
148+
/// If All, even if the name is ambiguous with the specifier
145149
/// removed.
146-
LLVM_PREFERRED_TYPE(bool)
147-
unsigned SuppressInlineNamespace : 1;
150+
LLVM_PREFERRED_TYPE(SuppressInlineNamespaceMode)
151+
unsigned SuppressInlineNamespace : 2;
148152

149153
/// Ignore qualifiers and tag keywords as specified by elaborated type sugar,
150154
/// instead letting the underlying type print as normal.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def warn_reserved_extern_symbol: Warning<
439439
InGroup<ReservedIdentifier>, DefaultIgnore;
440440
def warn_deprecated_literal_operator_id: Warning<
441441
"identifier %0 preceded by whitespace in a literal operator declaration "
442-
"is deprecated">, InGroup<DeprecatedLiteralOperator>, DefaultIgnore;
442+
"is deprecated">, InGroup<DeprecatedLiteralOperator>;
443443
def warn_reserved_module_name : Warning<
444444
"%0 is a reserved name for a module">, InGroup<ReservedModuleIdentifier>;
445445
def warn_import_implementation_partition_unit_in_interface_unit : Warning<
@@ -5262,13 +5262,6 @@ def note_template_arg_refers_here_func : Note<
52625262
def err_template_arg_template_params_mismatch : Error<
52635263
"template template argument has different template parameters than its "
52645264
"corresponding template template parameter">;
5265-
def note_template_arg_template_params_mismatch : Note<
5266-
"template template argument has different template parameters than its "
5267-
"corresponding template template parameter">;
5268-
def err_non_deduced_mismatch : Error<
5269-
"could not match %diff{$ against $|types}0,1">;
5270-
def err_inconsistent_deduction : Error<
5271-
"conflicting deduction %diff{$ against $|types}0,1 for parameter">;
52725265
def err_template_arg_not_integral_or_enumeral : Error<
52735266
"non-type template argument of type %0 must have an integral or enumeration"
52745267
" type">;

clang/include/clang/Basic/OpenACCKinds.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace clang {
2222
// Represents the Construct/Directive kind of a pragma directive. Note the
2323
// OpenACC standard is inconsistent between calling these Construct vs
2424
// Directive, but we're calling it a Directive to be consistent with OpenMP.
25-
enum class OpenACCDirectiveKind {
25+
enum class OpenACCDirectiveKind : uint8_t {
2626
// Compute Constructs.
2727
Parallel,
2828
Serial,
@@ -152,7 +152,7 @@ inline bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K) {
152152
K == OpenACCDirectiveKind::Kernels;
153153
}
154154

155-
enum class OpenACCAtomicKind {
155+
enum class OpenACCAtomicKind : uint8_t {
156156
Read,
157157
Write,
158158
Update,
@@ -161,7 +161,7 @@ enum class OpenACCAtomicKind {
161161
};
162162

163163
/// Represents the kind of an OpenACC clause.
164-
enum class OpenACCClauseKind {
164+
enum class OpenACCClauseKind : uint8_t {
165165
/// 'finalize' clause, allowed on 'exit data' directive.
166166
Finalize,
167167
/// 'if_present' clause, allowed on 'host_data' and 'update' directives.
@@ -459,7 +459,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
459459
return printOpenACCClauseKind(Out, K);
460460
}
461461

462-
enum class OpenACCDefaultClauseKind {
462+
enum class OpenACCDefaultClauseKind : uint8_t {
463463
/// 'none' option.
464464
None,
465465
/// 'present' option.
@@ -492,7 +492,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &Out,
492492
return printOpenACCDefaultClauseKind(Out, K);
493493
}
494494

495-
enum class OpenACCReductionOperator {
495+
enum class OpenACCReductionOperator : uint8_t {
496496
/// '+'.
497497
Addition,
498498
/// '*'.

clang/include/clang/Sema/Overload.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -925,11 +925,6 @@ class Sema;
925925

926926
bool TookAddressOfOverload : 1;
927927

928-
/// Have we matched any packs on the parameter side, versus any non-packs on
929-
/// the argument side, in a context where the opposite matching is also
930-
/// allowed?
931-
bool HasMatchedPackOnParmToNonPackOnArg : 1;
932-
933928
/// True if the candidate was found using ADL.
934929
CallExpr::ADLCallKind IsADLCandidate : 1;
935930

@@ -1004,9 +999,8 @@ class Sema;
1004999
friend class OverloadCandidateSet;
10051000
OverloadCandidate()
10061001
: IsSurrogate(false), IgnoreObjectArgument(false),
1007-
TookAddressOfOverload(false),
1008-
HasMatchedPackOnParmToNonPackOnArg(false),
1009-
IsADLCandidate(CallExpr::NotADL), RewriteKind(CRK_None) {}
1002+
TookAddressOfOverload(false), IsADLCandidate(CallExpr::NotADL),
1003+
RewriteKind(CRK_None) {}
10101004
};
10111005

10121006
/// OverloadCandidateSet - A set of overload candidates, used in C++

clang/include/clang/Sema/Sema.h

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10134,8 +10134,7 @@ class Sema final : public SemaBase {
1013410134
ADLCallKind IsADLCandidate = ADLCallKind::NotADL,
1013510135
ConversionSequenceList EarlyConversions = std::nullopt,
1013610136
OverloadCandidateParamOrder PO = {},
10137-
bool AggregateCandidateDeduction = false,
10138-
bool HasMatchedPackOnParmToNonPackOnArg = false);
10137+
bool AggregateCandidateDeduction = false);
1013910138

1014010139
/// Add all of the function declarations in the given function set to
1014110140
/// the overload candidate set.
@@ -10170,8 +10169,7 @@ class Sema final : public SemaBase {
1017010169
bool SuppressUserConversions = false,
1017110170
bool PartialOverloading = false,
1017210171
ConversionSequenceList EarlyConversions = std::nullopt,
10173-
OverloadCandidateParamOrder PO = {},
10174-
bool HasMatchedPackOnParmToNonPackOnArg = false);
10172+
OverloadCandidateParamOrder PO = {});
1017510173

1017610174
/// Add a C++ member function template as a candidate to the candidate
1017710175
/// set, using template argument deduction to produce an appropriate member
@@ -10217,8 +10215,7 @@ class Sema final : public SemaBase {
1021710215
CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
1021810216
CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
1021910217
OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10220-
bool AllowExplicit, bool AllowResultConversion = true,
10221-
bool HasMatchedPackOnParmToNonPackOnArg = false);
10218+
bool AllowExplicit, bool AllowResultConversion = true);
1022210219

1022310220
/// Adds a conversion function template specialization
1022410221
/// candidate to the overload set, using template argument deduction
@@ -11641,8 +11638,7 @@ class Sema final : public SemaBase {
1164111638
SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
1164211639
SmallVectorImpl<TemplateArgument> &SugaredConverted,
1164311640
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11644-
CheckTemplateArgumentKind CTAK, bool PartialOrdering,
11645-
bool *MatchedPackOnParmToNonPackOnArg);
11641+
CheckTemplateArgumentKind CTAK);
1164611642

1164711643
/// Check that the given template arguments can be provided to
1164811644
/// the given template, converting the arguments along the way.
@@ -11689,8 +11685,7 @@ class Sema final : public SemaBase {
1168911685
SmallVectorImpl<TemplateArgument> &SugaredConverted,
1169011686
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
1169111687
bool UpdateArgsWithConversions = true,
11692-
bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false,
11693-
bool *MatchedPackOnParmToNonPackOnArg = nullptr);
11688+
bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false);
1169411689

1169511690
bool CheckTemplateTypeArgument(
1169611691
TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg,
@@ -11724,9 +11719,7 @@ class Sema final : public SemaBase {
1172411719
/// It returns true if an error occurred, and false otherwise.
1172511720
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
1172611721
TemplateParameterList *Params,
11727-
TemplateArgumentLoc &Arg,
11728-
bool PartialOrdering,
11729-
bool *MatchedPackOnParmToNonPackOnArg);
11722+
TemplateArgumentLoc &Arg, bool IsDeduced);
1173011723

1173111724
void NoteTemplateLocation(const NamedDecl &Decl,
1173211725
std::optional<SourceRange> ParamRange = {});
@@ -12237,8 +12230,8 @@ class Sema final : public SemaBase {
1223712230
SmallVectorImpl<DeducedTemplateArgument> &Deduced,
1223812231
unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
1223912232
sema::TemplateDeductionInfo &Info,
12240-
SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12241-
bool PartialOverloading, bool PartialOrdering,
12233+
SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
12234+
bool PartialOverloading = false,
1224212235
llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
1224312236

1224412237
/// Perform template argument deduction from a function call
@@ -12272,8 +12265,7 @@ class Sema final : public SemaBase {
1227212265
TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
1227312266
FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
1227412267
bool PartialOverloading, bool AggregateDeductionCandidate,
12275-
bool PartialOrdering, QualType ObjectType,
12276-
Expr::Classification ObjectClassification,
12268+
QualType ObjectType, Expr::Classification ObjectClassification,
1227712269
llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
1227812270

1227912271
/// Deduce template arguments when taking the address of a function
@@ -12426,9 +12418,8 @@ class Sema final : public SemaBase {
1242612418
sema::TemplateDeductionInfo &Info);
1242712419

1242812420
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
12429-
TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
12430-
const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12431-
bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg);
12421+
TemplateParameterList *PParam, TemplateDecl *AArg,
12422+
const DefaultArguments &DefaultArgs, SourceLocation Loc, bool IsDeduced);
1243212423

1243312424
/// Mark which template parameters are used in a given expression.
1243412425
///
@@ -12737,9 +12728,6 @@ class Sema final : public SemaBase {
1273712728

1273812729
/// We are instantiating a type alias template declaration.
1273912730
TypeAliasTemplateInstantiation,
12740-
12741-
/// We are performing partial ordering for template template parameters.
12742-
PartialOrderingTTP,
1274312731
} Kind;
1274412732

1274512733
/// Was the enclosing context a non-instantiation SFINAE context?
@@ -12961,12 +12949,6 @@ class Sema final : public SemaBase {
1296112949
TemplateDecl *Entity, BuildingDeductionGuidesTag,
1296212950
SourceRange InstantiationRange = SourceRange());
1296312951

12964-
struct PartialOrderingTTP {};
12965-
/// \brief Note that we are partial ordering template template parameters.
12966-
InstantiatingTemplate(Sema &SemaRef, SourceLocation ArgLoc,
12967-
PartialOrderingTTP, TemplateDecl *PArg,
12968-
SourceRange InstantiationRange = SourceRange());
12969-
1297012952
/// Note that we have finished instantiating this template.
1297112953
void Clear();
1297212954

@@ -13427,8 +13409,7 @@ class Sema final : public SemaBase {
1342713409
bool InstantiateClassTemplateSpecialization(
1342813410
SourceLocation PointOfInstantiation,
1342913411
ClassTemplateSpecializationDecl *ClassTemplateSpec,
13430-
TemplateSpecializationKind TSK, bool Complain = true,
13431-
bool PrimaryHasMatchedPackOnParmToNonPackOnArg = false);
13412+
TemplateSpecializationKind TSK, bool Complain = true);
1343213413

1343313414
/// Instantiates the definitions of all of the member
1343413415
/// of the given class, which is an instantiation of a class template

clang/include/clang/Sema/TemplateDeduction.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ class TemplateDeductionInfo {
5151
/// Have we suppressed an error during deduction?
5252
bool HasSFINAEDiagnostic = false;
5353

54-
/// Have we matched any packs on the parameter side, versus any non-packs on
55-
/// the argument side, in a context where the opposite matching is also
56-
/// allowed?
57-
bool MatchedPackOnParmToNonPackOnArg = false;
58-
5954
/// The template parameter depth for which we're performing deduction.
6055
unsigned DeducedDepth;
6156

@@ -92,14 +87,6 @@ class TemplateDeductionInfo {
9287
return DeducedDepth;
9388
}
9489

95-
bool hasMatchedPackOnParmToNonPackOnArg() const {
96-
return MatchedPackOnParmToNonPackOnArg;
97-
}
98-
99-
void setMatchedPackOnParmToNonPackOnArg() {
100-
MatchedPackOnParmToNonPackOnArg = true;
101-
}
102-
10390
/// Get the number of explicitly-specified arguments.
10491
unsigned getNumExplicitArgs() const {
10592
return ExplicitArgs;

0 commit comments

Comments
 (0)