diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-05-29 20:38:28 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-05-29 20:38:28 +0000 |
commit | 7de5966d76fea50cdf1ded7ccd2677594a12ef36 (patch) | |
tree | a823b08ce247d4b9447e707117392e469ee0936f /clang/lib/AST/NestedNameSpecifier.cpp | |
parent | 006459ecd4ab07c8a1daa2d005533649261f8c4a (diff) | |
download | bcm5719-llvm-7de5966d76fea50cdf1ded7ccd2677594a12ef36.tar.gz bcm5719-llvm-7de5966d76fea50cdf1ded7ccd2677594a12ef36.zip |
Create a new PrintingPolicy class, which we pass down through the AST
printing logic to help customize the output. For now, we use this
rather than a special flag to suppress the "struct" when printing
"struct X" and to print the Boolean type as "bool" in C++ but "_Bool"
in C.
llvm-svn: 72590
Diffstat (limited to 'clang/lib/AST/NestedNameSpecifier.cpp')
-rw-r--r-- | clang/lib/AST/NestedNameSpecifier.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/AST/NestedNameSpecifier.cpp b/clang/lib/AST/NestedNameSpecifier.cpp index c94a4da7b61..09522a20863 100644 --- a/clang/lib/AST/NestedNameSpecifier.cpp +++ b/clang/lib/AST/NestedNameSpecifier.cpp @@ -14,6 +14,7 @@ #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" +#include "clang/AST/PrettyPrinter.h" #include "clang/AST/Type.h" #include "llvm/Support/raw_ostream.h" #include <cassert> @@ -104,9 +105,11 @@ bool NestedNameSpecifier::isDependent() const { /// \brief Print this nested name specifier to the given output /// stream. -void NestedNameSpecifier::print(llvm::raw_ostream &OS) const { +void +NestedNameSpecifier::print(llvm::raw_ostream &OS, + const PrintingPolicy &Policy) const { if (getPrefix()) - getPrefix()->print(OS); + getPrefix()->print(OS, Policy); switch (getKind()) { case Identifier: @@ -134,10 +137,9 @@ void NestedNameSpecifier::print(llvm::raw_ostream &OS) const { if (const QualifiedNameType *QualT = dyn_cast<QualifiedNameType>(T)) T = QualT->getNamedType().getTypePtr(); - if (const TagType *TagT = dyn_cast<TagType>(T)) - TagT->getAsStringInternal(TypeStr, true); - else - T->getAsStringInternal(TypeStr); + PrintingPolicy InnerPolicy(Policy); + InnerPolicy.SuppressTagKind = true; + T->getAsStringInternal(TypeStr, InnerPolicy); OS << TypeStr; break; } @@ -152,5 +154,7 @@ void NestedNameSpecifier::Destroy(ASTContext &Context) { } void NestedNameSpecifier::dump() { - print(llvm::errs()); + PrintingPolicy Policy; + Policy.CPlusPlus = true; + print(llvm::errs(), Policy); } |