diff options
Diffstat (limited to 'lib/AST/DeclPrinter.cpp')
-rw-r--r-- | lib/AST/DeclPrinter.cpp | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index a625865..53949247 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -301,17 +301,15 @@ void DeclPrinter::VisitTypedefDecl(TypedefDecl *D) { } void DeclPrinter::VisitEnumDecl(EnumDecl *D) { - Out << "enum " << D->getNameAsString() << " {\n"; + Out << "enum " << D << " {\n"; VisitDeclContext(D); Indent() << "}"; } void DeclPrinter::VisitRecordDecl(RecordDecl *D) { Out << D->getKindName(); - if (D->getIdentifier()) { - Out << " "; - Out << D->getNameAsString(); - } + if (D->getIdentifier()) + Out << ' ' << D; if (D->isDefinition()) { Out << " {\n"; @@ -321,7 +319,7 @@ void DeclPrinter::VisitRecordDecl(RecordDecl *D) { } void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { - Out << D->getNameAsString(); + Out << D; if (Expr *Init = D->getInitExpr()) { Out << " = "; Init->printPretty(Out, Context, 0, Policy, Indentation); @@ -406,7 +404,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { Out << ", "; if (BMInitializer->isMemberInitializer()) { FieldDecl *FD = BMInitializer->getMember(); - Out << FD->getNameAsString(); + Out << FD; } else { Out << QualType(BMInitializer->getBaseClass(), 0).getAsString(); } @@ -537,7 +535,7 @@ void DeclPrinter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) { // C++ declarations //---------------------------------------------------------------------------- void DeclPrinter::VisitNamespaceDecl(NamespaceDecl *D) { - Out << "namespace " << D->getNameAsString() << " {\n"; + Out << "namespace " << D << " {\n"; VisitDeclContext(D); Indent() << "}"; } @@ -546,22 +544,20 @@ void DeclPrinter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { Out << "using namespace "; if (D->getQualifier()) D->getQualifier()->print(Out, Policy); - Out << D->getNominatedNamespaceAsWritten()->getNameAsString(); + Out << D->getNominatedNamespaceAsWritten(); } void DeclPrinter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { - Out << "namespace " << D->getNameAsString() << " = "; + Out << "namespace " << D << " = "; if (D->getQualifier()) D->getQualifier()->print(Out, Policy); - Out << D->getAliasedNamespace()->getNameAsString(); + Out << D->getAliasedNamespace(); } void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) { Out << D->getKindName(); - if (D->getIdentifier()) { - Out << " "; - Out << D->getNameAsString(); - } + if (D->getIdentifier()) + Out << ' ' << D; if (D->isDefinition()) { // Print the base classes @@ -669,7 +665,7 @@ void DeclPrinter::VisitObjCClassDecl(ObjCClassDecl *D) { for (ObjCClassDecl::iterator I = D->begin(), E = D->end(); I != E; ++I) { if (I != D->begin()) Out << ", "; - Out << I->getInterface()->getNameAsString(); + Out << I->getInterface(); } } @@ -688,8 +684,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) { // FIXME: selector is missing here! pos = name.find_first_of(":", lastPos); Out << " " << name.substr(lastPos, pos - lastPos); - Out << ":(" << (*PI)->getType().getAsString(Policy) << ")" - << (*PI)->getNameAsString(); + Out << ":(" << (*PI)->getType().getAsString(Policy) << ')' << *PI; lastPos = pos + 1; } @@ -711,7 +706,7 @@ void DeclPrinter::VisitObjCImplementationDecl(ObjCImplementationDecl *OID) { ObjCInterfaceDecl *SID = OID->getSuperClass(); if (SID) - Out << "@implementation " << I << " : " << SID->getNameAsString(); + Out << "@implementation " << I << " : " << SID; else Out << "@implementation " << I; Out << "\n"; @@ -724,7 +719,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) { ObjCInterfaceDecl *SID = OID->getSuperClass(); if (SID) - Out << "@interface " << I << " : " << SID->getNameAsString(); + Out << "@interface " << I << " : " << SID; else Out << "@interface " << I; @@ -733,7 +728,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) { if (!Protocols.empty()) { for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(), E = Protocols.end(); I != E; ++I) - Out << (I == Protocols.begin() ? '<' : ',') << (*I)->getNameAsString(); + Out << (I == Protocols.begin() ? '<' : ',') << *I; } if (!Protocols.empty()) @@ -744,8 +739,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) { Indentation += Policy.Indentation; for (ObjCInterfaceDecl::ivar_iterator I = OID->ivar_begin(), E = OID->ivar_end(); I != E; ++I) { - Indent() << (*I)->getType().getAsString(Policy) - << ' ' << (*I)->getNameAsString() << ";\n"; + Indent() << (*I)->getType().getAsString(Policy) << ' ' << *I << ";\n"; } Indentation -= Policy.Indentation; Out << "}\n"; @@ -762,20 +756,18 @@ void DeclPrinter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) { E = D->protocol_end(); I != E; ++I) { if (I != D->protocol_begin()) Out << ", "; - Out << (*I)->getNameAsString(); + Out << *I; } } void DeclPrinter::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) { - Out << "@protocol " << PID->getNameAsString() << '\n'; + Out << "@protocol " << PID << '\n'; VisitDeclContext(PID, false); Out << "@end"; } void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) { - Out << "@implementation " - << PID->getClassInterface()->getNameAsString() - << '(' << PID->getNameAsString() << ")\n"; + Out << "@implementation " << PID->getClassInterface() << '(' << PID << ")\n"; VisitDeclContext(PID, false); Out << "@end"; @@ -783,9 +775,7 @@ void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) { } void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) { - Out << "@interface " - << PID->getClassInterface()->getNameAsString() - << '(' << PID->getNameAsString() << ")\n"; + Out << "@interface " << PID->getClassInterface() << '(' << PID << ")\n"; VisitDeclContext(PID, false); Out << "@end"; @@ -793,8 +783,8 @@ void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) { } void DeclPrinter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *AID) { - Out << "@compatibility_alias " << AID->getNameAsString() - << ' ' << AID->getClassInterface()->getNameAsString() << ";\n"; + Out << "@compatibility_alias " << AID + << ' ' << AID->getClassInterface() << ";\n"; } /// PrintObjCPropertyDecl - print a property declaration. @@ -854,8 +844,7 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) { } Out << " )"; } - Out << ' ' << PDecl->getType().getAsString(Policy) - << ' ' << PDecl->getNameAsString(); + Out << ' ' << PDecl->getType().getAsString(Policy) << ' ' << PDecl; } void DeclPrinter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PID) { @@ -863,28 +852,28 @@ void DeclPrinter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PID) { Out << "@synthesize "; else Out << "@dynamic "; - Out << PID->getPropertyDecl()->getNameAsString(); + Out << PID->getPropertyDecl(); if (PID->getPropertyIvarDecl()) - Out << "=" << PID->getPropertyIvarDecl()->getNameAsString(); + Out << '=' << PID->getPropertyIvarDecl(); } void DeclPrinter::VisitUsingDecl(UsingDecl *D) { Out << "using "; D->getTargetNestedNameDecl()->print(Out, Policy); - Out << D->getNameAsString(); + Out << D; } void DeclPrinter::VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D) { Out << "using typename "; D->getTargetNestedNameSpecifier()->print(Out, Policy); - Out << D->getDeclName().getAsString(); + Out << D->getDeclName(); } void DeclPrinter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { Out << "using "; D->getTargetNestedNameSpecifier()->print(Out, Policy); - Out << D->getDeclName().getAsString(); + Out << D->getDeclName(); } void DeclPrinter::VisitUsingShadowDecl(UsingShadowDecl *D) { |