Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp @@ -107,12 +107,7 @@ return nullptr; // Retrieve the associated statement. - const Stmt *S = nullptr; - ProgramPoint ProgLoc = N->getLocation(); - if (Optional SP = ProgLoc.getAs()) { - S = SP->getStmt(); - } - + const Stmt *S = PathDiagnosticLocation::getStmt(N); if (!S) return nullptr; Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -909,12 +909,7 @@ return nullptr; // Retrieve the associated statement. - const Stmt *S = nullptr; - ProgramPoint ProgLoc = N->getLocation(); - if (Optional SP = ProgLoc.getAs()) { - S = SP->getStmt(); - } - + const Stmt *S = PathDiagnosticLocation::getStmt(N); if (!S) return nullptr; Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -524,12 +524,7 @@ // allocated, and only report a single path. PathDiagnosticLocation LocUsedForUniqueing; const ExplodedNode *AllocNode = getAllocationNode(N, AP.first, C); - const Stmt *AllocStmt = nullptr; - ProgramPoint P = AllocNode->getLocation(); - if (Optional Exit = P.getAs()) - AllocStmt = Exit->getCalleeContext()->getCallSite(); - else if (Optional PS = P.getAs()) - AllocStmt = PS->getStmt(); + const Stmt *AllocStmt = PathDiagnosticLocation::getStmt(AllocNode); if (AllocStmt) LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocStmt, Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -2094,12 +2094,7 @@ const MemRegion *Region = nullptr; std::tie(AllocNode, Region) = getAllocationSite(N, Sym, C); - ProgramPoint P = AllocNode->getLocation(); - const Stmt *AllocationStmt = nullptr; - if (Optional Exit = P.getAs()) - AllocationStmt = Exit->getCalleeContext()->getCallSite(); - else if (Optional SP = P.getAs()) - AllocationStmt = SP->getStmt(); + const Stmt *AllocationStmt = PathDiagnosticLocation::getStmt(AllocNode); if (AllocationStmt) LocUsedForUniqueing = PathDiagnosticLocation::createBegin(AllocationStmt, C.getSourceManager(), @@ -2626,22 +2621,7 @@ if (!RS) return nullptr; - const Stmt *S = nullptr; - const char *Msg = nullptr; - StackHintGeneratorForSymbol *StackHint = nullptr; - - // Retrieve the associated statement. - ProgramPoint ProgLoc = N->getLocation(); - if (Optional SP = ProgLoc.getAs()) { - S = SP->getStmt(); - } else if (Optional Exit = ProgLoc.getAs()) { - S = Exit->getCalleeContext()->getCallSite(); - } else if (Optional Edge = ProgLoc.getAs()) { - // If an assumption was made on a branch, it should be caught - // here by looking at the state transition. - S = Edge->getSrc()->getTerminator(); - } - + const Stmt *S = PathDiagnosticLocation::getStmt(N); if (!S) return nullptr; @@ -2649,6 +2629,8 @@ // (__attribute__((cleanup))). // Find out if this is an interesting point and what is the kind. + const char *Msg = nullptr; + StackHintGeneratorForSymbol *StackHint = nullptr; if (Mode == Normal) { if (isAllocated(RS, RSPrev, S)) { Msg = "Memory is allocated"; Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -325,10 +325,7 @@ // Retrieve the associated statement. const Stmt *S = TrackedNullab->getNullabilitySource(); if (!S) { - ProgramPoint ProgLoc = N->getLocation(); - if (Optional SP = ProgLoc.getAs()) { - S = SP->getStmt(); - } + S = PathDiagnosticLocation::getStmt(N); } if (!S) Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -2418,12 +2418,7 @@ // FIXME: This will crash the analyzer if an allocation comes from an // implicit call (ex: a destructor call). // (Currently there are no such allocations in Cocoa, though.) - const Stmt *AllocStmt = nullptr; - ProgramPoint P = AllocNode->getLocation(); - if (Optional Exit = P.getAs()) - AllocStmt = Exit->getCalleeContext()->getCallSite(); - else - AllocStmt = P.castAs().getStmt(); + const Stmt *AllocStmt = PathDiagnosticLocation::getStmt(AllocNode); assert(AllocStmt && "Cannot find allocation statement"); PathDiagnosticLocation AllocLocation =