https://github.com/roubert created 
https://github.com/llvm/llvm-project/pull/182140

This is related to issue #178284, but when I read the code it looks to me as if 
setting `SetUpStaticAnalyzer = true` was simply forgotten here in this 
particular file, so fixing this wouldn't need to wait for any consensus around 
how all other cases ought to be handled.

>From 401468f1bd688b5a56ee79279f08c1fc0749d574 Mon Sep 17 00:00:00 2001
From: Fredrik Roubert <[email protected]>
Date: Wed, 18 Feb 2026 21:51:49 +0100
Subject: [PATCH] [include-cleaner] Explicitly ask to define __clang_analyzer__
 macro.

---
 clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index fefbfc3a9614d..746d9cdf8c975 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -12,6 +12,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
@@ -147,6 +148,8 @@ class Action : public clang::ASTFrontendAction {
     // in-development code.
     CI.getLangOpts().ModulesDeclUse = false;
     CI.getLangOpts().ModulesStrictDeclUse = false;
+    // Explicitly ask to define __clang_analyzer__ macro.
+    CI.getPreprocessorOpts().SetUpStaticAnalyzer = true;
     return true;
   }
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to