[PATCH] D117475: [clangd] NFC, emit source ranges in selection debug messages.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 17 06:20:14 PST 2022
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
It will make the output more versbose, but I found that these are useful
information when debugging selection tree.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117475
Files:
clang-tools-extra/clangd/Selection.cpp
Index: clang-tools-extra/clangd/Selection.cpp
===================================================================
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -465,11 +465,12 @@
}
#ifndef NDEBUG
-std::string printNodeToString(const DynTypedNode &N, const PrintingPolicy &PP) {
+std::string printNodeToString(const DynTypedNode &N, const PrintingPolicy &PP,
+ const SourceManager &SM) {
std::string S;
llvm::raw_string_ostream OS(S);
printNodeKind(OS, N);
- OS << " ";
+ OS << " " << N.getSourceRange().printToString(SM) << " ";
return std::move(OS.str());
}
#endif
@@ -699,7 +700,7 @@
[](const Attr *A) { return !A->isImplicit(); }))
return false;
if (!SelChecker.mayHit(S)) {
- dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy), indent());
+ dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy, SM), indent());
dlog("{1}skipped range = {0}", S.printToString(SM), indent(1));
return true;
}
@@ -717,7 +718,7 @@
// Pushes a node onto the ancestor stack. Pairs with pop().
void push(DynTypedNode Node) {
- dlog("{1}push: {0}", printNodeToString(Node, PrintPolicy), indent());
+ dlog("{1}push: {0}", printNodeToString(Node, PrintPolicy, SM), indent());
Nodes.emplace_back();
Nodes.back().ASTNode = std::move(Node);
Nodes.back().Parent = Stack.top();
@@ -729,7 +730,8 @@
// Performs primary hit detection.
void pop() {
Node &N = *Stack.top();
- dlog("{1}pop: {0}", printNodeToString(N.ASTNode, PrintPolicy), indent(-1));
+ dlog("{1}pop: {0}", printNodeToString(N.ASTNode, PrintPolicy, SM),
+ indent(-1));
claimTokensFor(N.ASTNode, N.Selected);
if (N.Selected == NoTokens)
N.Selected = SelectionTree::Unselected;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117475.400514.patch
Type: text/x-patch
Size: 1842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220117/e434cbd9/attachment.bin>
More information about the cfe-commits
mailing list