[clang-tools-extra] r364180 - [clangd] Improve SelectionTree string representation

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 24 06:01:28 PDT 2019


Author: sammccall
Date: Mon Jun 24 06:01:28 2019
New Revision: 364180

URL: http://llvm.org/viewvc/llvm-project?rev=364180&view=rev
Log:
[clangd] Improve SelectionTree string representation

Modified:
    clang-tools-extra/trunk/clangd/Selection.cpp

Modified: clang-tools-extra/trunk/clangd/Selection.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Selection.cpp?rev=364180&r1=364179&r2=364180&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/Selection.cpp (original)
+++ clang-tools-extra/trunk/clangd/Selection.cpp Mon Jun 24 06:01:28 2019
@@ -246,7 +246,17 @@ void SelectionTree::print(llvm::raw_ostr
                                                                     : '.');
   else
     OS.indent(Indent);
-  OS << N.ASTNode.getNodeKind().asStringRef() << " ";
+  if (const TypeLoc *TL = N.ASTNode.get<TypeLoc>()) {
+    // TypeLoc is a hierarchy, but has only a single ASTNodeKind.
+    // Synthesize the name from the Type subclass (except for QualifiedTypeLoc).
+    if (TL->getTypeLocClass() == TypeLoc::Qualified)
+      OS << "QualifiedTypeLoc";
+    else
+      OS << TL->getType()->getTypeClassName() << "TypeLoc";
+  } else {
+    OS << N.ASTNode.getNodeKind().asStringRef();
+  }
+  OS << " ";
   N.ASTNode.print(OS, PrintPolicy);
   OS << "\n";
   for (const Node *Child : N.Children)
@@ -280,6 +290,7 @@ SelectionTree::SelectionTree(ASTContext
   if (Begin == End)
     std::tie(Begin, End) = pointBounds(Begin, FID, AST);
   PrintPolicy.TerseOutput = true;
+  PrintPolicy.IncludeNewlines = false;
 
   Nodes = SelectionVisitor::collect(AST, Begin, End, FID);
   Root = Nodes.empty() ? nullptr : &Nodes.front();




More information about the cfe-commits mailing list