[PATCH] D67938: [static analyzer] Define __clang_analyzer__ macro in driver
Jan Korous via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 17:32:13 PDT 2019
This revision was automatically updated to reflect the committed changes.
jkorous marked 2 inline comments as done.
Closed by commit rL372679: [static analyzer] Define __clang_analyzer__ macro in driver (authored by jkorous, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D67938?vs=221445&id=221447#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67938/new/
https://reviews.llvm.org/D67938
Files:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Analysis/misc-driver.c
cfe/trunk/test/Analysis/misc-ps.m
Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -990,10 +990,6 @@
else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
Builder.defineMacro("__SSP_ALL__", "3");
- // Define a macro that exists only when using the static analyzer.
- if (FEOpts.ProgramAction == frontend::RunAnalysis)
- Builder.defineMacro("__clang_analyzer__");
-
if (LangOpts.FastRelaxedMath)
Builder.defineMacro("__FAST_RELAXED_MATH__");
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3896,8 +3896,10 @@
if (Args.hasArg(options::OPT_municode))
CmdArgs.push_back("-DUNICODE");
- if (isa<AnalyzeJobAction>(JA))
+ if (isa<AnalyzeJobAction>(JA)) {
RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
+ CmdArgs.push_back("-D__clang_analyzer__");
+ }
// Enable compatilibily mode to avoid analyzer-config related errors.
// Since we can't access frontend flags through hasArg, let's manually iterate
Index: cfe/trunk/test/Analysis/misc-driver.c
===================================================================
--- cfe/trunk/test/Analysis/misc-driver.c
+++ cfe/trunk/test/Analysis/misc-driver.c
@@ -0,0 +1,5 @@
+// RUN: %clang --analyze %s
+
+#ifndef __clang_analyzer__
+#error __clang_analyzer__ not defined
+#endif
Index: cfe/trunk/test/Analysis/misc-ps.m
===================================================================
--- cfe/trunk/test/Analysis/misc-ps.m
+++ cfe/trunk/test/Analysis/misc-ps.m
@@ -2,10 +2,6 @@
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
-#ifndef __clang_analyzer__
-#error __clang_analyzer__ not defined
-#endif
-
typedef struct objc_ivar *Ivar;
typedef struct objc_selector *SEL;
typedef signed char BOOL;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67938.221447.patch
Type: text/x-patch
Size: 2389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190924/11d30ccf/attachment.bin>
More information about the llvm-commits
mailing list