Skip to content

Commit 07e66aa

Browse files
Merge branch 'llvm:main' into gh-101657
2 parents a77dc02 + b9754e9 commit 07e66aa

File tree

153 files changed

+3216
-1546
lines changed

Some content is hidden

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

153 files changed

+3216
-1546
lines changed

.github/workflows/release-binaries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ jobs:
328328
run: |
329329
# Build some of the mlir tools that take a long time to link
330330
if [ "${{ needs.prepare.outputs.build-flang }}" = "true" ]; then
331-
ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ -j2 flang-new bbc
331+
ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ -j2 flang bbc
332332
fi
333333
ninja -C ${{ steps.setup-stage.outputs.build-prefix }}/build/tools/clang/stage2-bins/ \
334334
mlir-bytecode-parser-fuzzer \

clang/docs/ReleaseNotes.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ C++23 Feature Support
174174
C++20 Feature Support
175175
^^^^^^^^^^^^^^^^^^^^^
176176

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.
177181

178182
Resolutions to C++ Defect Reports
179183
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -200,7 +204,8 @@ Resolutions to C++ Defect Reports
200204
(`CWG2351: void{} <https://cplusplus.github.io/CWG/issues/2351.html>`_).
201205

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

205210
- Clang now allows comparing unequal object pointers that have been cast to ``void *``
206211
in constant expressions. These comparisons always worked in non-constant expressions.
@@ -331,6 +336,10 @@ Improvements to Clang's diagnostics
331336

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

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

