summaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/BugReporter.cpp
Commit message (Collapse)AuthorAge
...
* Make helper functions static.Benjamin Kramer2013-05-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182589 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate edges] fix type that was causing the wrong path piece to ↵Ted Kremenek2013-05-23
| | | | | | get removed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182562 91177308-0d34-0410-b5e6-96231b3b80d8
* Insert explicit casts to try appease overload resolution in the buildbotsPete Cooper2013-05-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182514 91177308-0d34-0410-b5e6-96231b3b80d8
* Use scope-resolution operator to hopefully unbreak Windows builds.Ted Kremenek2013-05-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182509 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplifiy code using return value of erase().Ted Kremenek2013-05-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182506 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] remove redundant adjacent "events" with the same ↵Ted Kremenek2013-05-22
| | | | | | | | text. Fixes <rdar://problem/13949982> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182505 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate edges] remove puny edges on the same line that span less ↵Ted Kremenek2013-05-22
| | | | | | | | | | | than 3 columns. These are legitimate control-flow edges, but visually they add no value. Implements <rdar://problem/13941325>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182502 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unnecessary assignment.Ted Kremenek2013-05-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182501 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate edges] prune out extra edges to a subexpression where we ↵Ted Kremenek2013-05-21
| | | | | | | | dive-in and out of a subexpression. Fixes <rdar://problem/13941891>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182426 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternated edges] look through expressions just like Environment ↵Ted Kremenek2013-05-21
| | | | | | does. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182425 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] optimize edges for ObjC fast enumeration loops.Ted Kremenek2013-05-21
| | | | | | Fixes <rdar://problem/13942300>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182342 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] New edges: include an edge to the end-of-path location.Jordan Rose2013-05-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182188 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Add a debug dump for PathPieces, a list of PathDiagnosticPieces.Jordan Rose2013-05-18
| | | | | | Originally implemented by Ted, extended by me. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182186 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[analyzer; alternate edges] improve support for edges with ↵Jordan Rose2013-05-18
| | | | | | | | | | | | | PseudoObjectExprs." Ted and I spent a long time discussing this today and found out that neither the existing code nor the new code was doing what either of us thought it was, which is never good. The good news is we found a much simpler way to fix the motivating test case (an ObjCSubscriptExpr). This reverts r182083, but pieces of it will come back in subsequent commits. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182185 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] improve support for edges with PseudoObjectExprs.Ted Kremenek2013-05-17
| | | | | | | | | | | | | | | | | | This optimizes some spurious edges resulting from PseudoObjectExprs. This required far more changes than I anticipated. The current ParentMap does not record any hierarchy information between a PseudoObjectExpr and its *semantic* expressions that may be wrapped in OpaqueValueExprs, which are the expressions actually laid out in the CFG. This means the arrow pruning logic could not map from an expression to its containing PseudoObjectExprs. To solve this, this patch adds a variant of ParentMap that returns the "semantic" parentage of expressions (essentially as they are viewed by the CFG). This alternate ParentMap is then used by the arrow reducing logic to identify edges into pseudo object expressions, and then eliminate them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182083 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] treat 'if' statements the same way we do as ↵Ted Kremenek2013-05-17
| | | | | | | | | 'for' or 'while'. This means adding an extra edge from the 'if' to the condition, which aesthetically looks more pleasing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182079 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] don't add an edge incoming from the start of a ↵Ted Kremenek2013-05-17
| | | | | | | | function for a nested call. This matches what we do with the first stack frame. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182078 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Add an option to use the last location in the main source file as ↵Anna Zaks2013-05-16
| | | | | | | | | | | | | the report location. Previously, we’ve used the last location of the analyzer issue path as the location of the report. This might not provide the best user experience, when one analyzer a source file and the issue appears in the header. Introduce an option to use the last location of the path that is in the main source file as the report location. New option can be enabled with -analyzer-config report-in-main-source-file=true. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182058 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] for "loop back" edges add back the extra edge ↵Ted Kremenek2013-05-09
| | | | | | to the closing '}' git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181505 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate arrows] adapt 'for' loop aesthetic cleanup to 'while' loops.Ted Kremenek2013-05-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181504 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] insert an extra edge for 'for' statements to ↵Ted Kremenek2013-05-08
| | | | | | conditions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181385 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate edges] edges from subexpressions of "?:" are important ↵Ted Kremenek2013-05-08
| | | | | | to retain git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181384 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate arrows] Fix inconsistencies in recorded location context ↵Ted Kremenek2013-05-07
| | | | | | when handling interprocedural paths. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181362 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] add back recording whether we visited the first ↵Ted Kremenek2013-05-07
| | | | | | edge. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181361 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] remove pruning of loop diagnostics.Ted Kremenek2013-05-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181360 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] include logical '||' and '&&' as anchors for edges.Ted Kremenek2013-05-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181359 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] include an edge from the "break" or "continue"Ted Kremenek2013-05-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181358 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] the extra edge to the closing '}' in a loop ↵Ted Kremenek2013-05-07
| | | | | | adds no value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181357 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] the initializer of a ForStmt isn't interesting ↵Ted Kremenek2013-05-07
| | | | | | either. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181356 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] The ForStmt increment is not a critical anchor ↵Ted Kremenek2013-05-07
| | | | | | for arrows. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181333 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] simplify optimization rules to look at ↵Ted Kremenek2013-05-07
| | | | | | control-flow conditions to prune edges. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181292 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] use the terminator condition as the location ↵Ted Kremenek2013-05-07
| | | | | | for 'entering loop body' git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181291 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] provide a diagnostic for entering a loop for ↵Ted Kremenek2013-05-07
| | | | | | the first time. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181282 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate arrows] don't increment the path iterator when we just ↵Ted Kremenek2013-05-06
| | | | | | | | | deleted the next iterator. This is an optimization. It is possible that by deleting the next edge we will pattern match again at the current spot. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181256 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate edges] start experimenting with control flow "barriers" ↵Ted Kremenek2013-05-04
| | | | | | to prevent an edge being optimized away. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181088 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate edges] ignore parentheses when determining edge levels.Ted Kremenek2013-05-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181087 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] - eliminate unnecessary edges where between ↵Ted Kremenek2013-05-04
| | | | | | parents and subexpressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181086 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] - merge control edges where we descend to a ↵Ted Kremenek2013-05-04
| | | | | | subexpression and pop back out. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181085 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer; alternate edges] prune edges whose end/begin locations have the ↵Ted Kremenek2013-05-04
| | | | | | | | | | | | | | | | | same statement parents. This change required some minor changes to LocationContextMap to have it map from PathPieces to LocationContexts instead of PathDiagnosticCallPieces to LocationContexts. These changes are in the other diagnostic generation logic as well, but are functionally equivalent. Interestingly, this optimize requires delaying "cleanUpLocation()" until later; possibly after all edges have been optimized. This is because we need PathDiagnosticLocations to refer to the semantic entity (e.g. a statement) as long as possible. Raw source locations tell us nothing about the semantic relationship between two locations in a path. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181084 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer;alternate edges] - add in events (loop iterations, etc)Ted Kremenek2013-05-04
| | | | | | | These were being dropped due a transcription mistake from the original algorithm. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181083 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Start hacking up alternate control-flow edge generation. WIP. ↵Ted Kremenek2013-05-03
| | | | | | Not guaranteed to do anything useful yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181040 91177308-0d34-0410-b5e6-96231b3b80d8
* Make cleanUpLocation() a self-contained function.Ted Kremenek2013-05-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180986 91177308-0d34-0410-b5e6-96231b3b80d8
* Re-apply 180974 with the build error fixed. This was the resultTed Kremenek2013-05-03
| | | | | | of a weird merge error with git. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180981 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Change LocationContextMap to be a temporary instead of shared ↵Rafael Espindola2013-05-03
| | | | | | | | variable in BugReporter." This reverts commit 180974. It broke the build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180979 91177308-0d34-0410-b5e6-96231b3b80d8
* Change LocationContextMap to be a temporary instead of shared variable in ↵Ted Kremenek2013-05-02
| | | | | | | | | | | | | BugReporter. BugReporter is used to process ALL bug reports. By using a shared map, we are having mappings from different PathDiagnosticPieces to LocationContexts well beyond the point where we are processing a given report. This state is inherently error prone, and is analogous to using a global variable. Instead, just create a temporary map, one per report, and when we are done with it we throw it away. No extra state. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180974 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[analyzer] Change PathPieces to be a wrapper around an ilist of ↵Ted Kremenek2013-04-29
| | | | | | | | (through indirection) PathDiagnosticPieces." Jordan rightly pointed out that we can do the same with std::list. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180746 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Change PathPieces to be a wrapper around an ilist of (through ↵Ted Kremenek2013-04-29
| | | | | | | | | | | | | | | | | | | | | | | indirection) PathDiagnosticPieces. Much of this patch outside of PathDiagnostics.h are just minor syntactic changes due to the return type for operator* and the like changing for the iterator, so the real focus should be on PathPieces itself. This change is motivated so that we can do efficient insertion and removal of individual pieces from within a PathPiece, just like this was a kind of "IR" for static analyzer diagnostics. We currently implement path transformations by iterating over an entire PathPiece and making a copy. This isn't very natural for some algorithms. We use an ilist here instead of std::list because we want operations to rip out/insert nodes in place, just like IR manipulation. This isn't being used yet, but opens the door for more powerful transformation algorithms on diagnostic paths. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180741 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Refactor BugReport::getLocation and ↵Anna Zaks2013-04-23
| | | | | | | | | | | | | | | PathDiagnosticLocation::createEndOfPath for greater code reuse The 2 functions were computing the same location using different logic (each one had edge case bugs that the other one did not). Refactor them to rely on the same logic. The location of the warning reported in text/command line output format will now match that of the plist file. There is one change in the plist output as well. When reporting an error on a BinaryOperator, we use the location of the operator instead of the beginning of the BinaryOperator expression. This matches our output on command line and looks better in most cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180165 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Don't emit extra context arrow after returning from an inlined call.Jordan Rose2013-04-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this code int getZero() { return 0; } void test() { int problem = 1 / getZero(); // expected-warning {{Division by zero}} } we generate these arrows: +-----------------+ | v int problem = 1 / getZero(); ^ | +---+ where the top one represents the control flow up to the first call, and the bottom one represents the flow to the division.* It turns out, however, that we were generating the top arrow twice, as if attempting to "set up context" after we had already returned from the call. This resulted in poor highlighting in Xcode. * Arguably the best location for the division is the '/', but that's a different problem. <rdar://problem/13326040> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179350 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] When creating a trimmed graph, preserve whether a node is a sink.Jordan Rose2013-04-06
| | | | | | | | | | | | | | This is important because sometimes two nodes are identical, except the second one is a sink. This bug has probably been around for a while, but it wouldn't have been an issue in the old report graph algorithm. I'm ashamed to say I actually looked at this the first time around and thought it would never be a problem...and then didn't include an assertion to back that up. PR15684 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178944 91177308-0d34-0410-b5e6-96231b3b80d8