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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72590 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index c94a4da..09522a2 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/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 @@
 
 /// \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 @@
     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::dump() {
-  print(llvm::errs());
+  PrintingPolicy Policy;
+  Policy.CPlusPlus = true;
+  print(llvm::errs(), Policy);
 }