sammccall added inline comments.

================
Comment at: clang-tools-extra/clangd/Selection.cpp:227
         continue;
+      // Ignore tokens in disabled preprocessor sections.
+      if (Buf.expandedTokens(SM.getMacroArgExpandedLocation(T->location()))
----------------
I think this is more work than we'd like to do in this loop (the whole file 
could be selected!) and it's also not obviously correct - it relies on the 
assumption that any token that doesn't expand to something by itself, isn't a 
macro argument or macro name, is part of an ignored region. (That may or may 
not be correct, but it's a nontrivial assumption to make here).

I think the API we need is something like `vector<TokenBuffer::Expansion> 
TokenBuffer::expansionsOverlapping(ArrayRef<Token> Spelled)`.
This requires a couple of binary searches on the TokenBuffer side to compute, 
and on this side we can just look at the spelled token ranges for empty 
expansions and mark them in a bitmap.

I'm happy to try to put together a TokenBuffer patch if this is too much of a 
yak-shave, though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83508/new/

https://reviews.llvm.org/D83508



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to