Skip to content

Commit 2bc0b2a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into cwg418
2 parents 0e24e37 + 9052b37 commit 2bc0b2a

File tree

119 files changed

+35738
-2838
lines changed

Some content is hidden

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

119 files changed

+35738
-2838
lines changed

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 0 additions & 312 deletions
Large diffs are not rendered by default.

clang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ if(NOT DEFINED CLANG_VERSION_SUFFIX)
331331
set(CLANG_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
332332
endif()
333333
set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}${CLANG_VERSION_SUFFIX}")
334+
set(MAX_CLANG_ABI_COMPAT_VERSION "${LLVM_VERSION_MAJOR}")
334335
message(STATUS "Clang version: ${CLANG_VERSION}")
335336

336337
# Configure the Version.inc file.

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 1294 deletions
Large diffs are not rendered by default.

clang/include/clang/Basic/Version.inc.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
#define CLANG_VERSION_MAJOR_STRING "@CLANG_VERSION_MAJOR@"
55
#define CLANG_VERSION_MINOR @CLANG_VERSION_MINOR@
66
#define CLANG_VERSION_PATCHLEVEL @CLANG_VERSION_PATCHLEVEL@
7+
#define MAX_CLANG_ABI_COMPAT_VERSION @MAX_CLANG_ABI_COMPAT_VERSION@

clang/include/clang/Sema/Sema.h

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11651,6 +11651,33 @@ class Sema final : public SemaBase {
1165111651
CTAK_DeducedFromArrayBound
1165211652
};
1165311653

11654+
struct CheckTemplateArgumentInfo {
11655+
explicit CheckTemplateArgumentInfo(bool PartialOrdering = false,
11656+
bool MatchingTTP = false)
11657+
: PartialOrdering(PartialOrdering), MatchingTTP(MatchingTTP) {}
11658+
CheckTemplateArgumentInfo(const CheckTemplateArgumentInfo &) = delete;
11659+
CheckTemplateArgumentInfo &
11660+
operator=(const CheckTemplateArgumentInfo &) = delete;
11661+
11662+
/// The checked, converted argument will be added to the
11663+
/// end of these vectors.
11664+
SmallVector<TemplateArgument, 4> SugaredConverted, CanonicalConverted;
11665+
11666+
/// The check is being performed in the context of partial ordering.
11667+
bool PartialOrdering;
11668+
11669+
/// If true, assume these template arguments are
11670+
/// the injected template arguments for a template template parameter.
11671+
/// This will relax the requirement that all its possible uses are valid:
11672+
/// TTP checking is loose, and assumes that invalid uses will be diagnosed
11673+
/// during instantiation.
11674+
bool MatchingTTP;
11675+
11676+
/// Is set to true when, in the context of TTP matching, a pack parameter
11677+
/// matches non-pack arguments.
11678+
bool MatchedPackOnParmToNonPackOnArg = false;
11679+
};
11680+
1165411681
/// Check that the given template argument corresponds to the given
1165511682
/// template parameter.
1165611683
///
@@ -11670,22 +11697,16 @@ class Sema final : public SemaBase {
1167011697
/// \param ArgumentPackIndex The index into the argument pack where this
1167111698
/// argument will be placed. Only valid if the parameter is a parameter pack.
1167211699
///
11673-
/// \param Converted The checked, converted argument will be added to the
11674-
/// end of this small vector.
11675-
///
1167611700
/// \param CTAK Describes how we arrived at this particular template argument:
1167711701
/// explicitly written, deduced, etc.
1167811702
///
1167911703
/// \returns true on error, false otherwise.
11680-
bool
11681-
CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11682-
NamedDecl *Template, SourceLocation TemplateLoc,
11683-
SourceLocation RAngleLoc, unsigned ArgumentPackIndex,
11684-
SmallVectorImpl<TemplateArgument> &SugaredConverted,
11685-
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11686-
CheckTemplateArgumentKind CTAK, bool PartialOrdering,
11687-
bool PartialOrderingTTP,
11688-
bool *MatchedPackOnParmToNonPackOnArg);
11704+
bool CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &Arg,
11705+
NamedDecl *Template, SourceLocation TemplateLoc,
11706+
SourceLocation RAngleLoc,
11707+
unsigned ArgumentPackIndex,
11708+
CheckTemplateArgumentInfo &CTAI,
11709+
CheckTemplateArgumentKind CTAK);
1168911710

