Add raw_ostream operators to NamedDecl for convenience. Switch over all users of getNameAsString on a stream.

The next step is to print the name directly into the stream, avoiding a temporary std::string copy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101632 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2010-04-17 09:33:03 +00:00
Родитель 7a22f02a02
Коммит 900fc6388e
29 изменённых файлов: 134 добавлений и 131 удалений

Просмотреть файл

@ -217,6 +217,8 @@ public:
static bool classofKind(Kind K) { return K >= NamedFirst && K <= NamedLast; } static bool classofKind(Kind K) { return K >= NamedFirst && K <= NamedLast; }
}; };
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const NamedDecl *ND);
/// NamespaceDecl - Represent a C++ namespace. /// NamespaceDecl - Represent a C++ namespace.
class NamespaceDecl : public NamedDecl, public DeclContext { class NamespaceDecl : public NamedDecl, public DeclContext {
SourceLocation LBracLoc, RBracLoc; SourceLocation LBracLoc, RBracLoc;

Просмотреть файл

@ -1132,6 +1132,9 @@ public:
static bool classofKind(Kind K) { return K == ObjCCategoryImpl;} static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
}; };
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const ObjCCategoryImplDecl *CID);
/// ObjCImplementationDecl - Represents a class definition - this is where /// ObjCImplementationDecl - Represents a class definition - this is where
/// method definitions are specified. For example: /// method definitions are specified. For example:
/// ///
@ -1217,6 +1220,9 @@ public:
static bool classofKind(Kind K) { return K == ObjCImplementation; } static bool classofKind(Kind K) { return K == ObjCImplementation; }
}; };
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const ObjCImplementationDecl *ID);
/// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is /// ObjCCompatibleAliasDecl - Represents alias of a class. This alias is
/// declared as @compatibility_alias alias class. /// declared as @compatibility_alias alias class.
class ObjCCompatibleAliasDecl : public NamedDecl { class ObjCCompatibleAliasDecl : public NamedDecl {

Просмотреть файл

@ -512,6 +512,12 @@ bool NamedDecl::isCXXInstanceMember() const {
return false; return false;
} }
llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
const NamedDecl *ND) {
OS << ND->getNameAsString();
return OS;
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// DeclaratorDecl Implementation // DeclaratorDecl Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

Просмотреть файл

@ -843,6 +843,12 @@ FindPropertyImplDecl(IdentifierInfo *Id) const {
return 0; return 0;
} }
llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
const ObjCCategoryImplDecl *CID) {
OS << CID->getName();
return OS;
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// ObjCImplementationDecl // ObjCImplementationDecl
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -855,6 +861,12 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl); return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
} }
llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
const ObjCImplementationDecl *ID) {
OS << ID->getName();
return OS;
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// ObjCCompatibleAliasDecl // ObjCCompatibleAliasDecl
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

Просмотреть файл

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

Просмотреть файл

@ -290,14 +290,12 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
// For incorrect code, there might not be an ObjCInterfaceDecl. Do // For incorrect code, there might not be an ObjCInterfaceDecl. Do
// a null check to avoid a crash. // a null check to avoid a crash.
if (const ObjCInterfaceDecl *ID = MD->getClassInterface()) if (const ObjCInterfaceDecl *ID = MD->getClassInterface())
Out << ID->getNameAsString(); Out << ID;
if (const ObjCCategoryImplDecl *CID = if (const ObjCCategoryImplDecl *CID =
dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext())) { dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
Out << '('; Out << '(' << CID << ')';
Out << CID->getNameAsString();
Out << ')';
}
Out << ' '; Out << ' ';
Out << MD->getSelector().getAsString(); Out << MD->getSelector().getAsString();
Out << ']'; Out << ']';

Просмотреть файл

@ -924,7 +924,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
// Vtable pointer. // Vtable pointer.
if (RD->isDynamicClass() && !PrimaryBase) { if (RD->isDynamicClass() && !PrimaryBase) {
PrintOffset(OS, Offset, IndentLevel); PrintOffset(OS, Offset, IndentLevel);
OS << '(' << RD->getNameAsString() << " vtable pointer)\n"; OS << '(' << RD << " vtable pointer)\n";
} }
// Dump (non-virtual) bases // Dump (non-virtual) bases
for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
@ -961,8 +961,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
} }
PrintOffset(OS, FieldOffset, IndentLevel); PrintOffset(OS, FieldOffset, IndentLevel);
OS << Field->getType().getAsString() << ' '; OS << Field->getType().getAsString() << ' ' << Field << '\n';
OS << Field->getNameAsString() << '\n';
} }
if (!IncludeVirtualBases) if (!IncludeVirtualBases)

