diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-11-15 02:07:23 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-11-15 02:07:23 +0000 |
commit | 368f3b070e8cb657a65bfa443d60256676d269e7 (patch) | |
tree | b2e99b170560985c2cbd6be5df2a7eea01adf713 /lib/StaticAnalyzer/Core/PathDiagnostic.cpp | |
parent | 350aea7b794e4824f61d92f96140fbdcc0393588 (diff) |
[analyzer] Make sure calls in synthesized functions have valid path locations.
We do this by using the "most recent" good location: if a synthesized
function 'A' calls another function 'B', the path notes for the call to 'B'
will be placed at the same location as the path note for calling 'A'.
Similarly, the call to 'A' will have a note saying "Entered call from...",
and now we just don't emit that (since the user doesn't have a body to look
at anyway).
Previously, we were doing this for the "Calling..." notes, but not for the
"Entered call from..." or "Returning to caller". This caused a crash when
the path entered and then exiting a call within a synthesized body.
<rdar://problem/12657843>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168019 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 0f48d1e1c7..2ebadcaa23 100644 --- a/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -790,11 +790,14 @@ PathDiagnosticCallPiece::getCallEnterEvent() const { StringRef msg = Out.str(); if (msg.empty()) return 0; + assert(callEnter.asLocation().isValid()); return new PathDiagnosticEventPiece(callEnter, msg); } IntrusiveRefCntPtr<PathDiagnosticEventPiece> PathDiagnosticCallPiece::getCallEnterWithinCallerEvent() const { + if (!callEnterWithin.asLocation().isValid()) + return 0; SmallString<256> buf; llvm::raw_svector_ostream Out(buf); if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(Caller)) @@ -819,6 +822,7 @@ PathDiagnosticCallPiece::getCallExitEvent() const { Out << "Returning from '" << *ND << "'"; else Out << "Returning to caller"; + assert(callReturn.asLocation().isValid()); return new PathDiagnosticEventPiece(callReturn, Out.str()); } |