forked from OSchip/llvm-project
[static analyzer] Define __clang_analyzer__ macro in driver
Differential Revision: https://reviews.llvm.org/D67938 llvm-svn: 372679
This commit is contained in:
parent
a4dd98f2e9
commit
fbd13570b0
|
@ -3896,8 +3896,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
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
|
||||
|
|
|
@ -990,10 +990,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
|||
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__");
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// RUN: %clang --analyze %s
|
||||
|
||||
#ifndef __clang_analyzer__
|
||||
#error __clang_analyzer__ not defined
|
||||
#endif
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue