[clang] [clang-tools-extra] [clangd][clang-tidy] Factor out mergeFixits() logic and reuse it in clangd (PR #208682)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 13 04:19:25 PDT 2026


================
@@ -803,17 +803,26 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
       }
       // Otherwise, follow clang's behavior: no fixits in macros.
       if (FixIt.RemoveRange.getBegin().isMacroID() ||
-          FixIt.RemoveRange.getEnd().isMacroID())
+          FixIt.RemoveRange.getEnd().isMacroID() ||
+          !isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
         return false;
+    }
+    llvm::SmallVector<FixItHint, 4> MergedFixIts;
----------------
zeyi2 wrote:

Is there any specific reason we need 4 here?

In https://llvm.org/doxygen/classllvm_1_1SmallVector.html#details:

> In the absence of a well-motivated choice for the number of inlined elements N, it is recommended to use SmallVector<T> (that is, omitting the N).

https://github.com/llvm/llvm-project/pull/208682


More information about the cfe-commits mailing list