ilya-biryukov added inline comments.

================
Comment at: clangd/XRefs.cpp:578
+    bool Invalid;
+    StringRef Buffer = SM.getBufferData(SM.getFileID(StartLoc), &Invalid);
+    if (!Invalid) {
----------------
Unfortunately we can't get the buffer here, because for the preamble macros the 
files might change on disk after we build the preamble and we can end up 
reading a different version of the file. Which can in turn lead to crashes as 
the offsets obtained from the source locations can point outside the buffer for 
the corresponding file.

This is really annoying and generally the solution is to try find a different 
way to obtain the same information, e.g. by looking at what `MacroInfo` has 
available.
However, I don't know of a good workaround for this. Happy to look into ways of 
providing something close to a macro definition from `MacroInfo` or other 
sources, can scout for this tomorrow.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55250



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

Reply via email to