Generalize printing of nested-name-specifier sequences for use in both
QualifiedNameType and QualifiedDeclRefExpr. We now keep track of the
exact nested-name-specifier spelling for a QualifiedDeclRefExpr, and
use that spelling when printing ASTs. This fixes PR3493.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67283 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index b066802..1fb1e99 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -18,7 +18,7 @@
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "llvm/ADT/StringExtras.h"
-
+#include "llvm/Support/raw_ostream.h"
using namespace clang;
bool QualType::isConstant(ASTContext &Ctx) const {
@@ -549,13 +549,12 @@
}
const ClassTemplateSpecializationType *
-Type::getClassTemplateSpecializationType() const {
+Type::getAsClassTemplateSpecializationType() const {
// There is no sugar for class template specialization types, so
// just return the canonical type pointer if it is the right class.
return dyn_cast<ClassTemplateSpecializationType>(CanonicalType);
}
-
bool Type::isIntegerType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() >= BuiltinType::Bool &&
@@ -1438,19 +1437,9 @@
void QualifiedNameType::getAsStringInternal(std::string &InnerString) const {
std::string MyString;
- for (iterator Comp = begin(), CompEnd = end(); Comp != CompEnd; ++Comp) {
- if (Type *T = Comp->getAsType()) {
- std::string TypeStr;
- if (const TagType *TagT = dyn_cast<TagType>(T))
- TagT->getAsStringInternal(TypeStr, true);
- else
- T->getAsStringInternal(TypeStr);
-
- MyString += TypeStr;
- } else if (NamedDecl *NamedDC
- = dyn_cast_or_null<NamedDecl>(Comp->getAsDeclContext()))
- MyString += NamedDC->getNameAsString();
- MyString += "::";
+ {
+ llvm::raw_string_ostream OS(MyString);
+ NestedNameSpecifier::Print(OS, begin(), end());
}
std::string TypeStr;