aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-04-17 09:33:03 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-04-17 09:33:03 +0000
commit900fc6388e803868a34b9483510c345e9b49d7eb (patch)
tree039296944edf1cf7ea7bcff92bcd42d550fb9c84
parent7a22f02a02616be8fd817529f1696a88a35ee041 (diff)
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
-rw-r--r--include/clang/AST/Decl.h2
-rw-r--r--include/clang/AST/DeclObjC.h6
-rw-r--r--lib/AST/Decl.cpp6
-rw-r--r--lib/AST/DeclObjC.cpp12
-rw-r--r--lib/AST/DeclPrinter.cpp69
-rw-r--r--lib/AST/Expr.cpp10
-rw-r--r--lib/AST/RecordLayoutBuilder.cpp5
-rw-r--r--lib/AST/StmtDumper.cpp16
-rw-r--r--lib/AST/StmtPrinter.cpp14
-rw-r--r--lib/AST/TemplateName.cpp4
-rw-r--r--lib/Checker/BugReporter.cpp2
-rw-r--r--lib/Checker/BugReporterVisitors.cpp4
-rw-r--r--lib/Checker/CFRefCount.cpp2
-rw-r--r--lib/Checker/CallAndMessageChecker.cpp5
-rw-r--r--lib/Checker/CheckObjCDealloc.cpp10
-rw-r--r--lib/Checker/CheckObjCInstMethSignature.cpp6
-rw-r--r--lib/Checker/CheckSecuritySyntaxOnly.cpp12
-rw-r--r--lib/Checker/MemRegion.cpp6
-rw-r--r--lib/Checker/NSErrorChecker.cpp2
-rw-r--r--lib/Checker/ObjCUnusedIVarsChecker.cpp3
-rw-r--r--lib/CodeGen/CGObjCMac.cpp2
-rw-r--r--lib/CodeGen/Mangle.cpp2
-rw-r--r--lib/Frontend/ASTConsumers.cpp46
-rw-r--r--lib/Frontend/AnalysisConsumer.cpp2
-rw-r--r--lib/Index/ASTLocation.cpp4
-rw-r--r--lib/Sema/CodeCompleteConsumer.cpp2
-rw-r--r--lib/Sema/SemaInit.cpp3
-rw-r--r--lib/Sema/SemaOverload.cpp2
-rw-r--r--tools/CIndex/CIndexUSRs.cpp6
29 files changed, 134 insertions, 131 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index a6a8b4cc84..e3e16d3d91 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -217,6 +217,8 @@ public:
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.
class NamespaceDecl : public NamedDecl, public DeclContext {
SourceLocation LBracLoc, RBracLoc;
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 991330466a..18bb607d79 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -1132,6 +1132,9 @@ public:
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
/// method definitions are specified. For example:
///
@@ -1217,6 +1220,9 @@ public:
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
/// declared as @compatibility_alias alias class.
class ObjCCompatibleAliasDecl : public NamedDecl {
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index d4cc945b1b..fdec2f5d65 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -512,6 +512,12 @@ bool NamedDecl::isCXXInstanceMember() const {
return false;
}
+llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
+ const NamedDecl *ND) {
+ OS << ND->getNameAsString();
+ return OS;
+}
+
//===----------------------------------------------------------------------===//
// DeclaratorDecl Implementation
//===----------------------------------------------------------------------===//
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index db46d89a76..dc4aacdb51 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -843,6 +843,12 @@ FindPropertyImplDecl(IdentifierInfo *Id) const {
return 0;
}
+llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
+ const ObjCCategoryImplDecl *CID) {
+ OS << CID->getName();
+ return OS;
+}
+
//===----------------------------------------------------------------------===//
// ObjCImplementationDecl
//===----------------------------------------------------------------------===//
@@ -855,6 +861,12 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
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
//===----------------------------------------------------------------------===//
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index a625865ecd..5394924797 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) {
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 7c715bd3c3..88b5b5e567 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -290,14 +290,12 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
// For incorrect code, there might not be an ObjCInterfaceDecl. Do
// a null check to avoid a crash.
if (const ObjCInterfaceDecl *ID = MD->getClassInterface())
- Out << ID->getNameAsString();
+ Out << ID;
if (const ObjCCategoryImplDecl *CID =
- dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext())) {
- Out << '(';
- Out << CID->getNameAsString();
- Out << ')';
- }
+ dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
+ Out << '(' << CID << ')';
+
Out << ' ';
Out << MD->getSelector().getAsString();
Out << ']';
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp
index 15ad11f7fd..d1de70a7ab 100644
--- a/lib/AST/RecordLayoutBuilder.cpp
+++ b/lib/AST/RecordLayoutBuilder.cpp
@@ -924,7 +924,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
// Vtable pointer.
if (RD->isDynamicClass() && !PrimaryBase) {
PrintOffset(OS, Offset, IndentLevel);
- OS << '(' << RD->getNameAsString() << " vtable pointer)\n";
+ OS << '(' << RD << " vtable pointer)\n";
}
// Dump (non-virtual) bases
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);
- OS << Field->getType().getAsString() << ' ';
- OS << Field->getNameAsString() << '\n';
+ OS << Field->getType().getAsString() << ' ' << Field << '\n';
}
if (!IncludeVirtualBases)
diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp
index ba6218be14..79f61f2bf3 100644
--- a/lib/AST/StmtDumper.cpp
+++ b/lib/AST/StmtDumper.cpp
@@ -219,7 +219,7 @@ void StmtDumper::DumpDeclarator(Decl *D) {
// nodes are where they need to be.
if (TypedefDecl *localType = dyn_cast<TypedefDecl>(D)) {
OS << "\"typedef " << localType->getUnderlyingType().getAsString()
- << " " << localType->getNameAsString() << "\"";
+ << ' ' << localType << '"';
} else if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
OS << "\"";
// Emit storage class for vardecls.
@@ -328,15 +328,14 @@ void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
case Decl::ObjCClass: OS << "ObjCClass"; break;
}
- OS << "='" << Node->getDecl()->getNameAsString()
- << "' " << (void*)Node->getDecl();
+ OS << "='" << Node->getDecl() << "' " << (void*)Node->getDecl();
}
void StmtDumper::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *Node) {
DumpExpr(Node);
OS << " (";
if (!Node->requiresADL()) OS << "no ";
- OS << "ADL) = '" << Node->getName().getAsString() << "'";
+ OS << "ADL) = '" << Node->getName() << '\'';
UnresolvedLookupExpr::decls_iterator
I = Node->decls_begin(), E = Node->decls_end();
@@ -349,7 +348,7 @@ void StmtDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
DumpExpr(Node);
OS << " " << Node->getDecl()->getDeclKindName()
- << "Decl='" << Node->getDecl()->getNameAsString()
+ << "Decl='" << Node->getDecl()
<< "' " << (void*)Node->getDecl();
if (Node->isFreeIvar())
OS << " isFreeIvar";
@@ -408,7 +407,7 @@ void StmtDumper::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *Node) {
void StmtDumper::VisitMemberExpr(MemberExpr *Node) {
DumpExpr(Node);
OS << " " << (Node->isArrow() ? "->" : ".")
- << Node->getMemberDecl()->getNameAsString() << " "
+ << Node->getMemberDecl() << ' '
<< (void*)Node->getMemberDecl();
}
void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
@@ -525,14 +524,13 @@ void StmtDumper::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
void StmtDumper::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
DumpExpr(Node);
- OS << " " << Node->getProtocol()->getNameAsString();
+ OS << ' ' << Node->getProtocol();
}
void StmtDumper::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
DumpExpr(Node);
- OS << " Kind=PropertyRef Property=\""
- << Node->getProperty()->getNameAsString() << "\"";
+ OS << " Kind=PropertyRef Property=\"" << Node->getProperty() << '"';
}
void StmtDumper::VisitObjCImplicitSetterGetterRefExpr(
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index da43878628..44d475853d 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -474,7 +474,7 @@ void StmtPrinter::VisitExpr(Expr *Node) {
void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
Qualifier->print(OS, Policy);
- OS << Node->getDecl()->getNameAsString();
+ OS << Node->getDecl();
if (Node->hasExplicitTemplateArgumentList())
OS << TemplateSpecializationType::PrintTemplateArgumentList(
Node->getTemplateArgs(),
@@ -509,7 +509,7 @@ void StmtPrinter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
PrintExpr(Node->getBase());
OS << (Node->isArrow() ? "->" : ".");
}
- OS << Node->getDecl()->getNameAsString();
+ OS << Node->getDecl();
}
void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
@@ -527,7 +527,7 @@ void StmtPrinter::VisitObjCImplicitSetterGetterRefExpr(
OS << ".";
}
if (Node->getGetterMethod())
- OS << Node->getGetterMethod()->getNameAsString();
+ OS << Node->getGetterMethod();
}
@@ -695,7 +695,7 @@ bool StmtPrinter::PrintOffsetOfDesignator(Expr *E) {
} else {
MemberExpr *ME = cast<MemberExpr>(E);
bool IsFirst = PrintOffsetOfDesignator(ME->getBase());
- OS << (IsFirst ? "" : ".") << ME->getMemberDecl()->getNameAsString();
+ OS << (IsFirst ? "" : ".") << ME->getMemberDecl();
return false;
}
}
@@ -746,7 +746,7 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
Qualifier->print(OS, Policy);
- OS << Node->getMemberDecl()->getNameAsString();
+ OS << Node->getMemberDecl();
if (Node->hasExplicitTemplateArgumentList())
OS << TemplateSpecializationType::PrintTemplateArgumentList(
@@ -1242,7 +1242,7 @@ void StmtPrinter::VisitObjCSelectorExpr(ObjCSelectorExpr *Node) {
}
void StmtPrinter::VisitObjCProtocolExpr(ObjCProtocolExpr *Node) {
- OS << "@protocol(" << Node->getProtocol()->getNameAsString() << ')';
+ OS << "@protocol(" << Node->getProtocol() << ')';
}
void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
@@ -1304,7 +1304,7 @@ void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
}
void StmtPrinter::VisitBlockDeclRefExpr(BlockDeclRefExpr *Node) {
- OS << Node->getDecl()->getNameAsString();
+ OS << Node->getDecl();
}
//===----------------------------------------------------------------------===//
// Stmt method implementations
diff --git a/lib/AST/TemplateName.cpp b/lib/AST/TemplateName.cpp
index a1ee552264..14722f7039 100644
--- a/lib/AST/TemplateName.cpp
+++ b/lib/AST/TemplateName.cpp
@@ -47,13 +47,13 @@ void
TemplateName::print(llvm::raw_ostream &OS, const PrintingPolicy &Policy,
bool SuppressNNS) const {
if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>())
- OS << Template->getNameAsString();
+ OS << Template;
else if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) {
if (!SuppressNNS)
QTN->getQualifier()->print(OS, Policy);
if (QTN->hasTemplateKeyword())
OS << "template ";
- OS << QTN->getDecl()->getNameAsString();
+ OS << QTN->getDecl();
} else if (DependentTemplateName *DTN = getAsDependentTemplateName()) {
if (!SuppressNNS && DTN->getQualifier())
DTN->getQualifier()->print(OS, Policy);
diff --git a/lib/Checker/BugReporter.cpp b/lib/Checker/BugReporter.cpp
index 4475872ee2..3bcc03f4f2 100644
--- a/lib/Checker/BugReporter.cpp
+++ b/lib/Checker/BugReporter.cpp
@@ -607,7 +607,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD,
if (D) {
GetRawInt = false;
- os << D->getNameAsString();
+ os << D;
}
}
diff --git a/lib/Checker/BugReporterVisitors.cpp b/lib/Checker/BugReporterVisitors.cpp
index 06cee5bcd1..544129bbf2 100644
--- a/lib/Checker/BugReporterVisitors.cpp
+++ b/lib/Checker/BugReporterVisitors.cpp
@@ -144,7 +144,7 @@ public:
if (const DeclStmt *DS = PS->getStmtAs<DeclStmt>()) {
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
- os << "Variable '" << VR->getDecl()->getNameAsString() << "' ";
+ os << "Variable '" << VR->getDecl() << "' ";
}
else
return NULL;
@@ -206,7 +206,7 @@ public:
return NULL;
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
- os << '\'' << VR->getDecl()->getNameAsString() << '\'';
+ os << '\'' << VR->getDecl() << '\'';
}
else
return NULL;
diff --git a/lib/Checker/CFRefCount.cpp b/lib/Checker/CFRefCount.cpp
index 3c4a27cc07..a0b4666160 100644
--- a/lib/Checker/CFRefCount.cpp
+++ b/lib/Checker/CFRefCount.cpp
@@ -2081,7 +2081,7 @@ PathDiagnosticPiece* CFRefReport::VisitNode(const ExplodedNode* N,
// Get the name of the callee (if it is available).
SVal X = CurrSt->getSValAsScalarOrLoc(CE->getCallee());
if (const FunctionDecl* FD = X.getAsFunctionDecl())
- os << "Call to function '" << FD->getNameAsString() <<'\'';
+ os << "Call to function '" << FD << '\'';
else
os << "function call";
}
diff --git a/lib/Checker/CallAndMessageChecker.cpp b/lib/Checker/CallAndMessageChecker.cpp
index dd1856c9d2..ce9f26ec69 100644
--- a/lib/Checker/CallAndMessageChecker.cpp
+++ b/lib/Checker/CallAndMessageChecker.cpp
@@ -154,8 +154,7 @@ bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
os << "Passed-by-value struct argument contains uninitialized data";
if (F.FieldChain.size() == 1)
- os << " (e.g., field: '" << F.FieldChain[0]->getNameAsString()
- << "')";
+ os << " (e.g., field: '" << F.FieldChain[0] << "')";
else {
os << " (e.g., via the field chain: '";
bool first = true;
@@ -165,7 +164,7 @@ bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
first = false;
else
os << '.';
- os << (*DI)->getNameAsString();
+ os << *DI;
}
os << "')";
}
diff --git a/lib/Checker/CheckObjCDealloc.cpp b/lib/Checker/CheckObjCDealloc.cpp
index d9606f1306..f510de573e 100644
--- a/lib/Checker/CheckObjCDealloc.cpp
+++ b/lib/Checker/CheckObjCDealloc.cpp
@@ -166,8 +166,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
std::string buf;
llvm::raw_string_ostream os(buf);
- os << "Objective-C class '" << D->getNameAsString()
- << "' lacks a 'dealloc' instance method";
+ os << "Objective-C class '" << D << "' lacks a 'dealloc' instance method";
BR.EmitBasicReport(name, os.str(), D->getLocStart());
return;
@@ -182,8 +181,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
std::string buf;
llvm::raw_string_ostream os(buf);
- os << "The 'dealloc' instance method in Objective-C class '"
- << D->getNameAsString()
+ os << "The 'dealloc' instance method in Objective-C class '" << D
<< "' does not send a 'dealloc' message to its super class"
" (missing [super dealloc])";
@@ -238,7 +236,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
? "missing ivar release (leak)"
: "missing ivar release (Hybrid MM, non-GC)";
- os << "The '" << ID->getNameAsString()
+ os << "The '" << ID
<< "' instance variable was retained by a synthesized property but "
"wasn't released in 'dealloc'";
} else {
@@ -246,7 +244,7 @@ void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
? "extra ivar release (use-after-release)"
: "extra ivar release (Hybrid MM, non-GC)";
- os << "The '" << ID->getNameAsString()
+ os << "The '" << ID
<< "' instance variable was not retained by a synthesized property "
"but was released in 'dealloc'";
}
diff --git a/lib/Checker/CheckObjCInstMethSignature.cpp b/lib/Checker/CheckObjCInstMethSignature.cpp
index 8c43a45d92..76a092393b 100644
--- a/lib/Checker/CheckObjCInstMethSignature.cpp
+++ b/lib/Checker/CheckObjCInstMethSignature.cpp
@@ -49,16 +49,16 @@ static void CompareReturnTypes(const ObjCMethodDecl *MethDerived,
llvm::raw_string_ostream os(sbuf);
os << "The Objective-C class '"
- << MethDerived->getClassInterface()->getNameAsString()
+ << MethDerived->getClassInterface()
<< "', which is derived from class '"
- << MethAncestor->getClassInterface()->getNameAsString()
+ << MethAncestor->getClassInterface()
<< "', defines the instance method '"
<< MethDerived->getSelector().getAsString()
<< "' whose return type is '"
<< ResDerived.getAsString()
<< "'. A method with the same name (same selector) is also defined in "
"class '"
- << MethAncestor->getClassInterface()->getNameAsString()
+ << MethAncestor->getClassInterface()
<< "' and has a return type of '"
<< ResAncestor.getAsString()
<< "'. These two types are incompatible, and may result in undefined "
diff --git a/lib/Checker/CheckSecuritySyntaxOnly.cpp b/lib/Checker/CheckSecuritySyntaxOnly.cpp
index efbce61261..74e12b18a8 100644
--- a/lib/Checker/CheckSecuritySyntaxOnly.cpp
+++ b/lib/Checker/CheckSecuritySyntaxOnly.cpp
@@ -387,11 +387,11 @@ void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) {
// Issue a warning.
llvm::SmallString<256> 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::raw_svector_ostream os2(buf2);
- os2 << "Function '" << FD->getNameAsString()
+