Predefine the '__clang_analyzer__' macro when using '-analyze'.

llvm-svn: 104742
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index f1e9819..2b35c8e 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -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);
 }