[PATCH] D65574: Added hack to prevent toHalfOpenFileRange assertion fail

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 2 01:31:07 PDT 2019


sammccall added inline comments.


================
Comment at: clang-tools-extra/clangd/Selection.cpp:373
+    if(!Range)
+      return SelectionTree::Unselected;
     dlog("{1}claimRange: {0}", Range->printToString(SM), indent());
----------------
This isn't a sufficient fix, there are 5 callsites that don't check for failure.
Adding defenses to each of them is the right thing if we really can't handle failure, but today they assume the invariant that if the inputs were from the same file id, the output will be valid. Can we really not provide that guarantee?


================
Comment at: clang-tools-extra/clangd/SourceCode.cpp:314
   while (!FileRange.getBegin().isFileID()) {
-    assert(!FileRange.getEnd().isFileID() &&
-           "Both Begin and End should be MacroIDs.");
+    // FIXME: Investigate when this assert fails. Added a hack until then.
+    // assert(!FileRange.getEnd().isFileID() &&
----------------
We have a reproducer, why can't we investigate now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65574





More information about the cfe-commits mailing list