diff options
Diffstat (limited to 'lib/AST/NestedNameSpecifier.cpp')
-rw-r--r-- | lib/AST/NestedNameSpecifier.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp index a514d57b6b6bc..42f6a133d7174 100644 --- a/lib/AST/NestedNameSpecifier.cpp +++ b/lib/AST/NestedNameSpecifier.cpp @@ -16,6 +16,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclTemplate.h" #include "clang/AST/PrettyPrinter.h" #include "clang/AST/TemplateName.h" #include "clang/AST/Type.h" @@ -270,9 +271,8 @@ bool NestedNameSpecifier::containsUnexpandedParameterPack() const { /// Print this nested name specifier to the given output /// stream. -void -NestedNameSpecifier::print(raw_ostream &OS, - const PrintingPolicy &Policy) const { +void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy, + bool ResolveTemplateArguments) const { if (getPrefix()) getPrefix()->print(OS, Policy); @@ -305,6 +305,15 @@ NestedNameSpecifier::print(raw_ostream &OS, LLVM_FALLTHROUGH; case TypeSpec: { + const auto *Record = + dyn_cast_or_null<ClassTemplateSpecializationDecl>(getAsRecordDecl()); + if (ResolveTemplateArguments && Record) { + // Print the type trait with resolved template parameters. + Record->printName(OS); + printTemplateArgumentList(OS, Record->getTemplateArgs().asArray(), + Policy); + break; + } const Type *T = getAsType(); PrintingPolicy InnerPolicy(Policy); @@ -339,13 +348,20 @@ NestedNameSpecifier::print(raw_ostream &OS, OS << "::"; } -void NestedNameSpecifier::dump(const LangOptions &LO) const { - print(llvm::errs(), PrintingPolicy(LO)); +LLVM_DUMP_METHOD void NestedNameSpecifier::dump(const LangOptions &LO) const { + dump(llvm::errs(), LO); } -LLVM_DUMP_METHOD void NestedNameSpecifier::dump() const { +LLVM_DUMP_METHOD void NestedNameSpecifier::dump() const { dump(llvm::errs()); } + +LLVM_DUMP_METHOD void NestedNameSpecifier::dump(llvm::raw_ostream &OS) const { LangOptions LO; - print(llvm::errs(), PrintingPolicy(LO)); + dump(OS, LO); +} + +LLVM_DUMP_METHOD void NestedNameSpecifier::dump(llvm::raw_ostream &OS, + const LangOptions &LO) const { + print(OS, PrintingPolicy(LO)); } unsigned @@ -446,9 +462,9 @@ SourceRange NestedNameSpecifierLoc::getLocalSourceRange() const { } TypeLoc NestedNameSpecifierLoc::getTypeLoc() const { - assert((Qualifier->getKind() == NestedNameSpecifier::TypeSpec || - Qualifier->getKind() == NestedNameSpecifier::TypeSpecWithTemplate) && - "Nested-name-specifier location is not a type"); + if (Qualifier->getKind() != NestedNameSpecifier::TypeSpec && + Qualifier->getKind() != NestedNameSpecifier::TypeSpecWithTemplate) + return TypeLoc(); // The "void*" that points at the TypeLoc data. unsigned Offset = getDataLength(Qualifier->getPrefix()); @@ -547,6 +563,7 @@ operator=(const NestedNameSpecifierLocBuilder &Other) { } // Deep copy. + BufferSize = 0; Append(Other.Buffer, Other.Buffer + Other.BufferSize, Buffer, BufferSize, BufferCapacity); return *this; |