Просмотреть файл

@ -219,7 +219,7 @@ void StmtDumper::DumpDeclarator(Decl *D) {
// nodes are where they need to be. // nodes are where they need to be.
if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) { if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
OS << "\"typedef " << localType->getUnderlyingType().getAsString() OS << "\"typedef " << localType->getUnderlyingType().getAsString()
<< " " << localType->getNameAsString() << "\""; << ' ' << localType << '"';
} else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) { } else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
OS << "\""; OS << "\"";
// Emit storage class for vardecls. // Emit storage class for vardecls.
@ -328,15 +328,14 @@ void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
case Decl::ObjCClass: OS << "ObjCClass"; break; case Decl::ObjCClass: OS << "ObjCClass"; break;
} }
OS << "='" << Node->getDecl()->getNameAsString() OS << "='" << Node->getDecl() << "' " << (void*)Node->getDecl();
<< "' " << (void*)Node->getDecl();
} }
void StmtDumper::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) { void StmtDumper::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
OS << " ("; OS << " (";
if (!Node->requiresADL()) OS << "no "; if (!Node->requiresADL()) OS << "no ";
OS << "ADL) = '" << Node->getName().getAsString() << "'"; OS << "ADL) = '" << Node->getName() << '\'';
UnresolvedLookupExpr::decls_iterator UnresolvedLookupExpr::decls_iterator
I = Node->decls_begin(), E = Node->decls_end(); I = Node->decls_begin(), E = Node->decls_end();
@ -349,7 +348,7 @@ void StmtDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
OS << " " << Node->getDecl()->getDeclKindName() OS << " " << Node->getDecl()->getDeclKindName()
<< "Decl='" << Node->getDecl()->getNameAsString() << "Decl='" << Node->getDecl()
<< "' " << (void*)Node->getDecl(); << "' " << (void*)Node->getDecl();
if (Node->isFreeIvar()) if (Node->isFreeIvar())
OS << " isFreeIvar"; OS << " isFreeIvar";
@ -408,7 +407,7 @@ void StmtDumper::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
void StmtDumper::VisitMemberExpr(MemberExpr *Node) { void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
OS << " " << (Node->isArrow() ? "->" : ".") OS << " " << (Node->isArrow() ? "->" : ".")
<< Node->getMemberDecl()->getNameAsString() << " " << Node->getMemberDecl() << ' '
<< (void*)Node->getMemberDecl(); << (void*)Node->getMemberDecl();
} }
void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) { void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
@ -525,14 +524,13 @@ void StmtDumper::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) { void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
OS << " " << Node->getProtocol()->getNameAsString(); OS << ' ' << Node->getProtocol();
} }
void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) { void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
DumpExpr(Node); DumpExpr(Node);
OS << " Kind=PropertyRef Property=\"" OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"';
<< Node->getProperty()->getNameAsString() << "\"";
} }
void StmtDumper::VisitObjCImplicitSetterGetterRefExpr( void StmtDumper::VisitObjCImplicitSetterGetterRefExpr(

Просмотреть файл

@ -474,7 +474,7 @@ void StmtPrinter::VisitExpr(Expr *Node) {
void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) { void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
if (NestedNameSpecifier *Qualifier = Node->getQualifier()) if (NestedNameSpecifier *Qualifier = Node->getQualifier())
Qualifier->print(OS, Policy); Qualifier->print(OS, Policy);
OS << Node->getDecl()->getNameAsString(); OS << Node->getDecl();
if (Node->hasExplicitTemplateArgumentList()) if (Node->hasExplicitTemplateArgumentList())
OS << TemplateSpecializationType::PrintTemplateArgumentList( OS << TemplateSpecializationType::PrintTemplateArgumentList(
Node->getTemplateArgs(), Node->getTemplateArgs(),
@ -509,7 +509,7 @@ void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
PrintExpr(Node->getBase()); PrintExpr(Node->getBase());
OS << (Node->isArrow() ? "->" : "."); OS << (Node->isArrow() ? "->" : ".");
} }
OS << Node->getDecl()->getNameAsString(); OS << Node->getDecl();
} }
void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) { void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
@ -527,7 +527,7 @@ void StmtPrinter::VisitObjCImplicitSetterGetterRefExpr(
OS << "."; OS << ".";
} }
if (Node->getGetterMethod()) if (Node->getGetterMethod())
OS << Node->getGetterMethod()->getNameAsString(); OS << Node->getGetterMethod();
} }
@ -695,7 +695,7 @@ bool StmtPrinter::PrintOffsetOfDesignator(Expr *E) {
} else { } else {
MemberExpr *ME = cast<MemberExpr>(E); MemberExpr *ME = cast<MemberExpr>(E);
bool IsFirst = PrintOffsetOfDesignator(ME->getBase()); bool IsFirst = PrintOffsetOfDesignator(ME->getBase());
OS << (IsFirst ? "" : ".") << ME->getMemberDecl()->getNameAsString(); OS << (IsFirst ? "" : ".") << ME->getMemberDecl();
return false; return false;
} }
} }
@ -746,7 +746,7 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
if (NestedNameSpecifier *Qualifier = Node->getQualifier()) if (NestedNameSpecifier *Qualifier = Node->getQualifier())
Qualifier->print(OS, Policy); Qualifier->print(OS, Policy);
OS << Node->getMemberDecl()->getNameAsString(); OS << Node->getMemberDecl();
if (Node->hasExplicitTemplateArgumentList()) if (Node->hasExplicitTemplateArgumentList())
OS << TemplateSpecializationType::PrintTemplateArgumentList( OS << TemplateSpecializationType::PrintTemplateArgumentList(
@ -1242,7 +1242,7 @@ void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
} }
void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) { void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
OS << "@protocol(" << Node->getProtocol()->getNameAsString() << ')'; OS << "@protocol(" << Node->getProtocol() << ')';
} }
void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) { void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
@ -1304,7 +1304,7 @@ void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
} }
void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) { void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) {
OS << Node->getDecl()->getNameAsString(); OS << Node->getDecl();
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Stmt method implementations // Stmt method implementations

Просмотреть файл

@ -47,13 +47,13 @@ void
TemplateName::print(llvm::raw_ostream &OS, const PrintingPolicy &Policy, TemplateName::print(llvm::raw_ostream &OS, const PrintingPolicy &Policy,
bool SuppressNNS) const { bool SuppressNNS) const {
if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>()) if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>())
OS << Template->getNameAsString(); OS << Template;
else if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) { else if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) {
if (!SuppressNNS) if (!SuppressNNS)
QTN->getQualifier()->print(OS, Policy); QTN->getQualifier()->print(OS, Policy);
if (QTN->hasTemplateKeyword()) if (QTN->hasTemplateKeyword())
OS << "template "; OS << "template ";
OS << QTN->getDecl()->getNameAsString(); OS << QTN->getDecl();
} else if (DependentTemplateName *DTN = getAsDependentTemplateName()) { } else if (DependentTemplateName *DTN = getAsDependentTemplateName()) {
if (!SuppressNNS && DTN->getQualifier()) if (!SuppressNNS && DTN->getQualifier())
DTN->getQualifier()->print(OS, Policy); DTN->getQualifier()->print(OS, Policy);

Просмотреть файл

@ -607,7 +607,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
if (D) { if (D) {
GetRawInt = false; GetRawInt = false;
os << D->getNameAsString(); os << D;
} }
} }

