[PATCH] D65073: [clangd] Add dlog()s for SelectionTree, enabling -debug-only=SelectionTree.cpp

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 05:11:17 PDT 2019


sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: llvm-commits, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: LLVM.

SelectionTree is a RecursiveASTVisitor which processes getSourceRange() for
every node. This is a lot of surface area with the AST, as getSourceRange()
is specialized for *many* node types.
And the resulting SelectionTree depends on the source ranges of many
visited nodes, and the order of traversal.

Put together, this means we really need a traversal log to debug when we
get an unexpected SelectionTree. I've built this ad-hoc a few times, now
it's time to check it in.

Example output:

  D[14:07:44.184] Computing selection for </usr/local/google/home/sammccall/test.cc:1:7, col:8>
  D[14:07:44.184]  push: VarDecl const auto x = 42
  D[14:07:44.184]   claimRange: </usr/local/google/home/sammccall/test.cc:1:12, col:13>
  D[14:07:44.184]   push: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
  D[14:07:44.184]   pop: NestedNameSpecifierLoc (empty NestedNameSpecifierLoc)
  D[14:07:44.184]   push: QualifiedTypeLoc const auto
  D[14:07:44.184]   pop: QualifiedTypeLoc const auto
  D[14:07:44.184]    claimRange: </usr/local/google/home/sammccall/test.cc:1:7, col:11>
  D[14:07:44.184]    hit selection: </usr/local/google/home/sammccall/test.cc:1:7, col:8>
  D[14:07:44.184]   skip: IntegerLiteral 42
  D[14:07:44.184]    skipped range = </usr/local/google/home/sammccall/test.cc:1:16>
  D[14:07:44.184]  pop: VarDecl const auto x = 42
  D[14:07:44.184]   claimRange: </usr/local/google/home/sammccall/test.cc:1:1, col:18>
  D[14:07:44.184]  skip: VarDecl int y = 43
  D[14:07:44.184]   skipped range = </usr/local/google/home/sammccall/test.cc:2:1, col:9>
  D[14:07:44.184] Built selection tree
  TranslationUnitDecl
    VarDecl const auto x = 42
       .QualifiedTypeLoc const auto


Repository:
  rL LLVM

https://reviews.llvm.org/D65073

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang/lib/AST/ASTTypeTraits.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65073.211056.patch
Type: text/x-patch
Size: 10993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190722/75832298/attachment.bin>


More information about the llvm-commits mailing list