diff options
author | Brad King <brad.king@kitware.com> | 2015-05-15 19:15:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-05-15 19:15:57 (GMT) |
commit | 5587062f5f894d7b2d7a61679a495535db0a8924 (patch) | |
tree | b7a45ae415a34e7a6d414c9e85df12a1d6db334f /src | |
parent | 29edb122e53ee80201a7e535f6e26f161de86a47 (diff) | |
download | CastXML-5587062f5f894d7b2d7a61679a495535db0a8924.zip CastXML-5587062f5f894d7b2d7a61679a495535db0a8924.tar.gz CastXML-5587062f5f894d7b2d7a61679a495535db0a8924.tar.bz2 |
Output: Refactor Clang printing policy selection
Store our printing policy in a member up front.
Diffstat (limited to 'src')
-rw-r--r-- | src/Output.cxx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Output.cxx b/src/Output.cxx index 709c5b8..d505b54 100644 --- a/src/Output.cxx +++ b/src/Output.cxx @@ -456,6 +456,9 @@ private: // Mangling context for target ABI. std::unique_ptr<clang::MangleContext> MangleContext; + // Control declaration and type printing. + clang::PrintingPolicy PrintingPolicy; + // Map from clang AST declaration node to our dump status node. typedef std::map<clang::Decl const*, DumpNode> DeclNodesMap; DeclNodesMap DeclNodes; @@ -488,7 +491,9 @@ public: NodeCount(0), FileCount(0), FileBuiltin(false), RequireComplete(true), - MangleContext(ctx.createMangleContext()) {} + MangleContext(ctx.createMangleContext()), + PrintingPolicy(ctx.getPrintingPolicy()) { + } /** Visit declarations in the given translation unit. This is the main entry point. */ @@ -1347,7 +1352,7 @@ void ASTVisitor::OutputFunctionArgument(clang::ParmVarDecl const* a, this->OS << " default=\""; std::string s; llvm::raw_string_ostream rso(s); - def->printPretty(rso, 0, this->CTX.getPrintingPolicy()); + def->printPretty(rso, 0, this->PrintingPolicy); this->OS << encodeXML(rso.str()); this->OS << "\""; } @@ -1408,7 +1413,7 @@ void ASTVisitor::OutputRecordDecl(clang::RecordDecl const* d, if(!d->isAnonymousStructOrUnion()) { std::string s; llvm::raw_string_ostream rso(s); - d->getNameForDiagnostic(rso, this->CTX.getPrintingPolicy(), false); + d->getNameForDiagnostic(rso, this->PrintingPolicy, false); this->PrintNameAttribute(rso.str()); } this->PrintContextAttribute(d); @@ -1542,7 +1547,7 @@ void ASTVisitor::OutputVarDecl(clang::VarDecl const* d, DumpNode const* dn) this->OS << " init=\""; std::string s; llvm::raw_string_ostream rso(s); - init->printPretty(rso, 0, this->CTX.getPrintingPolicy()); + init->printPretty(rso, 0, this->PrintingPolicy); this->OS << encodeXML(rso.str()); this->OS << "\""; } @@ -1690,7 +1695,7 @@ void ASTVisitor::OutputBuiltinType(clang::BuiltinType const* t, case clang::BuiltinType::ULong: name = "long unsigned int"; break; case clang::BuiltinType::LongLong: name = "long long int"; break; case clang::BuiltinType::ULongLong: name = "long long unsigned int"; break; - default: name = t->getName(this->CTX.getPrintingPolicy()).str(); break; + default: name = t->getName(this->PrintingPolicy).str(); break; }; this->PrintNameAttribute(name); this->PrintABIAttributes(this->CTX.getTypeInfo(t)); |