Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -592,6 +592,11 @@ if (!Opts->AnalyzeAll && !SM.isWrittenInMainFile(SL)) { if (SL.isInvalid() || SM.isInSystemHeader(SL)) return AM_None; + // Check if the definition of the function declaration has a body. + // Return the current analysis mode if the definition is in the main file. + if (D->hasBody()) + if (SM.isInMainFile(D->getBody()->getLocStart())) + 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}} +}