summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/StmtPrinter.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-16 03:56:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-16 03:56:14 +0000
commit235341bc88202e402225e43ce5e7dc8a29089a25 (patch)
tree1fdd650fdbd753484dca9f9dfa58466375bd1b98 /clang/lib/AST/StmtPrinter.cpp
parent426feb61b99defcc728185769ba3b7dbe6d82020 (diff)
downloadbcm5719-llvm-235341bc88202e402225e43ce5e7dc8a29089a25.tar.gz
bcm5719-llvm-235341bc88202e402225e43ce5e7dc8a29089a25.zip
Store SourceManager pointer on PrintingPolicy in the case where we're dumping,
and remove ASTContext reference (which was frequently bound to a dereferenced null pointer) from the recursive lump of printPretty functions. In so doing, fix (at least) one case where we intended to use the 'dump' mode, but that failed because a null ASTContext reference had been passed in. llvm-svn: 162011
Diffstat (limited to 'clang/lib/AST/StmtPrinter.cpp')
-rw-r--r--clang/lib/AST/StmtPrinter.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index d5ae74d59e6..c0960ce6a24 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -30,17 +30,15 @@ using namespace clang;
namespace {
class StmtPrinter : public StmtVisitor<StmtPrinter> {
raw_ostream &OS;
- ASTContext &Context;
unsigned IndentLevel;
clang::PrinterHelper* Helper;
PrintingPolicy Policy;
public:
- StmtPrinter(raw_ostream &os, ASTContext &C, PrinterHelper* helper,
+ StmtPrinter(raw_ostream &os, PrinterHelper* helper,
const PrintingPolicy &Policy,
unsigned Indentation = 0)
- : OS(os), Context(C), IndentLevel(Indentation), Helper(helper),
- Policy(Policy) {}
+ : OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy) {}
void PrintStmt(Stmt *S) {
PrintStmt(S, Policy.Indentation);
@@ -1395,7 +1393,7 @@ void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
std::string TypeS;
if (Expr *Size = E->getArraySize()) {
llvm::raw_string_ostream s(TypeS);
- Size->printPretty(s, Context, Helper, Policy);
+ Size->printPretty(s, Helper, Policy);
s.flush();
TypeS = "[" + TypeS + "]";
}
@@ -1804,13 +1802,12 @@ void StmtPrinter::VisitAsTypeExpr(AsTypeExpr *Node) {
// Stmt method implementations
//===----------------------------------------------------------------------===//
-void Stmt::dumpPretty(ASTContext& Context) const {
- printPretty(llvm::errs(), Context, 0,
- PrintingPolicy(Context.getLangOpts()));
+void Stmt::dumpPretty(ASTContext &Context) const {
+ printPretty(llvm::errs(), 0, PrintingPolicy(Context.getLangOpts()));
}
-void Stmt::printPretty(raw_ostream &OS, ASTContext& Context,
- PrinterHelper* Helper,
+void Stmt::printPretty(raw_ostream &OS,
+ PrinterHelper *Helper,
const PrintingPolicy &Policy,
unsigned Indentation) const {
if (this == 0) {
@@ -1818,12 +1815,12 @@ void Stmt::printPretty(raw_ostream &OS, ASTContext& Context,
return;
}
- if (Policy.Dump && &Context) {
- dump(OS, Context.getSourceManager());
+ if (Policy.DumpSourceManager) {
+ dump(OS, *Policy.DumpSourceManager);
return;
}
- StmtPrinter P(OS, Context, Helper, Policy, Indentation);
+ StmtPrinter P(OS, Helper, Policy, Indentation);
P.Visit(const_cast<Stmt*>(this));
}
OpenPOWER on IntegriCloud