Просмотреть файл

@ -144,7 +144,7 @@ public:
if (const DeclStmt *DS = PS->getStmtAs<DeclStmt>()) { if (const DeclStmt *DS = PS->getStmtAs<DeclStmt>()) {
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) { if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
os << "Variable '" << VR->getDecl()->getNameAsString() << "' "; os << "Variable '" << VR->getDecl() << "' ";
} }
else else
return NULL; return NULL;
@ -206,7 +206,7 @@ public:
return NULL; return NULL;
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) { if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
os << '\'' << VR->getDecl()->getNameAsString() << '\''; os << '\'' << VR->getDecl() << '\'';
} }
else else
return NULL; return NULL;

Просмотреть файл

@ -2081,7 +2081,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
// Get the name of the callee (if it is available). // Get the name of the callee (if it is available).
SVal X = CurrSt->getSValAsScalarOrLoc(CE->getCallee()); SVal X = CurrSt->getSValAsScalarOrLoc(CE->getCallee());
if (const FunctionDecl* FD = X.getAsFunctionDecl()) if (const FunctionDecl* FD = X.getAsFunctionDecl())
os << "Call to function '" << FD->getNameAsString() <<'\''; os << "Call to function '" << FD << '\'';
else else
os << "function call"; os << "function call";
} }

