summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-06-24 13:01:28 +0000
committerSam McCall <sam.mccall@gmail.com>2019-06-24 13:01:28 +0000
commitca89eb5f9c9d60f9b94f44490c34b7a788426deb (patch)
treef29cb3a38b467e3df3edff74d37456ab9e4dfa75
parent69144a925e741736f9a4b9e749657923fcffd546 (diff)
downloadbcm5719-llvm-ca89eb5f9c9d60f9b94f44490c34b7a788426deb.tar.gz
bcm5719-llvm-ca89eb5f9c9d60f9b94f44490c34b7a788426deb.zip
[clangd] Improve SelectionTree string representation
llvm-svn: 364180
-rw-r--r--clang-tools-extra/clangd/Selection.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp
index 2eef06031e1..e0fb4423737 100644
--- a/clang-tools-extra/clangd/Selection.cpp
+++ b/clang-tools-extra/clangd/Selection.cpp
@@ -246,7 +246,17 @@ void SelectionTree::print(llvm::raw_ostream &OS, const SelectionTree::Node &N,
: '.');
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 &AST, unsigned Begin, unsigned End)
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();
OpenPOWER on IntegriCloud