1169011711
/// Check that the given template arguments can be provided to
1169111712
/// the given template, converting the arguments along the way.
@@ -11718,22 +11739,15 @@ class Sema final : public SemaBase {
1171811739
/// \param DefaultArgs any default arguments from template specialization
1171911740
/// deduction.
1172011741
///
11721-
/// \param PartialOrderingTTP If true, assume these template arguments are
11722-
/// the injected template arguments for a template template parameter.
11723-
/// This will relax the requirement that all its possible uses are valid:
11724-
/// TTP checking is loose, and assumes that invalid uses will be diagnosed
11725-
/// during instantiation.
11726-
///
1172711742
/// \returns true if an error occurred, false otherwise.
11728-
bool CheckTemplateArgumentList(
11729-
TemplateDecl *Template, SourceLocation TemplateLoc,
11730-
TemplateArgumentListInfo &TemplateArgs,
11731-
const DefaultArguments &DefaultArgs, bool PartialTemplateArgs,
11732-
SmallVectorImpl<TemplateArgument> &SugaredConverted,
11733-
SmallVectorImpl<TemplateArgument> &CanonicalConverted,
11734-
bool UpdateArgsWithConversions = true,
11735-
bool *ConstraintsNotSatisfied = nullptr, bool PartialOrderingTTP = false,
11736-
bool *MatchedPackOnParmToNonPackOnArg = nullptr);
11743+
bool CheckTemplateArgumentList(TemplateDecl *Template,
11744+
SourceLocation TemplateLoc,
11745+
TemplateArgumentListInfo &TemplateArgs,
11746+
const DefaultArguments &DefaultArgs,
11747+
bool PartialTemplateArgs,
11748+
CheckTemplateArgumentInfo &CTAI,
11749+
bool UpdateArgsWithConversions = true,
11750+
bool *ConstraintsNotSatisfied = nullptr);
1173711751

1173811752
bool CheckTemplateTypeArgument(
1173911753
TemplateTypeParmDecl *Param, TemplateArgumentLoc &Arg,
@@ -11758,7 +11772,7 @@ class Sema final : public SemaBase {
1175811772
QualType InstantiatedParamType, Expr *Arg,
1175911773
TemplateArgument &SugaredConverted,
1176011774
TemplateArgument &CanonicalConverted,
11761-
bool PartialOrderingTTP,
11775+
bool MatchingTTP,
1176211776
CheckTemplateArgumentKind CTAK);
1176311777

1176411778
/// Check a template argument against its corresponding

clang/lib/AST/StmtPrinter.cpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,28 +1257,48 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
12571257
}
12581258

12591259
void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
1260-
if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) {
1260+
ValueDecl *VD = Node->getDecl();
1261+
if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
12611262
OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
12621263
return;
12631264
}
1264-
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(Node->getDecl())) {
1265+
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
12651266
TPOD->printAsExpr(OS, Policy);
12661267
return;
12671268
}
12681269
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
12691270
Qualifier->print(OS, Policy);
12701271
if (Node->hasTemplateKeyword())
12711272
OS << "template ";
1272-
if (Policy.CleanUglifiedParameters &&
1273-
isa<ParmVarDecl, NonTypeTemplateParmDecl>(Node->getDecl()) &&
1274-
Node->getDecl()->getIdentifier())
1275-
OS << Node->getDecl()->getIdentifier()->deuglifiedName();
1276-
else
1277-
Node->getNameInfo().printName(OS, Policy);
1273+
DeclarationNameInfo NameInfo = Node->getNameInfo();
1274+
if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo();
1275+
ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) {
1276+
if (Policy.CleanUglifiedParameters &&
1277+
isa<ParmVarDecl, NonTypeTemplateParmDecl>(VD) && ID)
1278+
OS << ID->deuglifiedName();
1279+
else
1280+
NameInfo.printName(OS, Policy);
1281+
} else {
1282+
switch (VD->getKind()) {
1283+
case Decl::NonTypeTemplateParm: {
1284+
auto *TD = cast<NonTypeTemplateParmDecl>(VD);
1285+
OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << "";
1286+
break;
1287+
}
1288+
case Decl::ParmVar: {
1289+
auto *PD = cast<ParmVarDecl>(VD);
1290+
OS << "function-parameter-" << PD->getFunctionScopeDepth() << '-'
1291+
<< PD->getFunctionScopeIndex();
1292+
break;
1293+
}
1294+
default:
1295+
llvm_unreachable("Unhandled anonymous declaration kind");
1296+
}
1297+
}
12781298
if (Node->hasExplicitTemplateArgs()) {
12791299
const TemplateParameterList *TPL = nullptr;
12801300
if (!Node->hadMultipleCandidates())
1281-
if (auto *TD = dyn_cast<TemplateDecl>(Node->getDecl()))
1301+
if (auto *TD = dyn_cast<TemplateDecl>(VD))
12821302
TPL = TD->getTemplateParameters();
12831303
printTemplateArgumentList(OS, Node->template_arguments(), Policy, TPL);
12841304
}

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,41 @@ void TextNodeDumper::dumpBareDeclRef(const Decl *D) {
901901

902902
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
903903
ColorScope Color(OS, ShowColors, DeclNameColor);
904-
OS << " '" << ND->getDeclName() << '\'';
904+
if (DeclarationName Name = ND->getDeclName())
905+
OS << " '" << Name << '\'';
906+
else
907+
switch (ND->getKind()) {
908+
case Decl::Decomposition: {
909+
auto *DD = cast<DecompositionDecl>(ND);
910+
OS << " first_binding '" << DD->bindings()[0]->getDeclName() << '\'';
911+
break;
912+
}
913+
case Decl::Field: {
914+
auto *FD = cast<FieldDecl>(ND);
915+
OS << " field_index " << FD->getFieldIndex();
916+
break;
917+
}
918+
case Decl::ParmVar: {
919+
auto *PD = cast<ParmVarDecl>(ND);
920+
OS << " depth " << PD->getFunctionScopeDepth() << " index "
921+
<< PD->getFunctionScopeIndex();
922+
break;
923+
}
924+
case Decl::TemplateTypeParm: {
925+
auto *TD = cast<TemplateTypeParmDecl>(ND);
926+
OS << " depth " << TD->getDepth() << " index " << TD->getIndex();
927+
break;
928+
}
929+
case Decl::NonTypeTemplateParm: {
930+
auto *TD = cast<NonTypeTemplateParmDecl>(ND);
931+
OS << " depth " << TD->getDepth() << " index " << TD->getIndex();
932+
break;
933+
}
934+
default:
935+
// Var, Namespace, (CXX)Record: Nothing else besides source location.
936+
dumpSourceRange(ND->getSourceRange());
937+
break;
938+
}
905939
}
906940

