From: Ted Kremenek Date: Tue, 15 Jun 2010 00:55:40 +0000 (+0000) Subject: Change AnalysisConsumer to analyze functions created by instantiantiating a macro... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcd783d583d270b7ec1ec3e0fcf83cd93d30e381;p=clang Change AnalysisConsumer to analyze functions created by instantiantiating a macro. Fixes PR 7361. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105984 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp index 6a4727929e..0589008033 100644 --- a/lib/Frontend/AnalysisConsumer.cpp +++ b/lib/Frontend/AnalysisConsumer.cpp @@ -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. diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 8323c62390..1beb464cd1 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -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}} +