[cfe-commits] r104742 - in /cfe/trunk: lib/Frontend/InitPreprocessor.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Wed May 26 14:36:55 PDT 2010
Author: kremenek
Date: Wed May 26 16:36:54 2010
New Revision: 104742
URL: http://llvm.org/viewvc/llvm-project?rev=104742&view=rev
Log:
Predefine the '__clang_analyzer__' macro when using '-analyze'.
Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=104742&r1=104741&r2=104742&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed May 26 16:36:54 2010
@@ -428,6 +428,11 @@
if (FEOpts.ProgramAction == frontend::RewriteObjC)
Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))");
+
+ // Define a macro that exists only when using the static analyzer.
+ if (FEOpts.ProgramAction == frontend::RunAnalysis)
+ Builder.defineMacro("__clang_analyzer__");
+
// Get other target #defines.
TI.getTargetDefines(LangOpts, Builder);
}
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=104742&r1=104741&r2=104742&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed May 26 16:36:54 2010
@@ -8,6 +8,10 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s
+#ifndef __clang_analyzer__
+#error __clang__analyzer__ not defined
+#endif
+
typedef struct objc_ivar *Ivar;
typedef struct objc_selector *SEL;
typedef signed char BOOL;
More information about the cfe-commits
mailing list