summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] Simplify RetainCountChecker's handling of dead symbols.Jordan Rose2012-12-061-29/+24
| | | | | | | | | Previously we made three passes over the set of dead symbols, and removed them from the state /twice/. Now we combine the autorelease pass and the symbol death pass, and only have to remove the bindings for the symbols that leaked. llvm-svn: 169527
* [analyzer] Use a smarter algorithm to find the last block in an inlined call.Jordan Rose2012-12-061-18/+3
| | | | | | | | | Previously we would search for the last statement, then back up to the entrance of the block that contained that statement. Now, while we're scanning for the statement, we just keep track of which blocks are being exited (in reverse order). llvm-svn: 169526
* [analyzer] Use optimized assumeDual for branches.Jordan Rose2012-12-061-6/+12
| | | | | | | This doesn't seem to make much of a difference in practice, but it does have the potential to avoid a trip through the constraint manager. llvm-svn: 169524
* [analyzer] Aggressively cut back on the canonicalization in RegionStore.Jordan Rose2012-12-061-31/+37
| | | | | | | | | | | | Whenever we touch a single bindings cluster multiple times, we can delay canonicalizing it until the final access. This has some interesting implications, in particular that we shouldn't remove an /empty/ cluster from the top-level map until canonicalization. This is good for a 2% speedup or so on the test case in <rdar://problem/12810842> llvm-svn: 169523
* [analyzer] Remove bindExprAndLocation, which does extra work for no gain.Jordan Rose2012-12-063-90/+7
| | | | | | | | This feature was probably intended to improve diagnostics, but was currently only used when dumping the Environment. It shows what location a given value was loaded from, e.g. when evaluating an LValueToRValue cast. llvm-svn: 169522
* Only provide explicit getCapturedRegion() and getOriginalRegion() from ↵Ted Kremenek2012-12-064-4/+4
| | | | | | | | referenced_vars_iterator. This is a nice conceptual cleanup. llvm-svn: 169480
* Pull logic to map from VarDecl* to captured region using a helper function. ↵Ted Kremenek2012-12-061-17/+24
| | | | | | WIP. llvm-svn: 169479
* Use 'getOriginalRegion()' rather than going through the logic to recreate it.Ted Kremenek2012-12-061-3/+1
| | | | llvm-svn: 169478
* Add missing virtual destructors reported by -Wnon-virtual-dtor.Daniel Jasper2012-12-051-0/+2
| | | | llvm-svn: 169365
* [analyzer] Implement an opt-in variant of direct ivar assignment.Anna Zaks2012-12-052-9/+57
| | | | | | | This will only check the direct ivar assignments in the annotated methods. llvm-svn: 169349
* Alphabetize source files, just like they have been before.Ted Kremenek2012-12-041-1/+1
| | | | llvm-svn: 169318
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-0484-217/+212
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Add raw_ostream include to pacify MSVC.Benjamin Kramer2012-12-011-0/+1
| | | | llvm-svn: 169097
* Include pruning and general cleanup.Benjamin Kramer2012-12-0123-1/+23
| | | | llvm-svn: 169095
* Don't include Type.h in DeclarationName.h.Benjamin Kramer2012-12-013-0/+3
| | | | | | Recursively prune some includes. llvm-svn: 169094
* Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't ↵Benjamin Kramer2012-12-0112-11/+23
| | | | | | | | | pull in all the generated Attr code. Required to pull some functions out of line, but this shouldn't have a perf impact. No functionality change. llvm-svn: 169092
* Correctly handle IntegralToBool casts in C++ in the static analyzer. Fixes ↵Ted Kremenek2012-11-291-2/+8
| | | | | | <rdar://problem/12759044>. llvm-svn: 168843
* Remove workaround in RegionStore in r168741 since it is handled more ↵Ted Kremenek2012-11-281-10/+8
| | | | | | generally by r168757. llvm-svn: 168774
* Fix another false positive due to a CXX temporary object appearing in a C ↵Ted Kremenek2012-11-281-2/+4
| | | | | | | | | | | initializer. The stop-gap here is to just drop such objects when processing the InitListExpr. We still need a better solution. Fixes <rdar://problem/12755044>. llvm-svn: 168757
* Provide stop-gap solution to crash reported in PR 14436.Ted Kremenek2012-11-271-8/+10
| | | | | | | | | | | | | This was also covered by <rdar://problem/12753384>. The static analyzer evaluates a CXXConstructExpr within an initializer expression and RegionStore doesn't know how to handle the resulting CXXTempObjectRegion that gets created. We need a better solution than just dropping the value, but we need to better understand how to implement the right semantics here. Thanks to Jordan for his help diagnosing the behavior here. llvm-svn: 168741
* [analyzer] Fix a crash reported in PR 14400.Anna Zaks2012-11-262-1/+3
| | | | | | | | The AllocaRegion did not have the superRegion (based on LocationContext) as part of it's hash. As a consequence, the AllocaRegions from different frames were uniqued to be the same region. llvm-svn: 168599
* Make helpers static/anonymous.Benjamin Kramer2012-11-221-2/+2
| | | | llvm-svn: 168500
* [analyzer] Fix a use-after-free introduced in r168019.Jordan Rose2012-11-151-4/+5
| | | | | | | | | | | | | | | | | | | | | | | In code like this: void foo() { bar(); baz(); } ...the location for the call to 'bar()' was being used as a backup location for the call to 'baz()'. This is fine unless the call to 'bar()' is deemed uninteresting and that part of the path deleted. (This looks like a logic error as well, but in practice the only way 'baz()' could have an invalid location is if the entire body of 'foo()' is synthesized, meaning the call to 'bar()' will be using the location of the call to 'foo()' anyway. Nevertheless, the new version better matches the intent of the code.) Found by Matt Beaumont-Gay using ASan. Thanks, Matt! llvm-svn: 168080
* [analyzer] Report leaks at the closing brace of a function body.Jordan Rose2012-11-153-13/+24
| | | | | | | | | | | | | | | | | | | | This fixes a few cases where we'd emit path notes like this: +---+ 1| v p = malloc(len); ^ |2 +---+ In general this should make path notes more consistent and more correct, especially in cases where the leak happens on the false branch of an if that jumps directly to the end of the function. There are a couple places where the leak is reported farther away from the cause; these are usually cases where there are several levels of nested braces before the end of the function. This still matches our current behavior for when there /is/ a statement after all the braces, though. llvm-svn: 168070
* [analyzer] StreamChecker: Remove now-unnecessary check::EndPath callback.Jordan Rose2012-11-151-46/+1
| | | | | | | Also, don't bother to stop tracking symbols in the return value, either. They are now properly considered live during checkDeadSymbols. llvm-svn: 168069
* [analyzer] MacOSKeychainAPIChecker: Remove now-unnecessary check::EndPath.Jordan Rose2012-11-151-75/+0
| | | | | | | Also, don't bother to stop tracking symbols in the return value, either. They are now properly considered live during checkDeadSymbols. llvm-svn: 168068
* [analyzer] MallocChecker: Remove now-unnecessary check::EndPath callback.Jordan Rose2012-11-151-29/+1
| | | | | | | Also, don't bother to stop tracking symbols in the return value, either. They are now properly considered live during checkDeadSymbols. llvm-svn: 168067
* [analyzer] Mark symbol values as dead in the environment.Jordan Rose2012-11-153-20/+37
| | | | | | | | | | | | | | This allows us to properly remove dead bindings at the end of the top-level stack frame, using the ReturnStmt, if there is one, to keep the return value live. This in turn removes the need for a check::EndPath callback in leak checkers. This does cause some changes in the path notes for leak checkers. Previously, a leak would be reported at the location of the closing brace in a function. Now, it gets reported at the last statement. This matches the way leaks are currently reported for inlined functions, but is less than ideal for both. llvm-svn: 168066
* [analyzer] Make sure calls in synthesized functions have valid path locations.Jordan Rose2012-11-152-10/+20
| | | | | | | | | | | | | | | | | | 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> llvm-svn: 168019
* [analyzer] Address Jordan's code review for r167813.Anna Zaks2012-11-131-20/+15
| | | | | | | This simplifies logic, fixes a bug, and adds a test case. Thanks Jordan! llvm-svn: 167868
* Fix a Malloc Checker FP by tracking return values from initWithCharacterAnna Zaks2012-11-131-20/+81
| | | | | | | | | | and other functions. When these functions return null, the pointer is not freed by them/ownership is not transfered. So we should allow the user to free the pointer by calling another function when the return value is NULL. llvm-svn: 167813
* [analyzer] Address Jordan's feedback for r167780.Anna Zaks2012-11-131-4/+5
| | | | llvm-svn: 167790
* [analyzer] Follow up to r167762 - precisely determine the adjustmentAnna Zaks2012-11-121-3/+13
| | | | | | | | | | | | | | | | | conditions. The adjustment is needed only in case of dynamic dispatch performed by the analyzer - when the runtime declaration is different from the static one. Document this explicitly in the code (by adding a helper). Also, use canonical Decls to avoid matching against the case where the definition is different from found declaration. This fix suppresses the testcase I added in r167762, so add another testcase to make sure we do test commit r167762. llvm-svn: 167780
* [analyzer] Fix a regression (from r 165079): compare canonical types.Anna Zaks2012-11-121-0/+2
| | | | | | | | | | | Suppresses a leak false positive (radar://12663777). In addition, we'll need to rewrite the adjustReturnValue() method not to return UnknownVal by default, but rather assert in cases we cannot handle. To make it possible, we need to correctly handle some of the edge cases we already know about. llvm-svn: 167762
* [analyzer] When invalidating symbolic offset regions, take fields into account.Jordan Rose2012-11-101-6/+63
| | | | | | | | | | | | | | | | | | | Previously, RegionStore was being VERY conservative in saying that because p[i].x and p[i].y have a concrete base region of 'p', they might overlap. Now, we check the chain of fields back up to the base object and check if they match. This only kicks in when dealing with symbolic offset regions because RegionStore's "base+offset" representation of concrete offset regions loses all information about fields. In cases where all offsets are concrete (s.x and s.y), RegionStore will already do the right thing, but mixing concrete and symbolic offsets can cause bindings to be invalidated that are known to not overlap (e.g. p[0].x and p[i].y). This additional refinement is tracked by <rdar://problem/12676180>. <rdar://problem/12530149> llvm-svn: 167654
* [analyzer] Check that the argument to CFMakeCollectable is non-NULL.Jordan Rose2012-11-072-10/+18
| | | | | | Patch by Sean McBride! llvm-svn: 167537
* [analyzer] Enhance docs for checker callbacks (esp. processRegionChanges).Jordan Rose2012-11-071-13/+28
| | | | | | No functionality change; this checker is only used for documentation. llvm-svn: 167522
* [analyzer] Add symbol escapes logic to the SimpleStreamChecker.Anna Zaks2012-11-061-1/+125
| | | | llvm-svn: 167439
* [analyzer] Remove isWithinInlined. It's been replaced with inTopFrame().Anna Zaks2012-11-061-1/+1
| | | | | | Thanks Jordan. llvm-svn: 167438
* [analyzer] Move convenience REGISTER_*_WITH_PROGRAMSTATE to CheckerContext.hJordan Rose2012-11-053-6/+9
| | | | | | | | | | | | As Anna pointed out, ProgramStateTrait.h is a relatively obscure header, and checker writers may not know to look there to add their own custom state. The base macro that specializes the template remains in ProgramStateTrait.h (REGISTER_TRAIT_WITH_PROGRAMSTATE), which allows the analyzer core to keep using it. llvm-svn: 167385
* StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp: Appease msvc.NAKAMURA Takumi2012-11-031-2/+2
| | | | | | 0 (as nullptr) is incompatible to pointer in type matching on msvc. llvm-svn: 167355
* [analyzer] Run remove dead on end of path.Anna Zaks2012-11-034-8/+65
| | | | | | | | | | | | | This will simplify checkers that need to register for leaks. Currently, they have to register for both: check dead and check end of path. I've modified the SymbolReaper to consider everything on the stack dead if the input StackLocationContext is 0. (This is a bit disruptive, so I'd like to flash out all the issues asap.) llvm-svn: 167352
* [analyzer] add LocationContext::inTopFrame() helper.Anna Zaks2012-11-031-7/+1
| | | | llvm-svn: 167351
* [analyzer] Refactor: Remove Pred from NodeBuilderContext.Anna Zaks2012-11-033-12/+12
| | | | | | Node builders should manage the nodes, not the context. llvm-svn: 167350
* [analyzer] Convert SimpleStreamChecker over to CallEvent.Jordan Rose2012-11-021-13/+23
| | | | llvm-svn: 167340
* [analyzer] CheckerDocumentation: Change examples for PreStmt and PostStmt.Jordan Rose2012-11-021-9/+9
| | | | llvm-svn: 167339
* [analyzer] Add some convenience accessors to CallEvent, and use them.Jordan Rose2012-11-025-12/+31
| | | | | | | | These are CallEvent-equivalents of helpers already accessible in CheckerContext, as part of making it easier for new checkers to be written using CallEvent rather than raw CallExprs. llvm-svn: 167338
* [analyzer] isCLibraryFunction: check that the function is at TU-scope.Jordan Rose2012-11-022-11/+18
| | | | | | | Also, Decls already carry a pointer to the ASTContext, so there's no need to pass an extra argument to the predicate. llvm-svn: 167337
* [analyzer] Factor SimpleStreamChecker pulling out isLeaked().Anna Zaks2012-11-021-15/+21
| | | | llvm-svn: 167316
* [analyzer] Convert some of the harder cases over to ProgramStateTrait macros.Jordan Rose2012-11-023-62/+24
| | | | | | | Add FIXMEs for the traits visible from multiple translation units. Currently the macros hide their key types in an anonymous namespace. llvm-svn: 167277
OpenPOWER on IntegriCloud