Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp =================================================================== --- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -372,40 +372,41 @@ if (!Diags.empty()) SM = &(*(*Diags.begin())->path.begin())->getLocation().getManager(); - - for (std::vector::iterator DI = Diags.begin(), - DE = Diags.end(); DI != DE; ++DI) { + auto AddPieceFID = [&FM, &Fids, SM](const PathDiagnosticPiece *Piece)->void { + AddFID(FM, Fids, SM, Piece->getLocation().asLocation()); + ArrayRef Ranges = Piece->getRanges(); + for (const SourceRange &Range : Ranges) { + AddFID(FM, Fids, SM, Range.getBegin()); + AddFID(FM, Fids, SM, Range.getEnd()); + } + }; - const PathDiagnostic *D = *DI; + for (const PathDiagnostic *D : Diags) { SmallVector WorkList; WorkList.push_back(&D->path); while (!WorkList.empty()) { - const PathPieces &path = *WorkList.pop_back_val(); - - for (PathPieces::const_iterator I = path.begin(), E = path.end(); I != E; - ++I) { - const PathDiagnosticPiece *piece = I->getPtr(); - AddFID(FM, Fids, SM, piece->getLocation().asLocation()); - ArrayRef Ranges = piece->getRanges(); - for (ArrayRef::iterator I = Ranges.begin(), - E = Ranges.end(); I != E; ++I) { - AddFID(FM, Fids, SM, I->getBegin()); - AddFID(FM, Fids, SM, I->getEnd()); - } + const PathPieces &Path = *WorkList.pop_back_val(); + + for (const auto &Iter : Path) { + const PathDiagnosticPiece *Piece = Iter.getPtr(); + AddPieceFID(Piece); + + if (const PathDiagnosticCallPiece *Call = + dyn_cast(Piece)) { + if (IntrusiveRefCntPtr + CallEnterWithin = Call->getCallEnterWithinCallerEvent()) + AddPieceFID(CallEnterWithin.getPtr()); - if (const PathDiagnosticCallPiece *call = - dyn_cast(piece)) { - IntrusiveRefCntPtr - callEnterWithin = call->getCallEnterWithinCallerEvent(); - if (callEnterWithin) - AddFID(FM, Fids, SM, callEnterWithin->getLocation().asLocation()); + if (IntrusiveRefCntPtr + CallEnterEvent = Call->getCallEnterEvent()) + AddPieceFID(CallEnterEvent.getPtr()); - WorkList.push_back(&call->path); + WorkList.push_back(&Call->path); } else if (const PathDiagnosticMacroPiece *macro = - dyn_cast(piece)) { + dyn_cast(Piece)) { WorkList.push_back(¯o->subPieces); } } Index: test/Analysis/diagnostics/Inputs/include/SomeMacro.def =================================================================== --- /dev/null +++ test/Analysis/diagnostics/Inputs/include/SomeMacro.def @@ -0,0 +1 @@ +SOME_MACRO Index: test/Analysis/diagnostics/Inputs/include/Something.h =================================================================== --- /dev/null +++ test/Analysis/diagnostics/Inputs/include/Something.h @@ -0,0 +1,9 @@ +void clang_analyzer_warnIfReached(); + +class Something { +public: + Something () { } + void run() { + clang_analyzer_warnIfReached(); + } +}; Index: test/Analysis/diagnostics/plist-diagnostics-include-check.cpp =================================================================== --- /dev/null +++ test/Analysis/diagnostics/plist-diagnostics-include-check.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -analyzer-output=plist-multi-file -o plist.xml %s + +#include "Inputs/include/Something.h" + +void foo() { + Something() +#define SOME_MACRO .run(); +#include "Inputs/include/SomeMacro.def" +}