diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-08-01 22:16:30 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-08-01 22:16:30 +0000 |
commit | 5fbe7f97664dc2024252c03729198eb4b958a03c (patch) | |
tree | 1e3c6f972c5b5ea7dc1052da47295d4adc2df4a5 /clang/lib/StaticAnalyzer/Core/BugReporter.cpp | |
parent | 3e8c33cff5c28911b8ee9cd5f5d8de2c4362c009 (diff) | |
download | bcm5719-llvm-5fbe7f97664dc2024252c03729198eb4b958a03c.tar.gz bcm5719-llvm-5fbe7f97664dc2024252c03729198eb4b958a03c.zip |
[analyzer] Silently drop all reports within synthesized bodies.
Much of our diagnostic machinery is set up to assume that the report
end path location is valid. Moreover, the user may be quite confused
when something goes wrong in our BodyFarm-synthesized function bodies,
which may be simplified or modified from the real implementations.
Rather than try to make this all work somehow, just drop the report so
that we don't try to go on with an invalid source location.
Note that we still handle reports whose /paths/ go through invalid
locations, just not those that are reported in one.
We do have to be careful not to lose warnings because of this.
The impetus for this change was an autorelease being processed within
the synthesized body, and there may be other possible issues that are
worth reporting in some way. We'll take these as they come, however.
<rdar://problem/14611722>
llvm-svn: 187624
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index d8d54fdba5b..aaa8c8d0ca0 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -3202,6 +3202,22 @@ void BugReporter::Register(BugType *BT) { } void BugReporter::emitReport(BugReport* R) { + // Defensive checking: throw the bug away if it comes from a BodyFarm- + // generated body. We do this very early because report processing relies + // on the report's location being valid. + if (const ExplodedNode *E = R->getErrorNode()) { + const LocationContext *LCtx = E->getLocationContext(); + if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) + return; + } + + bool ValidSourceLoc = R->getLocation(getSourceManager()).isValid(); + assert(ValidSourceLoc); + // If we mess up in a release build, we'd still prefer to just drop the bug + // instead of trying to go on. + if (!ValidSourceLoc) + return; + // Compute the bug report's hash to determine its equivalence class. llvm::FoldingSetNodeID ID; R->Profile(ID); |