Просмотреть файл

@ -154,8 +154,7 @@ bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
os << "Passed-by-value struct argument contains uninitialized data"; os << "Passed-by-value struct argument contains uninitialized data";
if (F.FieldChain.size() == 1) if (F.FieldChain.size() == 1)
os << " (e.g., field: '" << F.FieldChain[0]->getNameAsString() os << " (e.g., field: '" << F.FieldChain[0] << "')";
<< "')";
else { else {
os << " (e.g., via the field chain: '"; os << " (e.g., via the field chain: '";
bool first = true; bool first = true;
@ -165,7 +164,7 @@ bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
first = false; first = false;
else else
os << '.'; os << '.';
os << (*DI)->getNameAsString(); os << *DI;
} }
os << "')"; os << "')";
} }

Просмотреть файл

@ -166,8 +166,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
std::string buf; std::string buf;
llvm::raw_string_ostream os(buf); llvm::raw_string_ostream os(buf);
os << "Objective-C class '" << D->getNameAsString() os << "Objective-C class '" << D << "' lacks a 'dealloc' instance method";
<< "' lacks a 'dealloc' instance method";
BR.EmitBasicReport(name, os.str(), D->getLocStart()); BR.EmitBasicReport(name, os.str(), D->getLocStart());
return; return;
@ -182,8 +181,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
std::string buf; std::string buf;
llvm::raw_string_ostream os(buf); llvm::raw_string_ostream os(buf);
os << "The 'dealloc' instance method in Objective-C class '" os << "The 'dealloc' instance method in Objective-C class '" << D
<< D->getNameAsString()
<< "' does not send a 'dealloc' message to its super class" << "' does not send a 'dealloc' message to its super class"
" (missing [super dealloc])"; " (missing [super dealloc])";
@ -238,7 +236,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
? "missing ivar release (leak)" ? "missing ivar release (leak)"
: "missing ivar release (Hybrid MM, non-GC)"; : "missing ivar release (Hybrid MM, non-GC)";
os << "The '" << ID->getNameAsString() os << "The '" << ID
<< "' instance variable was retained by a synthesized property but " << "' instance variable was retained by a synthesized property but "
"wasn't released in 'dealloc'"; "wasn't released in 'dealloc'";
} else { } else {
@ -246,7 +244,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
? "extra ivar release (use-after-release)" ? "extra ivar release (use-after-release)"
: "extra ivar release (Hybrid MM, non-GC)"; : "extra ivar release (Hybrid MM, non-GC)";
os << "The '" << ID->getNameAsString() os << "The '" << ID
<< "' instance variable was not retained by a synthesized property " << "' instance variable was not retained by a synthesized property "
"but was released in 'dealloc'"; "but was released in 'dealloc'";
} }

Просмотреть файл

