]> granicus.if.org Git - clang/commitdiff
Change AnalysisConsumer to analyze functions created by instantiantiating a macro...
authorTed Kremenek <kremenek@apple.com>
Tue, 15 Jun 2010 00:55:40 +0000 (00:55 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 15 Jun 2010 00:55:40 +0000 (00:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105984 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/AnalysisConsumer.cpp
test/Analysis/misc-ps.m

index 6a4727929e7a9b0d13b32d58c4b1c2b9c8a09eb2..05890080339791983b51c0e8b23f0978e116e134 100644 (file)
@@ -278,8 +278,9 @@ void AnalysisConsumer::HandleCode(Decl *D, Stmt* Body, Actions& actions) {
 
   // Don't run the actions on declarations in header files unless
   // otherwise specified.
-  if (!Opts.AnalyzeAll &&
-      !Ctx->getSourceManager().isFromMainFile(D->getLocation()))
+  SourceManager &SM = Ctx->getSourceManager();
+  SourceLocation SL = SM.getInstantiationLoc(D->getLocation());
+  if (!Opts.AnalyzeAll && !SM.isFromMainFile(SL))
     return;
 
   // Clear the AnalysisManager of old AnalysisContexts.
index 8323c62390e84214e1eec06053900c255e20dc6c..1beb464cd1c0b3ca3481c2c7ce6d182fed7e3c43 100644 (file)
@@ -971,3 +971,13 @@ void r7979430(id x) {
   @synchronized(x) {}
 }
 
+//===----------------------------------------------------------------------===
+// PR 7361 - Test that functions wrapped in macro instantiations are analyzed.
+//===----------------------------------------------------------------------===
+#define MAKE_TEST_FN() \
+  void test_pr7361 (char a) {\
+    char* b = 0x0;  *b = a;\
+  }
+
+MAKE_TEST_FN() // expected-warning{{null pointer}}
+