[PATCH] D55250: [clangd] Enhance macro hover to see full definition

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 5 10:40:31 PST 2018


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





More information about the cfe-commits mailing list