[cfe-commits] r149982 - in /cfe/trunk: lib/AST/DeclPrinter.cpp lib/AST/StmtDumper.cpp lib/AST/StmtPrinter.cpp lib/AST/TemplateBase.cpp lib/AST/TemplateName.cpp lib/Frontend/FrontendAction.cpp lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp lib/StaticAnalyzer/Core/BugReporterVisitors.cpp tools/libclang/CIndex.cpp
Benjamin Kramer
benny.kra at googlemail.com
Tue Feb 7 03:57:57 PST 2012
Author: d0k
Date: Tue Feb 7 05:57:57 2012
New Revision: 149982
URL: http://llvm.org/viewvc/llvm-project?rev=149982&view=rev
Log:
Print NamedDecls directly to a raw_ostream where possible.
Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/StmtDumper.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/TemplateBase.cpp
cfe/trunk/lib/AST/TemplateName.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Feb 7 05:57:57 2012
@@ -335,8 +335,7 @@
}
void DeclPrinter::VisitTypeAliasDecl(TypeAliasDecl *D) {
- Out << "using " << D->getNameAsString() << " = "
- << D->getUnderlyingType().getAsString(Policy);
+ Out << "using " << *D << " = " << D->getUnderlyingType().getAsString(Policy);
}
void DeclPrinter::VisitEnumDecl(EnumDecl *D) {
@@ -600,7 +599,7 @@
}
void DeclPrinter::VisitLabelDecl(LabelDecl *D) {
- Out << D->getNameAsString() << ":";
+ Out << *D << ":";
}
@@ -761,7 +760,7 @@
if (TTP->isParameterPack())
Out << "... ";
- Out << TTP->getNameAsString();
+ Out << *TTP;
if (Args) {
Out << " = ";
Modified: cfe/trunk/lib/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtDumper.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtDumper.cpp (original)
+++ cfe/trunk/lib/AST/StmtDumper.cpp Tue Feb 7 05:57:57 2012
@@ -287,7 +287,7 @@
PrintingPolicy(UD->getASTContext().getLangOptions()));
OS << ";\"";
} else if (LabelDecl *LD = dyn_cast<LabelDecl>(D)) {
- OS << "label " << LD->getNameAsString();
+ OS << "label " << *LD;
} else if (StaticAssertDecl *SAD = dyn_cast<StaticAssertDecl>(D)) {
OS << "\"static_assert(\n";
DumpSubTree(SAD->getAssertExpr());
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Tue Feb 7 05:57:57 2012
@@ -1608,12 +1608,12 @@
}
void StmtPrinter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
- OS << "sizeof...(" << E->getPack()->getNameAsString() << ")";
+ OS << "sizeof...(" << *E->getPack() << ")";
}
void StmtPrinter::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *Node) {
- OS << Node->getParameterPack()->getNameAsString();
+ OS << *Node->getParameterPack();
}
void StmtPrinter::VisitSubstNonTypeTemplateParmExpr(
Modified: cfe/trunk/lib/AST/TemplateBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TemplateBase.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TemplateBase.cpp (original)
+++ cfe/trunk/lib/AST/TemplateBase.cpp Tue Feb 7 05:57:57 2012
@@ -326,7 +326,7 @@
if (NamedDecl *ND = dyn_cast_or_null<NamedDecl>(getAsDecl())) {
if (ND->getDeclName()) {
Unnamed = false;
- Out << ND->getNameAsString();
+ Out << *ND;
}
}
Modified: cfe/trunk/lib/AST/TemplateName.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TemplateName.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TemplateName.cpp (original)
+++ cfe/trunk/lib/AST/TemplateName.cpp Tue Feb 7 05:57:57 2012
@@ -149,7 +149,7 @@
subst->getReplacement().print(OS, Policy, SuppressNNS);
} else if (SubstTemplateTemplateParmPackStorage *SubstPack
= getAsSubstTemplateTemplateParmPack())
- OS << SubstPack->getParameterPack()->getNameAsString();
+ OS << *SubstPack->getParameterPack();
else {
OverloadedTemplateStorage *OTS = getAsOverloadedTemplate();
(*OTS->begin())->printName(OS);
Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Tue Feb 7 05:57:57 2012
@@ -76,7 +76,7 @@
virtual void DeclRead(serialization::DeclID ID, const Decl *D) {
llvm::outs() << "PCH DECL: " << D->getDeclKindName();
if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
- llvm::outs() << " - " << ND->getNameAsString();
+ llvm::outs() << " - " << *ND;
llvm::outs() << "\n";
DelegatingDeserializationListener::DeclRead(ID, D);
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Tue Feb 7 05:57:57 2012
@@ -2205,7 +2205,7 @@
else {
const FunctionDecl *FD = cast<FunctionDecl>(D);
os << " is returned from a function whose name ('"
- << FD->getNameAsString()
+ << *FD
<< "') does not contain 'Copy' or 'Create'. This violates the naming"
" convention rules given in the Memory Management Guide for Core"
" Foundation";
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp Tue Feb 7 05:57:57 2012
@@ -165,18 +165,18 @@
os << "Call Path : ";
// Name of current visiting CallExpr.
- os << CE->getDirectCallee()->getNameAsString();
+ os << *CE->getDirectCallee();
// Name of the CallExpr whose body is current walking.
if (visitingCallExpr)
- os << " <-- " << visitingCallExpr->getDirectCallee()->getNameAsString();
+ os << " <-- " << *visitingCallExpr->getDirectCallee();
// Names of FunctionDecls in worklist with state PostVisited.
for (SmallVectorImpl<const CallExpr *>::iterator I = WList.end(),
E = WList.begin(); I != E; --I) {
const FunctionDecl *FD = (*(I-1))->getDirectCallee();
assert(FD);
if (VisitedFunctions[FD] == PostVisited)
- os << " <-- " << FD->getNameAsString();
+ os << " <-- " << *FD;
}
PathDiagnosticLocation CELoc =
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Tue Feb 7 05:57:57 2012
@@ -757,7 +757,7 @@
if (isa<BlockDecl>(callee))
Out << "Entering call to block";
else if (const NamedDecl *ND = dyn_cast<NamedDecl>(callee))
- Out << "Entering call to '" << ND->getNameAsString() << "'";
+ Out << "Entering call to '" << *ND << "'";
StringRef msg = Out.str();
if (msg.empty())
return 0;
@@ -767,7 +767,7 @@
const Decl *caller = CExit->getLocationContext()->getParent()->getDecl();
pos = getLastStmtLoc(PrevN, BRC.getSourceManager());
if (const NamedDecl *ND = dyn_cast<NamedDecl>(caller))
- Out << "Returning to '" << ND->getNameAsString() << "'";
+ Out << "Returning to '" << *ND << "'";
else
Out << "Returning to caller";
return new PathDiagnosticCallExitPiece(pos, Out.str());
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=149982&r1=149981&r2=149982&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Feb 7 05:57:57 2012
@@ -3042,7 +3042,7 @@
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
llvm::SmallString<64> Str;
llvm::raw_svector_ostream OS(Str);
- OS << Function->getNameAsString();
+ OS << *Function;
if (Function->getPrimaryTemplate())
OS << "<>";
OS << "(";
@@ -3064,7 +3064,7 @@
if (ClassTemplateDecl *ClassTemplate = dyn_cast<ClassTemplateDecl>(D)) {
llvm::SmallString<64> Str;
llvm::raw_svector_ostream OS(Str);
- OS << ClassTemplate->getNameAsString();
+ OS << *ClassTemplate;
OS << "<";
TemplateParameterList *Params = ClassTemplate->getTemplateParameters();
for (unsigned I = 0, N = Params->size(); I != N; ++I) {
@@ -3100,7 +3100,7 @@
llvm::SmallString<64> Str;
llvm::raw_svector_ostream OS(Str);
- OS << ClassSpec->getNameAsString();
+ OS << *ClassSpec;
OS << TemplateSpecializationType::PrintTemplateArgumentList(
ClassSpec->getTemplateArgs().data(),
ClassSpec->getTemplateArgs().size(),
More information about the cfe-commits
mailing list