Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -589,9 +589,18 @@ // - System headers: don't run any checks. SourceManager &SM = Ctx->getSourceManager(); SourceLocation SL = SM.getExpansionLoc(D->getLocation()); + + // Check if the definition of the function declaration has a body. + // Update the location if function body is found. + if (D->hasBody()) + SL = D->getBody()->getLocStart(); + if (!Opts->AnalyzeAll && !SM.isWrittenInMainFile(SL)) { if (SL.isInvalid() || SM.isInSystemHeader(SL)) return AM_None; + // Return the current analysis mode if the location is in the main file. + if (SM.isInMainFile(SL)) + return Mode; return Mode & ~AM_Path; } Index: test/Analysis/test-include.h =================================================================== --- test/Analysis/test-include.h +++ test/Analysis/test-include.h @@ -0,0 +1 @@ +void test(int * data); Index: test/Analysis/test-include.c =================================================================== --- test/Analysis/test-include.c +++ test/Analysis/test-include.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +#include "test-include.h" +void test(int * data) { + data = 0; + *data = 1; // expected-warning{{Dereference of null pointer}} +}