aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/AST/TemplateBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/TemplateBase.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/AST/TemplateBase.cpp35
1 files changed, 31 insertions, 4 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/TemplateBase.cpp b/contrib/llvm-project/clang/lib/AST/TemplateBase.cpp
index 6a3d2b30e46e..baf62bd115a8 100644
--- a/contrib/llvm-project/clang/lib/AST/TemplateBase.cpp
+++ b/contrib/llvm-project/clang/lib/AST/TemplateBase.cpp
@@ -244,6 +244,7 @@ void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID,
break;
case Declaration:
+ getParamTypeForDecl().Profile(ID);
ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : nullptr);
break;
@@ -288,11 +289,14 @@ bool TemplateArgument::structurallyEquals(const TemplateArgument &Other) const {
case Null:
case Type:
case Expression:
- case Template:
- case TemplateExpansion:
case NullPtr:
return TypeOrValue.V == Other.TypeOrValue.V;
+ case Template:
+ case TemplateExpansion:
+ return TemplateArg.Name == Other.TemplateArg.Name &&
+ TemplateArg.NumExpansions == Other.TemplateArg.NumExpansions;
+
case Declaration:
return getAsDecl() == Other.getAsDecl();
@@ -352,6 +356,13 @@ void TemplateArgument::print(const PrintingPolicy &Policy,
case Declaration: {
NamedDecl *ND = getAsDecl();
+ if (getParamTypeForDecl()->isRecordType()) {
+ if (auto *TPO = dyn_cast<TemplateParamObjectDecl>(ND)) {
+ // FIXME: Include the type if it's not obvious from the context.
+ TPO->printAsInit(Out);
+ break;
+ }
+ }
if (!getParamTypeForDecl()->isReferenceType())
Out << '&';
ND->printQualifiedName(Out);
@@ -448,8 +459,8 @@ SourceRange TemplateArgumentLoc::getSourceRange() const {
llvm_unreachable("Invalid TemplateArgument Kind!");
}
-const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
- const TemplateArgument &Arg) {
+template <typename T>
+static const T &DiagTemplateArg(const T &DB, const TemplateArgument &Arg) {
switch (Arg.getKind()) {
case TemplateArgument::Null:
// This is bad, but not as bad as crashing because of argument
@@ -502,6 +513,22 @@ const DiagnosticBuilder &clang::operator<<(const DiagnosticBuilder &DB,
llvm_unreachable("Invalid TemplateArgument Kind!");
}
+const StreamingDiagnostic &clang::operator<<(const StreamingDiagnostic &DB,
+ const TemplateArgument &Arg) {
+ return DiagTemplateArg(DB, Arg);
+}
+
+clang::TemplateArgumentLocInfo::TemplateArgumentLocInfo(
+ ASTContext &Ctx, NestedNameSpecifierLoc QualifierLoc,
+ SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc) {
+ TemplateTemplateArgLocInfo *Template = new (Ctx) TemplateTemplateArgLocInfo;
+ Template->Qualifier = QualifierLoc.getNestedNameSpecifier();
+ Template->QualifierLocData = QualifierLoc.getOpaqueData();
+ Template->TemplateNameLoc = TemplateNameLoc;
+ Template->EllipsisLoc = EllipsisLoc;
+ Pointer = Template;
+}
+
const ASTTemplateArgumentListInfo *
ASTTemplateArgumentListInfo::Create(const ASTContext &C,
const TemplateArgumentListInfo &List) {