[PATCH] D122315: [clangd] Retain main file fixes attached to diags from preamble

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 09:04:16 PDT 2022


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


================
Comment at: clang-tools-extra/clangd/Diagnostics.cpp:68
     return true;
   // Fixes are always in the main file.
   if (!D.Fixes.empty())
----------------
update comment: Fixes are only added if the fix or diagnostics is in the main file.


================
Comment at: clang-tools-extra/clangd/Diagnostics.cpp:705
 
   bool InsideMainFile = isInsideMainFile(Info);
   SourceManager &SM = Info.getSourceManager();
----------------
I think this can now be inlined to the one place it's used


================
Comment at: clang-tools-extra/clangd/Diagnostics.cpp:724
+    // No point in generating fixes, if the diagnostic is for a different file.
+    if (!LastDiag->InsideMainFile)
       return false;
----------------
Note that this may still miss some cases, e.g. if we had a diagnostic inside a template instantiation with a fix in the current file. tryMoveToMainFile has not been called yet, so LastDiag->InsideMainFile would be false.

I don't have a great idea about what to do about this, nor does it seem that important...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122315



More information about the cfe-commits mailing list