336345
- Improved diagnostic when trying to befriend a concept. (#GH45182).
@@ -440,6 +449,8 @@ Bug Fixes to C++ Support
440449
- Correctly check constraints of explicit instantiations of member functions. (#GH46029)
441450
- When performing partial ordering of function templates, clang now checks that
442451
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.
443454
- Fixed an assertion failure about a constraint of a friend function template references to a value with greater
444455
template depth than the friend function template. (#GH98258)
445456
- Clang now rebuilds the template parameters of out-of-line declarations and specializations in the context
@@ -478,6 +489,8 @@ Bug Fixes to C++ Support
478489
- Clang now instantiates the correct lambda call operator when a lambda's class type is
479490
merged across modules. (#GH110401)
480491
- Fix a crash when parsing a pseudo destructor involving an invalid type. (#GH111460)
492+
- Fixed an assertion failure when invoking recovery call expressions with explicit attributes
493+
and undeclared templates. (#GH107047, #GH49093)
481494

482495
Bug Fixes to AST Handling
483496
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/DeclBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,9 @@ class alignas(8) Decl {
687687
/// Whether this declaration comes from a named module.
688688
bool isInNamedModule() const;
689689

690+
/// Whether this declaration comes from a header unit.
691+
bool isFromHeaderUnit() const;
692+
690693
/// Return true if this declaration has an attribute which acts as
691694
/// definition of the entity, such as 'alias' or 'ifunc'.
692695
bool hasDefiningAttr() const;

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ def warn_drv_unsupported_option_for_processor : Warning<
147147
def warn_drv_unsupported_openmp_library : Warning<
148148
"the library '%0=%1' is not supported, OpenMP will not be enabled">,
149149
InGroup<OptionIgnored>;
150+
def warn_openmp_experimental : Warning<
151+
"OpenMP support in flang is still experimental">,
152+
InGroup<ExperimentalOption>;
150153

151154
def err_drv_invalid_thread_model_for_target : Error<
152155
"invalid thread model '%0' in '%1' for this target">;

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,3 +1583,7 @@ def ExtractAPIMisuse : DiagGroup<"extractapi-misuse">;
15831583
// Warnings about using the non-standard extension having an explicit specialization
15841584
// with a storage class specifier.
15851585
def ExplicitSpecializationStorageClass : DiagGroup<"explicit-specialization-storage-class">;
1586+
1587+
// A warning for options that enable a feature that is not yet complete
1588+
def ExperimentalOption : DiagGroup<"experimental-option">;
1589+

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5262,6 +5262,13 @@ 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">;
52655272
def err_template_arg_not_integral_or_enumeral : Error<
52665273
"non-type template argument of type %0 must have an integral or enumeration"
52675274
" type">;

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6077,7 +6077,7 @@ def _sysroot_EQ : Joined<["--"], "sysroot=">, Visibility<[ClangOption, FlangOpti
60776077
def _sysroot : Separate<["--"], "sysroot">, Alias<_sysroot_EQ>;
60786078

60796079
//===----------------------------------------------------------------------===//
6080-
// pie/pic options (clang + flang-new)
6080+
// pie/pic options (clang + flang)
60816081
//===----------------------------------------------------------------------===//
60826082
let Visibility = [ClangOption, FlangOption] in {
60836083

@@ -6093,7 +6093,7 @@ def fno_pie : Flag<["-"], "fno-pie">, Group<f_Group>;
60936093
} // let Vis = [Default, FlangOption]
60946094

60956095
//===----------------------------------------------------------------------===//
6096-
// Target Options (clang + flang-new)
6096+
// Target Options (clang + flang)
60976097
//===----------------------------------------------------------------------===//
60986098
let Flags = [TargetSpecific] in {
60996099
let Visibility = [ClangOption, FlangOption] in {

clang/include/clang/Sema/Overload.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,11 @@ 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+
928933
/// True if the candidate was found using ADL.
929934
CallExpr::ADLCallKind IsADLCandidate : 1;
930935

@@ -999,8 +1004,9 @@ class Sema;
9991004
friend class OverloadCandidateSet;
10001005
OverloadCandidate()
10011006
: IsSurrogate(false), IgnoreObjectArgument(false),
1002-
TookAddressOfOverload(false), IsADLCandidate(CallExpr::NotADL),
1003-
RewriteKind(CRK_None) {}
1007+
TookAddressOfOverload(false),
1008+
HasMatchedPackOnParmToNonPackOnArg(false),
1009+
IsADLCandidate(CallExpr::NotADL), RewriteKind(CRK_None) {}
10041010
};
10051011

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

clang/include/clang/Sema/Sema.h

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

1013810139
/// Add all of the function declarations in the given function set to
1013910140
/// the overload candidate set.
@@ -10168,7 +10169,8 @@ class Sema final : public SemaBase {
1016810169
bool SuppressUserConversions = false,
1016910170
bool PartialOverloading = false,
1017010171
ConversionSequenceList EarlyConversions = std::nullopt,
10171-
OverloadCandidateParamOrder PO = {});
10172+
OverloadCandidateParamOrder PO = {},
10173+
bool HasMatchedPackOnParmToNonPackOnArg = false);
1017210174

1017310175
/// Add a C++ member function template as a candidate to the candidate
1017410176
/// set, using template argument deduction to produce an appropriate member
@@ -10214,7 +10216,8 @@ class Sema final : public SemaBase {
1021410216
CXXConversionDecl *Conversion, DeclAccessPair FoundDecl,
1021510217
CXXRecordDecl *ActingContext, Expr *From, QualType ToType,
1021610218
OverloadCandidateSet &CandidateSet, bool AllowObjCConversionOnExplicit,
10217-
bool AllowExplicit, bool AllowResultConversion = true);
10219+
bool AllowExplicit, bool AllowResultConversion = true,
10220+
bool HasMatchedPackOnParmToNonPackOnArg = false);
1021810221

1021910222
/// Adds a conversion function template specialization
1022010223
/// candidate to the overload set, using template argument deduction
@@ -11637,7 +11640,8 @@ class Sema final : public SemaBase {
1163711640
SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
1163811641
SmallVectorImpl<TemplateArgument> &SugaredConverted,
1163911642
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11640-
CheckTemplateArgumentKind CTAK);
11643+
CheckTemplateArgumentKind CTAK, bool PartialOrdering,
11644+
bool *MatchedPackOnParmToNonPackOnArg);
1164111645

1164211646
/// Check that the given template arguments can be provided to
1164311647
/// the given template, converting the arguments along the way.
@@ -11684,7 +11688,8 @@ class Sema final : public SemaBase {
1168411688
SmallVectorImpl<TemplateArgument> &SugaredConverted,
1168511689
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
1168611690
bool UpdateArgsWithConversions = true,
11687-
bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false);
11691+
bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false,
11692+
bool *MatchedPackOnParmToNonPackOnArg = nullptr);
1168811693

1168911694
bool CheckTemplateTypeArgument(
1169011695
TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg,
@@ -11718,7 +11723,9 @@ class Sema final : public SemaBase {
1171811723
/// It returns true if an error occurred, and false otherwise.
1171911724
bool CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
1172011725
TemplateParameterList *Params,
11721-
TemplateArgumentLoc &Arg, bool IsDeduced);
11726+
TemplateArgumentLoc &Arg,
11727+
bool PartialOrdering,
11728+
bool *MatchedPackOnParmToNonPackOnArg);
1172211729

1172311730
void NoteTemplateLocation(const NamedDecl &Decl,
1172411731
std::optional<SourceRange> ParamRange = {});
@@ -12229,8 +12236,8 @@ class Sema final : public SemaBase {
1222912236
SmallVectorImpl<DeducedTemplateArgument> &Deduced,
1223012237
unsigned NumExplicitlySpecified, FunctionDecl *&Specialization,
1223112238
sema::TemplateDeductionInfo &Info,
12232-
SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr,
12233-
bool PartialOverloading = false,
12239+
SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs,
12240+
bool PartialOverloading, bool PartialOrdering,
1223412241
llvm::function_ref<bool()> CheckNonDependent = [] { return false; });
1223512242

1223612243
/// Perform template argument deduction from a function call
@@ -12264,7 +12271,8 @@ class Sema final : public SemaBase {
1226412271
TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef<Expr *> Args,
1226512272
FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
1226612273
bool PartialOverloading, bool AggregateDeductionCandidate,
12267-
QualType ObjectType, Expr::Classification ObjectClassification,
12274+
bool PartialOrdering, QualType ObjectType,
12275+
Expr::Classification ObjectClassification,
1226812276
llvm::function_ref<bool(ArrayRef<QualType>)> CheckNonDependent);
1226912277

1227012278
/// Deduce template arguments when taking the address of a function
@@ -12417,8 +12425,9 @@ class Sema final : public SemaBase {
1241712425
sema::TemplateDeductionInfo &Info);
1241812426

1241912427
bool isTemplateTemplateParameterAtLeastAsSpecializedAs(
12420-
TemplateParameterList *PParam, TemplateDecl *AArg,
12421-
const DefaultArguments &DefaultArgs, SourceLocation Loc, bool IsDeduced);
12428+
TemplateParameterList *PParam, TemplateDecl *PArg, TemplateDecl *AArg,
12429+
const DefaultArguments &DefaultArgs, SourceLocation ArgLoc,
12430+
bool PartialOrdering, bool *MatchedPackOnParmToNonPackOnArg);
1242212431

1242312432
/// Mark which template parameters are used in a given expression.
1242412433
///
@@ -12727,6 +12736,9 @@ class Sema final : public SemaBase {
1272712736

1272812737
/// We are instantiating a type alias template declaration.
1272912738
TypeAliasTemplateInstantiation,
12739+
12740+
/// We are performing partial ordering for template template parameters.
12741+
PartialOrderingTTP,
1273012742
} Kind;
1273112743

1273212744
/// Was the enclosing context a non-instantiation SFINAE context?
@@ -12948,6 +12960,12 @@ class Sema final : public SemaBase {
1294812960
TemplateDecl *Entity, BuildingDeductionGuidesTag,
1294912961
SourceRange InstantiationRange = SourceRange());
1295012962

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

@@ -13408,7 +13426,8 @@ class Sema final : public SemaBase {
1340813426
bool InstantiateClassTemplateSpecialization(
1340913427
SourceLocation PointOfInstantiation,
1341013428
ClassTemplateSpecializationDecl *ClassTemplateSpec,
13411-
TemplateSpecializationKind TSK, bool Complain = true);
13429+
TemplateSpecializationKind TSK, bool Complain = true,
13430+
bool PrimaryHasMatchedPackOnParmToNonPackOnArg = false);
1341213431

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

clang/include/clang/Sema/TemplateDeduction.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ 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+
5459
/// The template parameter depth for which we're performing deduction.
5560
unsigned DeducedDepth;
5661

@@ -87,6 +92,14 @@ class TemplateDeductionInfo {
8792
return DeducedDepth;
8893
}
8994

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

0 commit comments

Comments
 (0)