Merged Elaborated and QualifiedName types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103517 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp
index 915d7af..0478d4e 100644
--- a/lib/AST/TypePrinter.cpp
+++ b/lib/AST/TypePrinter.cpp
@@ -497,16 +497,6 @@
PrintTag(T->getDecl(), S);
}
-void TypePrinter::PrintElaborated(const ElaboratedType *T, std::string &S) {
- Print(T->getUnderlyingType(), S);
-
- // We don't actually make these in C, but the language options
- // sometimes lie to us -- for example, if someone calls
- // QualType::getAsString(). Just suppress the redundant tag if so.
- if (Policy.LangOpts.CPlusPlus)
- S = std::string(T->getNameForTagKind(T->getTagKind())) + ' ' + S;
-}
-
void TypePrinter::PrintTemplateTypeParm(const TemplateTypeParmType *T,
std::string &S) {
if (!S.empty()) // Prefix the basic type, e.g. 'parmname X'.
@@ -549,13 +539,17 @@
PrintTemplateSpecialization(T->getInjectedTST(), S);
}
-void TypePrinter::PrintQualifiedName(const QualifiedNameType *T,
- std::string &S) {
+void TypePrinter::PrintElaborated(const ElaboratedType *T, std::string &S) {
std::string MyString;
{
llvm::raw_string_ostream OS(MyString);
- T->getQualifier()->print(OS, Policy);
+ OS << TypeWithKeyword::getKeywordName(T->getKeyword());
+ if (T->getKeyword() != ETK_None)
+ OS << " ";
+ NestedNameSpecifier* Qualifier = T->getQualifier();
+ if (Qualifier)
+ Qualifier->print(OS, Policy);
}
std::string TypeStr;
@@ -575,14 +569,9 @@
{
llvm::raw_string_ostream OS(MyString);
- switch (T->getKeyword()) {
- case ETK_None: break;
- case ETK_Typename: OS << "typename "; break;
- case ETK_Class: OS << "class "; break;
- case ETK_Struct: OS << "struct "; break;
- case ETK_Union: OS << "union "; break;
- case ETK_Enum: OS << "enum "; break;
- }
+ OS << TypeWithKeyword::getKeywordName(T->getKeyword());
+ if (T->getKeyword() != ETK_None)
+ OS << " ";
T->getQualifier()->print(OS, Policy);