[PATCH] D136567: [clangd] Avoid hanging in Selection when PP corrects the token sequence.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 28 05:00:29 PDT 2022


hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/Selection.cpp:316
     // return the eof token.
     if (ExpandedTokens.back().kind() == tok::eof)
       ExpandedTokens = ExpandedTokens.drop_back();
----------------
It reminds me of this fix, the symptom is the same (triggers the `Batch.empty()` assertion).
With the current fix, it is no longer needed I think (maybe we should keep it, it seems an interesting special case.)


================
Comment at: clang-tools-extra/clangd/Selection.cpp:331
+        // See https://github.com/llvm/llvm-project/issues/58482
+        return T.location() >= Start && T.location() <= Limit;
       });
----------------
This is bad :(  but I don't see other better alternative, I agree the current behavior is better than hanging forever. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136567



More information about the cfe-commits mailing list