From 7e3aba1ae9545582b73877693924d11d8401d464 Mon Sep 17 00:00:00 2001 From: Jan Korous Date: Tue, 24 Sep 2019 03:21:22 +0000 Subject: [PATCH] Revert "[static analyzer] Define __clang_analyzer__ macro in driver" This reverts commit fbd13570b0d5f92ef2cf6bcfe7cc2f6178500187. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372687 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains/Clang.cpp | 4 +--- lib/Frontend/InitPreprocessor.cpp | 4 ++++ test/Analysis/misc-driver.c | 5 ----- test/Analysis/misc-ps.m | 4 ++++ 4 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 test/Analysis/misc-driver.c diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 6453af73b0..aa17efbee3 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -3896,10 +3896,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_municode)) CmdArgs.push_back("-DUNICODE"); - if (isa(JA)) { + if (isa(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 diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index 9da37e0a44..95d9f62c60 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -990,6 +990,10 @@ 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__"); diff --git a/test/Analysis/misc-driver.c b/test/Analysis/misc-driver.c deleted file mode 100644 index f9e7fe373d..0000000000 --- a/test/Analysis/misc-driver.c +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: %clang --analyze %s - -#ifndef __clang_analyzer__ -#error __clang_analyzer__ not defined -#endif diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 1cfd2eb1ca..9a75cfd87b 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -2,6 +2,10 @@ // 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; -- 2.40.0