@ -49,16 +49,16 @@ static void CompareReturnTypes(const ObjCMethodDecl *MethDerived,
llvm::raw_string_ostream os(sbuf); llvm::raw_string_ostream os(sbuf);
os << "The Objective-C class '" os << "The Objective-C class '"
<< MethDerived->getClassInterface()->getNameAsString() << MethDerived->getClassInterface()
<< "', which is derived from class '" << "', which is derived from class '"
<< MethAncestor->getClassInterface()->getNameAsString() << MethAncestor->getClassInterface()
<< "', defines the instance method '" << "', defines the instance method '"
<< MethDerived->getSelector().getAsString() << MethDerived->getSelector().getAsString()
<< "' whose return type is '" << "' whose return type is '"
<< ResDerived.getAsString() << ResDerived.getAsString()
<< "'. A method with the same name (same selector) is also defined in " << "'. A method with the same name (same selector) is also defined in "
"class '" "class '"
<< MethAncestor->getClassInterface()->getNameAsString() << MethAncestor->getClassInterface()
<< "' and has a return type of '" << "' and has a return type of '"
<< ResAncestor.getAsString() << ResAncestor.getAsString()
<< "'. These two types are incompatible, and may result in undefined " << "'. These two types are incompatible, and may result in undefined "

Просмотреть файл

@ -387,11 +387,11 @@ void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) {
// Issue a warning. // Issue a warning.
llvm::SmallString<256> buf1; llvm::SmallString<256> buf1;
llvm::raw_svector_ostream os1(buf1); llvm::raw_svector_ostream os1(buf1);
os1 << "'" << FD->getNameAsString() << "' is a poor random number generator"; os1 << '\'' << FD << "' is a poor random number generator";
llvm::SmallString<256> buf2; llvm::SmallString<256> buf2;
llvm::raw_svector_ostream os2(buf2); llvm::raw_svector_ostream os2(buf2);
os2 << "Function '" << FD->getNameAsString() os2 << "Function '" << FD
<< "' is obsolete because it implements a poor random number generator." << "' is obsolete because it implements a poor random number generator."
<< " Use 'arc4random' instead"; << " Use 'arc4random' instead";
@ -472,14 +472,12 @@ void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) {
// Issue a warning. // Issue a warning.
llvm::SmallString<256> buf1; llvm::SmallString<256> buf1;
llvm::raw_svector_ostream os1(buf1); llvm::raw_svector_ostream os1(buf1);
os1 << "Return value is not checked in call to '" << FD->getNameAsString() os1 << "Return value is not checked in call to '" << FD << '\'';
<< "'";
llvm::SmallString<256> buf2; llvm::SmallString<256> buf2;
llvm::raw_svector_ostream os2(buf2); llvm::raw_svector_ostream os2(buf2);
os2 << "The return value from the call to '" << FD->getNameAsString() os2 << "The return value from the call to '" << FD
<< "' is not checked. If an error occurs in '" << "' is not checked. If an error occurs in '" << FD
<< FD->getNameAsString()
<< "', the following code may execute with unexpected privileges"; << "', the following code may execute with unexpected privileges";
SourceRange R = CE->getCallee()->getSourceRange(); SourceRange R = CE->getCallee()->getSourceRange();

Просмотреть файл

@ -365,11 +365,11 @@ void ElementRegion::dumpToStream(llvm::raw_ostream& os) const {
} }
void FieldRegion::dumpToStream(llvm::raw_ostream& os) const { void FieldRegion::dumpToStream(llvm::raw_ostream& os) const {
os << superRegion << "->" << getDecl()->getNameAsString(); os << superRegion << "->" << getDecl();
} }
void ObjCIvarRegion::dumpToStream(llvm::raw_ostream& os) const { void ObjCIvarRegion::dumpToStream(llvm::raw_ostream& os) const {
os << "ivar{" << superRegion << ',' << getDecl()->getNameAsString() << '}'; os << "ivar{" << superRegion << ',' << getDecl() << '}';
} }
void StringRegion::dumpToStream(llvm::raw_ostream& os) const { void StringRegion::dumpToStream(llvm::raw_ostream& os) const {
@ -381,7 +381,7 @@ void SymbolicRegion::dumpToStream(llvm::raw_ostream& os) const {
} }
void VarRegion::dumpToStream(llvm::raw_ostream& os) const { void VarRegion::dumpToStream(llvm::raw_ostream& os) const {
os << cast<VarDecl>(D)->getNameAsString(); os << cast<VarDecl>(D);
} }
void RegionRawOffset::dump() const { void RegionRawOffset::dump() const {

Просмотреть файл

@ -226,7 +226,7 @@ void NSErrorChecker::CheckParamDeref(const VarDecl *Param,
else else
os << "documented in CoreFoundation/CFError.h the parameter '"; os << "documented in CoreFoundation/CFError.h the parameter '";
os << Param->getNameAsString() << "' may be null."; os << Param << "' may be null.";
BugReport *report = new BugReport(*this, os.str(), *I); BugReport *report = new BugReport(*this, os.str(), *I);
// FIXME: Notable symbols are now part of the report. We should // FIXME: Notable symbols are now part of the report. We should

Просмотреть файл

@ -150,8 +150,7 @@ void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
if (I->second == Unused) { if (I->second == Unused) {
std::string sbuf; std::string sbuf;
llvm::raw_string_ostream os(sbuf); llvm::raw_string_ostream os(sbuf);
os << "Instance variable '" << I->first->getNameAsString() os << "Instance variable '" << I->first << "' in class '" << ID
<< "' in class '" << ID->getNameAsString()
<< "' is never used by the methods in its @implementation " << "' is never used by the methods in its @implementation "
"(although it may be used by category methods)."; "(although it may be used by category methods).";

Просмотреть файл

@ -3565,7 +3565,7 @@ void CGObjCCommonMac::GetNameForMethod(const ObjCMethodDecl *D,
<< '[' << CD->getName(); << '[' << CD->getName();
if (const ObjCCategoryImplDecl *CID = if (const ObjCCategoryImplDecl *CID =
dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext())) dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext()))
OS << '(' << CID->getNameAsString() << ')'; OS << '(' << CID << ')';
OS << ' ' << D->getSelector().getAsString() << ']'; OS << ' ' << D->getSelector().getAsString() << ']';
} }

Просмотреть файл

@ -896,7 +896,7 @@ void CXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
assert (CD && "Missing container decl in GetNameForMethod"); assert (CD && "Missing container decl in GetNameForMethod");
OS << (MD->isInstanceMethod() ? '-' : '+') << '[' << CD->getName(); OS << (MD->isInstanceMethod() ? '-' : '+') << '[' << CD->getName();
if (const ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(CD)) if (const ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(CD))
OS << '(' << CID->getNameAsString() << ')'; OS << '(' << CID << ')';
OS << ' ' << MD->getSelector().getAsString() << ']'; OS << ' ' << MD->getSelector().getAsString() << ']';
Out << OS.str().size() << OS.str(); Out << OS.str().size() << OS.str();

Просмотреть файл

@ -164,7 +164,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
case Decl::Namespace: { case Decl::Namespace: {
Out << "[namespace] "; Out << "[namespace] ";
const NamespaceDecl* ND = cast<NamespaceDecl>(DC); const NamespaceDecl* ND = cast<NamespaceDecl>(DC);
Out << ND->getNameAsString(); Out << ND;
break; break;
} }
case Decl::Enum: { case Decl::Enum: {
@ -173,7 +173,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "[enum] "; Out << "[enum] ";
else else
Out << "<enum> "; Out << "<enum> ";
Out << ED->getNameAsString(); Out << ED;
break; break;
} }
case Decl::Record: { case Decl::Record: {
@ -182,7 +182,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "[struct] "; Out << "[struct] ";
else else
Out << "<struct> "; Out << "<struct> ";
Out << RD->getNameAsString(); Out << RD;
break; break;
} }
case Decl::CXXRecord: { case Decl::CXXRecord: {
@ -191,7 +191,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "[class] "; Out << "[class] ";
else else
Out << "<class> "; Out << "<class> ";
Out << RD->getNameAsString() << " " << DC; Out << RD << ' ' << DC;
break; break;
} }
case Decl::ObjCMethod: case Decl::ObjCMethod:
@ -224,7 +224,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "[function] "; Out << "[function] ";
else else
Out << "<function> "; Out << "<function> ";
Out << FD->getNameAsString(); Out << FD;
// Print the parameters. // Print the parameters.
Out << "("; Out << "(";
bool PrintComma = false; bool PrintComma = false;
@ -234,7 +234,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << ", "; Out << ", ";
else else
PrintComma = true; PrintComma = true;
Out << (*I)->getNameAsString(); Out << *I;
} }
Out << ")"; Out << ")";
break; break;
@ -247,7 +247,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "(c++ method) "; Out << "(c++ method) ";
else else
Out << "<c++ method> "; Out << "<c++ method> ";
Out << D->getNameAsString(); Out << D;
// Print the parameters. // Print the parameters.
Out << "("; Out << "(";
bool PrintComma = false; bool PrintComma = false;
@ -257,7 +257,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << ", "; Out << ", ";
else else
PrintComma = true; PrintComma = true;
Out << (*I)->getNameAsString(); Out << *I;
} }
Out << ")"; Out << ")";
@ -277,7 +277,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "(c++ ctor) "; Out << "(c++ ctor) ";
else else
Out << "<c++ ctor> "; Out << "<c++ ctor> ";
Out << D->getNameAsString(); Out << D;
// Print the parameters. // Print the parameters.
Out << "("; Out << "(";
bool PrintComma = false; bool PrintComma = false;
@ -287,7 +287,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << ", "; Out << ", ";
else else
PrintComma = true; PrintComma = true;
Out << (*I)->getNameAsString(); Out << *I;
} }
Out << ")"; Out << ")";
@ -306,7 +306,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "(c++ dtor) "; Out << "(c++ dtor) ";
else else
Out << "<c++ dtor> "; Out << "<c++ dtor> ";
Out << D->getNameAsString(); Out << D;
// Check the semantic DC. // Check the semantic DC.
const DeclContext* SemaDC = D->getDeclContext(); const DeclContext* SemaDC = D->getDeclContext();
const DeclContext* LexicalDC = D->getLexicalDeclContext(); const DeclContext* LexicalDC = D->getLexicalDeclContext();
@ -322,7 +322,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
Out << "(c++ conversion) "; Out << "(c++ conversion) ";
else else
Out << "<c++ conversion> "; Out << "<c++ conversion> ";
Out << D->getNameAsString(); Out << D;
// Check the semantic DC. // Check the semantic DC.
const DeclContext* SemaDC = D->getDeclContext(); const DeclContext* SemaDC = D->getDeclContext();
const DeclContext* LexicalDC = D->getLexicalDeclContext(); const DeclContext* LexicalDC = D->getLexicalDeclContext();
@ -369,42 +369,42 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
} }
case Decl::Field: { case Decl::Field: {
FieldDecl* FD = cast<FieldDecl>(*I); FieldDecl* FD = cast<FieldDecl>(*I);
Out << "<field> " << FD->getNameAsString() << "\n"; Out << "<field> " << FD << '\n';
break; break;
} }
case Decl::Typedef: { case Decl::Typedef: {
TypedefDecl* TD = cast<TypedefDecl>(*I); TypedefDecl* TD = cast<TypedefDecl>(*I);
Out << "<typedef> " << TD->getNameAsString() << "\n"; Out << "<typedef> " << TD << '\n';
break; break;
} }
case Decl::EnumConstant: { case Decl::EnumConstant: {
EnumConstantDecl* ECD = cast<EnumConstantDecl>(*I); EnumConstantDecl* ECD = cast<EnumConstantDecl>(*I);
Out << "<enum constant> " << ECD->getNameAsString() << "\n"; Out << "<enum constant> " << ECD << '\n';
break; break;
} }
case Decl::Var: { case Decl::Var: {
VarDecl* VD = cast<VarDecl>(*I); VarDecl* VD = cast<VarDecl>(*I);
Out << "<var> " << VD->getNameAsString() << "\n"; Out << "<var> " << VD << '\n';
break; break;
} }
case Decl::ImplicitParam: { case Decl::ImplicitParam: {
ImplicitParamDecl* IPD = cast<ImplicitParamDecl>(*I); ImplicitParamDecl* IPD = cast<ImplicitParamDecl>(*I);
Out << "<implicit parameter> " << IPD->getNameAsString() << "\n"; Out << "<implicit parameter> " << IPD << '\n';
break; break;
} }
case Decl::ParmVar: { case Decl::ParmVar: {
ParmVarDecl* PVD = cast<ParmVarDecl>(*I); ParmVarDecl* PVD = cast<ParmVarDecl>(*I);
Out << "<parameter> " << PVD->getNameAsString() << "\n"; Out << "<parameter> " << PVD << '\n';
break; break;
} }
case Decl::ObjCProperty: { case Decl::ObjCProperty: {
ObjCPropertyDecl* OPD = cast<ObjCPropertyDecl>(*I); ObjCPropertyDecl* OPD = cast<ObjCPropertyDecl>(*I);
Out << "<objc property> " << OPD->getNameAsString() << "\n"; Out << "<objc property> " << OPD << '\n';
break; break;
} }
case Decl::FunctionTemplate: { case Decl::FunctionTemplate: {
FunctionTemplateDecl* FTD = cast<FunctionTemplateDecl>(*I); FunctionTemplateDecl* FTD = cast<FunctionTemplateDecl>(*I);
Out << "<function template> " << FTD->getNameAsString() << "\n"; Out << "<function template> " << FTD << '\n';
break; break;
} }
case Decl::FileScopeAsm: { case Decl::FileScopeAsm: {
@ -417,16 +417,16 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
} }
case Decl::NamespaceAlias: { case Decl::NamespaceAlias: {
NamespaceAliasDecl* NAD = cast<NamespaceAliasDecl>(*I); NamespaceAliasDecl* NAD = cast<NamespaceAliasDecl>(*I);
Out << "<namespace alias> " << NAD->getNameAsString() << "\n"; Out << "<namespace alias> " << NAD << '\n';
break; break;
} }
case Decl::ClassTemplate: { case Decl::ClassTemplate: {
ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(*I); ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(*I);
Out << "<class template> " << CTD->getNameAsString() << '\n'; Out << "<class template> " << CTD << '\n';
break; break;
} }
default: default:
Out << "DeclKind: " << DK << '"' << I->getDeclKindName() << "\"\n"; Out << "DeclKind: " << DK << '"' << *I << "\"\n";
assert(0 && "decl unhandled"); assert(0 && "decl unhandled");
} }
} }

Просмотреть файл

@ -150,7 +150,7 @@ public:
if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) { if (isa<FunctionDecl>(D) || isa<ObjCMethodDecl>(D)) {
const NamedDecl *ND = cast<NamedDecl>(D); const NamedDecl *ND = cast<NamedDecl>(D);
llvm::errs() << ' ' << ND->getNameAsString() << '\n'; llvm::errs() << ' ' << ND << '\n';
} }
else if (isa<BlockDecl>(D)) { else if (isa<BlockDecl>(D)) {
llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:" llvm::errs() << ' ' << "block(line:" << Loc.getLine() << ",col:"

Просмотреть файл

@ -87,7 +87,7 @@ void ASTLocation::print(llvm::raw_ostream &OS) const {
case N_Decl: case N_Decl:
OS << "[Decl: " << AsDecl()->getDeclKindName() << " "; OS << "[Decl: " << AsDecl()->getDeclKindName() << " ";
if (const NamedDecl *ND = dyn_cast<NamedDecl>(AsDecl())) if (const NamedDecl *ND = dyn_cast<NamedDecl>(AsDecl()))
OS << ND->getNameAsString(); OS << ND;
break; break;
case N_Stmt: case N_Stmt:
@ -97,7 +97,7 @@ void ASTLocation::print(llvm::raw_ostream &OS) const {
case N_NamedRef: case N_NamedRef:
OS << "[NamedRef: " << AsNamedRef().ND->getDeclKindName() << " "; OS << "[NamedRef: " << AsNamedRef().ND->getDeclKindName() << " ";
OS << AsNamedRef().ND->getNameAsString(); OS << AsNamedRef().ND;
break; break;
case N_Type: { case N_Type: {

Просмотреть файл

@ -425,7 +425,7 @@ PrintingCodeCompleteConsumer::ProcessCodeCompleteResults(Sema &SemaRef,
OS << "COMPLETION: "; OS << "COMPLETION: ";
switch (Results[I].Kind) { switch (Results[I].Kind) {
case Result::RK_Declaration: case Result::RK_Declaration:
OS << Results[I].Declaration->getNameAsString() ; OS << Results[I].Declaration;
if (Results[I].Hidden) if (Results[I].Hidden)
OS << " (Hidden)"; OS << " (Hidden)";
if (CodeCompletionString *CCS if (CodeCompletionString *CCS

Просмотреть файл

@ -4020,8 +4020,7 @@ void InitializationSequence::dump(llvm::raw_ostream &OS) const {
break; break;
case SK_UserConversion: case SK_UserConversion:
OS << "user-defined conversion via " OS << "user-defined conversion via " << S->Function.Function;
<< S->Function.Function->getNameAsString();
break; break;
case SK_QualificationConversionRValue: case SK_QualificationConversionRValue:

Просмотреть файл

@ -226,7 +226,7 @@ void UserDefinedConversionSequence::DebugPrint() const {
Before.DebugPrint(); Before.DebugPrint();
OS << " -> "; OS << " -> ";
} }
OS << "'" << ConversionFunction->getNameAsString() << "'"; OS << '\'' << ConversionFunction << '\'';
if (After.First || After.Second || After.Third) { if (After.First || After.Second || After.Third) {
OS << " -> "; OS << " -> ";
After.DebugPrint(); After.DebugPrint();

Просмотреть файл

@ -137,7 +137,7 @@ void USRGenerator::VisitFieldDecl(FieldDecl *D) {
void USRGenerator::VisitFunctionDecl(FunctionDecl *D) { void USRGenerator::VisitFunctionDecl(FunctionDecl *D) {
VisitDeclContext(D->getDeclContext()); VisitDeclContext(D->getDeclContext());
Out << "@F@" << D->getNameAsString(); Out << "@F@" << D;
} }
void USRGenerator::VisitNamedDecl(NamedDecl *D) { void USRGenerator::VisitNamedDecl(NamedDecl *D) {
@ -155,7 +155,7 @@ void USRGenerator::VisitNamedDecl(NamedDecl *D) {
void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) { void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) {
VisitDeclContext(D->getDeclContext()); VisitDeclContext(D->getDeclContext());
Out << "@N@" << D->getNameAsString(); Out << "@N@" << D;
} }
void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) { void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
@ -251,7 +251,7 @@ void USRGenerator::VisitTagDecl(TagDecl *D) {
if (s.empty()) { if (s.empty()) {
if (TD) if (TD)
Out << '@' << TD->getNameAsString(); Out << '@' << TD;
} }
else else
Out << '@' << s; Out << '@' << s;