907941
if (const ValueDecl *VD = dyn_cast<ValueDecl>(D))

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2815,7 +2815,7 @@ static bool shouldOmitDefinition(llvm::codegenoptions::DebugInfoKind DebugKind,
28152815
// without any dllimport methods can be used in one DLL and constructed in
28162816
// another, but it is the current behavior of LimitedDebugInfo.
28172817
if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
2818-
!isClassOrMethodDLLImport(CXXDecl))
2818+
!isClassOrMethodDLLImport(CXXDecl) && !CXXDecl->hasAttr<MSNoVTableAttr>())
28192819
return true;
28202820

28212821
TemplateSpecializationKind Spec = TSK_Undeclared;

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4413,7 +4413,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
44134413
// y or y.0 (4 <= y <= current version).
44144414
if (!VerParts.first.starts_with("0") &&
44154415
!VerParts.first.getAsInteger(10, Major) && 3 <= Major &&
4416-
Major <= CLANG_VERSION_MAJOR &&
4416+
Major <= MAX_CLANG_ABI_COMPAT_VERSION &&
44174417
(Major == 3
44184418
? VerParts.second.size() == 1 &&
44194419
!VerParts.second.getAsInteger(10, Minor)

clang/lib/Sema/SemaLookup.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,13 +3721,11 @@ Sema::LookupLiteralOperator(Scope *S, LookupResult &R,
37213721
// is a well-formed template argument for the template parameter.
37223722
if (StringLit) {
37233723
SFINAETrap Trap(*this);
3724-
SmallVector<TemplateArgument, 1> SugaredChecked, CanonicalChecked;
3724+
CheckTemplateArgumentInfo CTAI;
37253725
TemplateArgumentLoc Arg(TemplateArgument(StringLit), StringLit);
37263726
if (CheckTemplateArgument(
37273727
Params->getParam(0), Arg, FD, R.getNameLoc(), R.getNameLoc(),
3728-
0, SugaredChecked, CanonicalChecked, CTAK_Specified,
3729-
/*PartialOrdering=*/false, /*PartialOrderingTTP=*/false,
3730-
/*MatchedPackOnParmToNonPackOnArg=*/nullptr) ||
3728+
/*ArgumentPackIndex=*/0, CTAI, CTAK_Specified) ||
37313729
Trap.hasErrorOccurred())
37323730
IsTemplate = false;
37333731
}

0 commit comments

Comments
 (0)