Commit Graph

557 Commits

Author SHA1 Message Date
Anna Zaks 85913db489 [analyzer] MacOSKeychainAPIChecker: Add the custom BugReport visitor(which highlights the allocation site) to all the relevant reports within the checker.
llvm-svn: 138531
2011-08-25 00:32:42 +00:00
Jordy Rose 8b289a2cbd [analyzer] Move the RetainSummaryManager from CFRefCount to RetainReleaseChecker.
Because Checkers live for an entire translation unit, this persists summary caches across multiple code bodies and avoids repeated initialization (but probably at the cost of memory). This removes the last references from RetainReleaseChecker to CFRefCount.

llvm-svn: 138529
2011-08-25 00:10:37 +00:00
Jordy Rose a4c41bb875 [analyzer] Better fix for the "missing return" error, from Ted.
llvm-svn: 138526
2011-08-24 23:41:46 +00:00
Jordy Rose 34a83e911f [analyzer] Silence another incorrect warning ("control reaches end of non-void function")
llvm-svn: 138510
2011-08-24 22:58:49 +00:00
Jordy Rose 763982b82d [analyzer] Remove experimental FIXME that never actually applied to the code in trunk.
llvm-svn: 138508
2011-08-24 22:45:12 +00:00
Jordy Rose 184bd1430b [analyzer] CFRefReport and friends no longer depend on CFRefCount.
llvm-svn: 138506
2011-08-24 22:39:09 +00:00
Anna Zaks f880cff209 [analyzer] Do not use references in std::pair.
llvm-svn: 138497
2011-08-24 21:58:55 +00:00
Anna Zaks 0d67579497 [analyzer] Unbreak the release buildbot.
llvm-svn: 138493
2011-08-24 21:40:10 +00:00
Anna Zaks be460898bb [analyzer] MacOSKeychainAPIChecker: Provide reacher diagnostic trace by pointing to the allocation site when reporting a leak.
llvm-svn: 138479
2011-08-24 20:52:46 +00:00
Jordy Rose 9ff0299935 [analyzer] Silence an (incorrect) uninitialized variable warning, caught by Cameron.
llvm-svn: 138477
2011-08-24 20:38:42 +00:00
Jordy Rose 38eea65acd [analyzer] Copy GC mode setting from CFRefCount to RetainReleaseChecker in preparation for getting rid of CFRefCount.
This is a little hacky for now but will get better once we decide the best way to handle this.

llvm-svn: 138476
2011-08-24 20:33:55 +00:00
Anna Zaks 45aa208554 [analyzer] Allow checker writes to specify that no region should be accosiated with the report. (Useful when we report an error on endOfPath or deadSymbols, when the range of the last expression might have nothing to do with the error.)
llvm-svn: 138474
2011-08-24 20:31:06 +00:00
Jordy Rose e8743a7499 [analyzer] Remove unused DoNothingByRef and the special case for CFDictionaryCreate.
This is a very small regression (actually introduced in r138309) because it won't catch leaks of objects passed by reference to CFDictionaryCreate (they're considered to have escaped and are ignored). If this is important we can put in a specific eval::Call to restore the functionality.

llvm-svn: 138464
2011-08-24 19:10:50 +00:00
Jordy Rose 5df640dc33 [analyzer] Slightly clean up the fix in 138432, so that it doesn't depend on the relative ordering of path-sensitive and path-insensitive checks. Still not ideal, but I think a real fix would require infrastructure that doesn't exist yet.
llvm-svn: 138462
2011-08-24 18:56:32 +00:00
Jordy Rose 95589f13ff [analyzer] Fix a Heisenbug concerning object lifetimes with a hack. Hopefully a better fix coming soon. See comment for more details.
llvm-svn: 138432
2011-08-24 09:27:24 +00:00
Jordy Rose 58428b914d [analyzer] Reapply 138390 "Clean up unused bits of CFRefCount", reverted in 138405. Ended up unrelated to any problems.
llvm-svn: 138431
2011-08-24 09:22:31 +00:00
Jordy Rose 14de7c5a88 [analyzer] Fix potential crasher with RAII. No functionality change. (No test because this particular circumstance requires an impossible series of events, but this is future-proofing.)
llvm-svn: 138430
2011-08-24 09:02:37 +00:00
Jordy Rose 7a53498f20 [analyzer] Reapply 138382 and 138388 (reverted in 138419 and 138420). The issue seems to have been with the uninitialized variable fixed in 138424; a fix for another Heisencrasher coming soon.
llvm-svn: 138426
2011-08-24 05:47:39 +00:00
Jordy Rose 03a8f9e578 [analyzer] Correctly initialize a variable and hopefully fix crashes.
llvm-svn: 138424
2011-08-24 04:48:19 +00:00
Eric Christopher aa8b6a5cf4 Revert "[analyzer] Cleanup: Move temporary declarations of CFRefCount variables closer to their uses. No functionality change."
This reverts commit d02b4af7bd6ca4a743c7074d64e205d718aa221d.

llvm-svn: 138420
2011-08-24 00:39:51 +00:00
Eric Christopher 1825e7a260 Revert "[analyzer] Make CFRefBug and CFRefReportVisitor not dependent on CFRefCount. Unfortunately, CFRefReport still is. No functionality change."
This reverts commit e3fb7e428b7ba0d5d902dfe3f165d70e09b03a15.

llvm-svn: 138419
2011-08-24 00:39:48 +00:00
Anna Zaks 0897a23517 [analyzer] MacOSKeychainAPIChecker: Add reasoning about functions which MIGHT deallocate the memory region allocated with SecKeychain APIs. Specifically, when the buffer is passed to CFStringCreateWithBytesNoCopy along with a custom deallocator, which might potentially correctly release the memory.
llvm-svn: 138417
2011-08-24 00:06:27 +00:00
Anna Zaks f9e9c4e9bc [analyzer] MacOSKeychainAPIChecker: Retrieve the memory region which we are tracking even when it's no longer a SymbolicRegion, for example, when it is cast to char*.
llvm-svn: 138415
2011-08-23 23:56:12 +00:00
Anna Zaks bb167011e3 Move creation of the deallocation mismatch report into a separate function for future reuse.
llvm-svn: 138414
2011-08-23 23:47:36 +00:00
Ted Kremenek adfb445466 Constify the result of CFGStmt::getStmt().
llvm-svn: 138408
2011-08-23 23:05:04 +00:00
Eric Christopher fba570c9d8 Revert "[analyzer] Clean up unused bits of CFRefCount."
This reverts commit 6886a92640f5bffc972f67c0a1f302d6c6e7c322.

llvm-svn: 138405
2011-08-23 22:38:04 +00:00
Jordy Rose 5aa9b1dd3f [analyzer] Clean up unused bits of CFRefCount.
llvm-svn: 138390
2011-08-23 21:51:36 +00:00
Jordy Rose 908426aae4 [analyzer] Make CFRefBug and CFRefReportVisitor not dependent on CFRefCount. Unfortunately, CFRefReport still is. No functionality change.
llvm-svn: 138388
2011-08-23 21:47:17 +00:00
Jordy Rose fd13f6f56a [analyzer] Cleanup: Move temporary declarations of CFRefCount variables closer to their uses. No functionality change.
llvm-svn: 138382
2011-08-23 21:06:32 +00:00
Jordy Rose 20d4e68195 [analyzer] Move function retain-count effect summary log from CFRefCount to RetainReleaseChecker, and then explicitly provide the summary log when creating CFRefReports. No functionality change.
llvm-svn: 138374
2011-08-23 20:55:48 +00:00
Ted Kremenek ee9848e20d Fix regression in -Wuninitialized involving VLAs. It turns out that we were modeling sizeof(VLAs)
incorrectly in the CFG, and also the static analyzer.  This patch regresses the analyzer a bit, but
that needs to be followed up with a better solution.

Fixes <rdar://problem/10008112>.

llvm-svn: 138372
2011-08-23 20:30:50 +00:00
Jordy Rose bf77e51fa1 [analyzer] Move helper method Update from CFRefCount to RetainReleaseChecker. No functionality change.
llvm-svn: 138370
2011-08-23 20:27:16 +00:00
Jordy Rose 6763e38736 [analyzer] Move helper method handleAutoreleaseCounts from CFRefCount to RetainReleaseChecker. No functionality change.
llvm-svn: 138365
2011-08-23 20:07:14 +00:00
Jordy Rose 298cc4d907 [analyzer] Move ReturnStmt retain-count analysis from CFRefCount to RetainReleaseChecker. Tweak CFRefReport to reflect that fact that ReturnStmt checks are pre-statement, not post-statement. No intended functionality change.
llvm-svn: 138358
2011-08-23 19:43:16 +00:00
Jordy Rose 7861276f47 [analyzer] Move symbol death leak analysis from CFRefCount to RetainReleaseChecker.
llvm-svn: 138353
2011-08-23 19:01:07 +00:00
Jordy Rose 212e459164 [analyzer] Only allocate retain summaries for interesting functions/messages. This is a minor saving of memory but doesn't seem to cost any performance.
llvm-svn: 138320
2011-08-23 04:27:15 +00:00
Jordy Rose f5b0234992 [analyzer] Rename CFRefCount's evalSummary method to evalCallOrMessage, since it no longer, uh, evaluates call summaries.
llvm-svn: 138313
2011-08-23 00:03:01 +00:00
Jordy Rose 5b31d7acf7 [analyzer] Migrate the handling of retain-count-related RetEffects and ArgEffects from CFRefCount to RetainReleaseChecker. No intended functionality change.
llvm-svn: 138309
2011-08-22 23:48:23 +00:00
Anna Zaks bd7972b49e [analyzer] MacOSKeychainAPIChecker: Users of KeyChain API often use free() to deallocate the password. Catch this error explicitly and generate the error message at the place where free() is called.
llvm-svn: 138296
2011-08-22 23:18:12 +00:00
Anna Zaks 76c3fb6a51 Static Analyzer Diagnostics: Allow checkers to add ExtraDescriptiveText, now renamed into ExtraText, to the diagnostic without subclassing BugReport.
llvm-svn: 138272
2011-08-22 20:31:28 +00:00
Anna Zaks 752de1443f Clean up the CFRefBugReport - remove the members, which got moved to the CFRefReportVisitors.
llvm-svn: 138259
2011-08-22 18:54:07 +00:00
Jordy Rose 898a148d28 [analyzer] Migrate the aliasing effects of CFRetain and CFMakeCollectable from CFRefCount to RetainReleaseChecker. No intended functionality change.
llvm-svn: 138223
2011-08-21 21:58:18 +00:00
Jordy Rose 6582dde545 [analyzer] Remove FIXME; Ted reminded me that -init is not guaranteed to return its receiver and pretending that it does won't actually buy us anything. (Comment change only.)
llvm-svn: 138221
2011-08-21 21:04:38 +00:00
Jordy Rose 3f7f7568f2 [analyzer] Migrate return value handling from CFRefCount to ExprEngine. This seems to result in a minor performance hit, but I think that will go away again once we eliminate TransferFuncs from function calls entirely.
llvm-svn: 138220
2011-08-21 19:41:36 +00:00
Jordy Rose 82c673de33 [analyzer] Replace calls to getNameAsString() with StringRef equivalents.
llvm-svn: 138215
2011-08-21 05:25:15 +00:00
Benjamin Kramer 3cca223a2a Fix compile on platforms that don't implicitly include stdarg.h here.
llvm-svn: 138214
2011-08-20 21:50:41 +00:00
Jordy Rose a8f99ba749 [analyzer] RetainReleaseChecker always wants region change updates. There's no need for a flag, at least not right now.
llvm-svn: 138212
2011-08-20 21:17:59 +00:00
Jordy Rose 5c252ef7b1 Fix indentation.
llvm-svn: 138211
2011-08-20 21:16:58 +00:00
Jordy Rose 5a3c9ff3a3 [analyzer] Move handling of hardcoded noreturn ("panic") methods from CFRefCount to NoReturnFunctionChecker. No functionality change intended.
llvm-svn: 138210
2011-08-20 20:55:40 +00:00
Ted Kremenek 60d2ec5765 [analyzer] Handle reads of ObjCPropertyRefExprs implicitly in Environment. No need to bind an explicit value and create a new node.
llvm-svn: 138196
2011-08-20 06:23:25 +00:00
Ted Kremenek 876e34b7b5 [analyzer] Simplify ExprEngine::VisitBinaryOperator() by removing recursive visit to subexpressions (which is no longer needed).
llvm-svn: 138195
2011-08-20 06:16:31 +00:00
Ted Kremenek a9ce612fa2 Start partitioning ExprEngine.cpp into separate .cpp files that handle different parts
of the analysis (e.g., analysis of C expressions, analysis of Objective-C expressions, and so on).

llvm-svn: 138194
2011-08-20 06:00:03 +00:00
Ted Kremenek 10e2503177 Rename CXXExprEngine.cpp to ExprEngineCXX.cpp.
llvm-svn: 138193
2011-08-20 05:59:58 +00:00
Anna Zaks 88255cc533 Static Analyzer Diagnostics: Move the responsibility for generating the endOfPath diagnostic piece from BugReport to BugReporterVisitor. Switch CFRefCount to use visitors in order to generate the endOfPath piece.
llvm-svn: 138184
2011-08-20 01:27:22 +00:00
Ted Kremenek 417d566775 Remove dead code.
llvm-svn: 138183
2011-08-20 01:15:28 +00:00
Anna Zaks 071a89c39f Static Analyzer Diagnostics: Switch CFRefCount to using the new visitor API. BugReport no longer needs to inherit from BugReporterVisitor.
llvm-svn: 138142
2011-08-19 23:21:56 +00:00
Anna Zaks f86615ca5c Static Analyzer Diagnostics: Kill the addVisitorCreator(callbackTy, void*) API in favor of addVisitor(BugReporterVisitor*).
1) Create a header file to expose the predefined visitors. And move the parent(BugReporterVisitor) there as well.

2) Remove the registerXXXVisitor functions - the Visitor constructors/getters can be used now to create the object. One exception is registerVarDeclsLastStore(), which registers more then one visitor, so make it static member of FindLastStoreBRVisitor.

3) Modify all the checkers to use the new API.

llvm-svn: 138126
2011-08-19 22:33:38 +00:00
Anna Zaks be28d6c66d Fix a memory leak in the analyzer - BugReports didn't get freed. Plus, remove invalid assert from the destructor which wasn't called previously due to the leak.
llvm-svn: 138027
2011-08-19 01:57:09 +00:00
Anna Zaks f4dd4ae7cc Static Analyzer Diagnostics: Move custom diagnostic visitors from BugReporterContext to BugReport.
One API change: I added BugReporter as an additional parameter to the BugReporterVisitor::VisitNode() method to allow visitors register other visitors with the report on the fly (while processing a node). This functionality is used by NilReceiverVisitor, which registers TrackNullOrUndefValue when the receiver is null.

llvm-svn: 138001
2011-08-18 22:37:56 +00:00
Anna Zaks 525cfe7d28 Remove DiagBugReport by pulling it into its parent BugReport.
llvm-svn: 137899
2011-08-17 23:21:23 +00:00
Anna Zaks 3a6bdf8f82 Remove EnhancedBugReport and RangedBugReport - pull all the extra functionality they provided into their parent BugReport. The only functional changes are: made getRanges() non const - it adds default range to Ranges if none are supplied, made getStmt() private, which was another FIXME.
llvm-svn: 137894
2011-08-17 23:00:25 +00:00
Jordy Rose 217eb9043f [analyzer] Migrate assumption and binding handling from CFRefCount to RetainReleaseChecker. This is mostly a textual move and required no supporting changes. No functionality change intended.
llvm-svn: 137874
2011-08-17 21:27:39 +00:00
Ted Kremenek c14efa7122 Fix a handful of dead stores found by Clang's static analyzer. There's a bunch of others I haven't touched.
llvm-svn: 137867
2011-08-17 21:04:19 +00:00
Jordy Rose 9c09ce48b4 Fix typo.
llvm-svn: 137814
2011-08-17 05:00:56 +00:00
Jordy Rose 075d73bcce [analyzer] Add a warning for an incompatible plugin version.
llvm-svn: 137813
2011-08-17 04:56:03 +00:00
Benjamin Kramer 8b3929d956 Silence compiler warnings by casting object pointers to function pointers via intptr_t.
This is ugly but ISO C++ doesn't allow direct casts.

llvm-svn: 137812
2011-08-17 04:22:25 +00:00
Jordy Rose 93b86e494d [analyzer] Add basic support for pluggable checkers.
llvm-svn: 137802
2011-08-17 01:30:59 +00:00
Ted Kremenek e1962328f5 [analyzer] teach ExprEngine about loads from static C++ class fields. Fixes <rdar://problem/9948787>.
llvm-svn: 137760
2011-08-16 21:37:52 +00:00
Jordy Rose 59cce71af6 [analyzer] Overhaul of checker registration in preparation for basic plugin support. Removes support for checker groups (we can add them back in later if we decide they are still useful), and -analyzer-checker-help output is a little worse for the time being (no packages).
llvm-svn: 137758
2011-08-16 21:24:21 +00:00
Anna Zaks a06421a02c MacOSKeychainAPIChecker: Turn it on by default.
llvm-svn: 137740
2011-08-16 20:02:05 +00:00
Anna Zaks 01ae1e1197 MacOSKeychainAPIChecker: Do not report double allocation if first allocation returned an error.
llvm-svn: 137720
2011-08-16 16:30:24 +00:00
Ted Kremenek 31fdb61618 [analyzer] Enhance ConditionVisitor to handle arbitrary ValueDecls in binary expressions, and also handle inverting the order of comparison when the named decl appears on the RHS.
llvm-svn: 137714
2011-08-16 10:57:37 +00:00
Ted Kremenek 01401a54f8 [analyzer] fix operation inversion calculation in ConditionVisitor.
llvm-svn: 137708
2011-08-16 03:44:38 +00:00
Ted Kremenek 667417ef9c [analyzer] Enhance ConditionVisitor to understand eagerly evaluated (simple) binary conditions, and teach it to only focus on constraint changes.
llvm-svn: 137705
2011-08-16 01:53:41 +00:00
Ted Kremenek b1bf2680f5 [analyzer] add ExprEngine::getEagerlyAssumedTags() to allow externally querying of "eagerly assumed" expressions.
llvm-svn: 137704
2011-08-16 01:53:39 +00:00
Ted Kremenek 9815709cd2 [analyzer] Remove PostStmtCustom ProgramPoint. It can be represented using tagged PostStmts.
llvm-svn: 137697
2011-08-16 00:49:19 +00:00
Anna Zaks 5443a6497b MacOSKeychainAPIChecker: The security API/memory leak checker should always generate regular nodes instead of sink nodes.
llvm-svn: 137681
2011-08-15 23:23:15 +00:00
Ted Kremenek 32b9e234fe Add ProgramState.cpp.
llvm-svn: 137677
2011-08-15 23:05:22 +00:00
Ted Kremenek 001fd5b498 Rename GRState to ProgramState, and cleanup some code formatting along the way.
llvm-svn: 137665
2011-08-15 22:09:50 +00:00
Anna Zaks 29f9b7adc3 MacOSKeychainAPIChecker: Use llvm::SmallString instead of std::string (as per code review for r137523).
llvm-svn: 137633
2011-08-15 18:42:00 +00:00
Ted Kremenek 5ef32dbf2a Cleanup various declarations of 'Stmt*' to be 'Stmt *', etc. in libAnalyzer and libStaticAnalyzer[*]. It was highly inconsistent, and very ugly to look at.
llvm-svn: 137537
2011-08-12 23:37:29 +00:00
Ted Kremenek e8f7316fee [analyzer] change "tag" in ProgramPoint from "void*" to a ProgramPointTag*.
Having a notion of an actual ProgramPointTag will aid in introspection of the analyzer's behavior.
For example, the GraphViz output of the analyzer will pretty-print the tags in a useful manner.

llvm-svn: 137529
2011-08-12 23:04:46 +00:00
Anna Zaks 59d741fec6 MacOSKeychainAPIChecker: If the allocated data address entered as an enclosing function parameter, skip it to avoid false positives.
llvm-svn: 137526
2011-08-12 22:47:22 +00:00
Anna Zaks fdd0aca0a5 MacOSKeychainAPIChecker:
Report errors earlier: on checkDeadSymbols() and clear the state after the symbol we are tracking goes out of scope. 

Also, perform lazy error checking. Instead of forcing the paths to be split depending one the return value of the allocator, make the return symbol depend on the allocated data symbol, which prolongs its life span to the time when the allocated data symbol becomes dead.

llvm-svn: 137523
2011-08-12 21:56:43 +00:00
Jordy Rose add45b78dd [analyzer] Nitpicks on Olaf's patch, which I meant to e-mail but then didn't in
time. One is cleanup, the other is me being OCD about enum group nesting.

llvm-svn: 137517
2011-08-12 21:41:07 +00:00
Anna Zaks c94894fbc2 MacOSKeychainAPIChecker: There is no need to use SymbolMetadata to represent the allocated data symbol, we can just use the symbol corresponding to the SymbolicRegion. This simplifies tracking of the symbol, for example, SymbolMetadata needs to go through extra hoops to stay alive.
Make AllocationState internal to the MacOSKeychainAPIChecker class.

llvm-svn: 137514
2011-08-12 21:14:26 +00:00
Ted Kremenek 8df44b2632 [analyzer] Introduce new MemRegion, "TypedValueRegion", so that we can separate TypedRegions that implement getValueType() from those that don't.
Patch by Olaf Krzikalla!

llvm-svn: 137498
2011-08-12 20:02:48 +00:00
Anna Zaks 9b25cee36f Optimizations for Dependent Symbol tracking (as per Ted's code review for r137309):
1) Change SymbolDependTy map to keep pointers as data. And other small tweaks like making the DenseMap smaller 64->16 elements; remove removeSymbolDependencies() as it will probably not be used.

2) Do not mark dependents live more then once.

llvm-svn: 137401
2011-08-12 00:34:56 +00:00
Anna Zaks 22a9d0f316 Analyzer Core: Adding support for user-defined symbol dependencies. (For example, the allocated resource symbol only needs to be freed if no error has been returned by the allocator, so a checker might want to make the lifespan of the error code symbol depend on the allocated resource symbol.) Note, by default, the map that holds the dependencies will get destroyed along with the SymbolManager at the end of function exploration.
llvm-svn: 137309
2011-08-11 16:43:28 +00:00
Anna Zaks 173864b36c Cleanup: remove CleanedSate member and GetState() wrapper from StmtNodeBuilder, not needed as of r137273.
llvm-svn: 137284
2011-08-11 00:11:21 +00:00
Anna Zaks e309e05603 Cleanup: remove GetState() wrapper from ExprEngine, not needed as of r137273.
llvm-svn: 137279
2011-08-10 23:34:53 +00:00
Anna Zaks 5a56a6653f Analyzer Core: In checkDeadSymbols checker callback, provide the state in which the symbols are not yet deleted so that checkers could inspect them. Since we are now always creating a transition in ProcessStmt(), remove the logic for adding a transition when none was generated. TODO: the extra transitions will have to be removed; more cleanups; a checker that tests teh new fucntionality.
llvm-svn: 137273
2011-08-10 23:14:54 +00:00
Ted Kremenek 54d456758e [analyzer] Start sketching out a new BugReporterVisitor that inspects branches and other expressions to generate interesting path events in diagnostics.
llvm-svn: 137012
2011-08-06 06:54:45 +00:00
Ted Kremenek 84a1ca5280 [analyzer] Simplify logic for ExprEngine::VisitUnaryExprOrTypeTraitExpr to avoid recursion to subexpression.
This exposed bugs in the live variables analysis, and a latent analyzer bug in the SymbolReaper.

llvm-svn: 137006
2011-08-06 00:30:00 +00:00
Ted Kremenek c91ca30b4c [analyzer] Change SymbolReaper to store region roots implied by the Environment, allowing it be queried when
determining if symbols derived from regions are still live.

llvm-svn: 137005
2011-08-06 00:29:57 +00:00
Anna Zaks 177ecfac21 KeychainAPI checker: Track SymbolMetadata instead of MemRegion in checker state so that we could clear the state on evalDeadSymbols; also track the return value.
llvm-svn: 137003
2011-08-05 23:52:45 +00:00
Anna Zaks c52bed1814 KeychainAPI checker: Generate an error on double allocation. Pull out getAsPointeeMemoryRegion so that it could be reused.
llvm-svn: 136952
2011-08-05 00:37:00 +00:00
Anna Zaks c686177555 KeychainAPI checker: Track additional pair of SecKeychain APIs. Also, keep exploring the transition on which a call to allocator function failed (to be able to find errors in examples like ErrorCodesFromDifferentAPISDoNotInterfere).
llvm-svn: 136930
2011-08-04 21:53:01 +00:00
Anna Zaks 08be9b99e3 KeychainAPI checker: Refactor to make it easier to add more allocator/deallocator API pairs. Add the allocator function ID to the checker state. Better comments.
llvm-svn: 136889
2011-08-04 17:28:06 +00:00
Anna Zaks 4aa34a5325 KeychainAPI checker: refactor to use early exit.
llvm-svn: 136852
2011-08-04 00:31:38 +00:00
Anna Zaks 388c18ec7f KeychainAPI checker: Add basic diagnostics. Track MemoryRegion istead of SymbolicRef since the address might not be a symbolic value in some cases, for example in fooOnlyFree() test.
llvm-svn: 136851
2011-08-04 00:26:57 +00:00
Ted Kremenek 907377e303 [analyzer] Remove 'all-experimental' checker group.
llvm-svn: 136849
2011-08-04 00:25:50 +00:00
Ted Kremenek 3f955e6d89 [analyzer] rename all experimental checker packages to have 'experimental' be the common root package.
llvm-svn: 136835
2011-08-03 23:14:55 +00:00
Ted Kremenek 1c2fb270ce [analyzer] Introduce MallocOverflowSecurityChecker, a simple flow-sensitive checker that may be useful for security auditing. This checker is currently too noisy to be on by default.
llvm-svn: 136804
2011-08-03 20:17:43 +00:00
Anna Zaks 59546b8f79 Static Analyzer diagnostics visualization: when the last location on a path is end of the function, the arrow should point to the closing brace, not the statement before it. Patch by Ted Kremenek.
llvm-svn: 136761
2011-08-03 01:57:49 +00:00
Ted Kremenek 9a2001a817 [analyzer] Drastically simplify ExprEngine::VisitInitListExpr() by assuming all initializer expressions have already been evaluated.
llvm-svn: 136706
2011-08-02 18:27:05 +00:00
Anna Zaks 9ab728bb05 KeychainAPI checker: only check the paths on which the allocator function returned noErr. (+ minor cleanup)
llvm-svn: 136694
2011-08-02 17:11:03 +00:00
Anna Zaks 15f496c118 Add a skeleton for the Keychain Services API Checker. Register it as OSX experimental for now. Note, the checker still does not handle tracking of escaped values, taking into account the return value of the allocator functions, nor the actual bug reporting..
llvm-svn: 136659
2011-08-01 22:40:01 +00:00
Benjamin Kramer 558e37858b Remove dead code flagged by GCC's -Wunused-but-set-variable.
llvm-svn: 136581
2011-07-31 01:06:41 +00:00
Ted Kremenek 67d7136f26 [analyzer] Remove recursive visitation in ExprEngine::VisitDeclStmt because it isn't needed anymore.
llvm-svn: 136522
2011-07-29 21:18:41 +00:00
Ted Kremenek e905c68cbd [analyzer] Remove recursive visitation in ExprEngine::VisitCompoundLiteralExpr because it isn't needed anymore.
llvm-svn: 136521
2011-07-29 21:18:39 +00:00
Ted Kremenek dc492c29f7 [analyzer] Remove recursive visitation in ExprEngine::VisitCastExpr because it isn't needed anymore.
llvm-svn: 136520
2011-07-29 21:18:37 +00:00
Ted Kremenek cf36b0c64d [analyzer] Remove recursive visitation in ExprEngine::VisitObjCForCollectionStmt because it isn't needed anymore.
llvm-svn: 136519
2011-07-29 21:18:35 +00:00
Ted Kremenek 65eefed6c6 [analyzer] Remove explicit argument processing from ExprEngine::VisitObjCMessage() since it is no longer needed.
llvm-svn: 136518
2011-07-29 21:18:31 +00:00
Ted Kremenek 4e577fae2c [analyzer] Remove recursive visitation in ExprEngine::VisitLValObjCIvarRefExpr because it isn't needed anymore.
llvm-svn: 136517
2011-07-29 21:18:28 +00:00
Ted Kremenek 003ec6ff83 [analyzer] tighten up ExprEngine::VisitObjCAtSynchronizationStmt().
llvm-svn: 136516
2011-07-29 21:18:26 +00:00
Ted Kremenek f8c0bcf101 [analyzer] Remove recursive visitation in ExprEngine::VisitObjCPropertyRefExpr because it isn't needed anymore.
llvm-svn: 136515
2011-07-29 21:18:24 +00:00
Ted Kremenek 298e5cc7f4 [analyzer] Remove recursive visitation in ExprEngine::VisitCallExpr because it isn't needed anymore.
llvm-svn: 136514
2011-07-29 21:18:22 +00:00
Ted Kremenek 22a1e65532 [analyzer] Remove recursive visitation in ExprEngine::VisitMemberExpr because it isn't needed anymore.
llvm-svn: 136513
2011-07-29 21:18:19 +00:00
Ted Kremenek db835cc213 [analyzer] Remove recursive visitation in ExprEngine::VisitLvalArraySubscriptExpr() because it is no longer needed.
llvm-svn: 136512
2011-07-29 21:18:17 +00:00
Chandler Carruth 605415923f Remove an unused function (found by Clang's -Wunused-function)
llvm-svn: 136434
2011-07-29 00:15:44 +00:00
Ted Kremenek 73665188fc Really remove FlatStoreManager and BasicStoreManager, this time from the driver. Also remove associated tests. Sorry for the messy commits; this is the result of a botched Git merge.
llvm-svn: 136422
2011-07-28 23:08:16 +00:00
Ted Kremenek e2e37b9afc Remove FlatStoreManager and BasicStoreManager. The latter has long been obsolete and the former has no had development in a long time.
llvm-svn: 136420
2011-07-28 23:08:02 +00:00
Ted Kremenek e9fda1e48a [analyzer] Overhaul how the static analyzer expects CFGs by forcing CFGs to be linearized only when used by the static analyzer. This required a rewrite of LiveVariables, and exposed a ton of subtle bugs.
The motivation of this large change is to drastically simplify the logic in ExprEngine going forward.

Some fallout is that the output of some BugReporterVisitors is not as accurate as before; those will
need to be fixed over time.  There is also some possible performance regression as RemoveDeadBindings
will be called frequently; this can also be improved over time.

llvm-svn: 136419
2011-07-28 23:07:59 +00:00
Ted Kremenek e227f49302 [analyzer] fix bug in malloc checker where the tracked symbol would not properly be removed from the state.
llvm-svn: 136418
2011-07-28 23:07:51 +00:00
Ted Kremenek ae16d1cc67 [analyzer] Add StoreManager::includedInBindings() to to query whether a region is used in any bindings.
llvm-svn: 136416
2011-07-28 23:07:46 +00:00
Ted Kremenek 6b1a761f3e [analyzer] Add safety checking in RegionStoreManager for string literal underruns.
llvm-svn: 136415
2011-07-28 23:07:43 +00:00
Ted Kremenek 47fc816b96 [analyzer] Teach Environment to not look through MaterializeTemporaryExprs.
llvm-svn: 136414
2011-07-28 23:07:41 +00:00
Ted Kremenek 3b446215d1 [analyzer] Fix bug in ObjCMessage where casts were being incorrectly ignored.
llvm-svn: 136413
2011-07-28 23:07:38 +00:00
Ted Kremenek a644668193 [analyzer] fix handling of MaterializeTemporaryExpr by binding the result value to
the proper expression.

llvm-svn: 136412
2011-07-28 23:07:36 +00:00
Chandler Carruth d48db2115a Rename getInstantiationLineNumber to getExpansionLineNumber in both
SourceManager and FullSourceLoc.

llvm-svn: 135969
2011-07-25 21:09:52 +00:00
Chandler Carruth 42f35f9cd2 Rename getInstantiationColumnNumber to getExpansionColumnNumber in both
SourceManager and FullSourceLoc.

llvm-svn: 135965
2011-07-25 20:57:57 +00:00
Chandler Carruth c7ca5218b6 Rename getDecomposedInstantiationLoc to getDecomposedExpansionLoc.
llvm-svn: 135962
2011-07-25 20:52:32 +00:00
Chandler Carruth 35f5320d8e Mechanically rename SourceManager::getInstantiationLoc and
FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part
of the API and documentation update from 'instantiation' as the term for
macros to 'expansion'.

llvm-svn: 135914
2011-07-25 16:49:02 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
John McCall d2930c2100 In Objective-C, pull arbitrary attributes from overridden
methods, including indirectly overridden methods like those
declared in protocols and categories.  There are mismatches
that we would like to diagnose but aren't yet, but this   
is fine for now.

I looked at approaches that avoided doing this lookup 
unless we needed it, but the infer-related-result-type
checks were doing it anyway, so I left it with the same
fast-path check for no previous declartions of that 
selector.

llvm-svn: 135743
2011-07-22 02:45:48 +00:00
Ted Kremenek 86070b9c0f Move AnalysisManager constructor out of line. No functionality change (yet).
llvm-svn: 135667
2011-07-21 05:22:52 +00:00
Ted Kremenek 189ecec4db Simplify passing of CFGBuildOptions around for AnalysisContext. No functionality change.
llvm-svn: 135666
2011-07-21 05:22:47 +00:00
Jordy Rose a39e10fd7c [analyzer] Very minor cleanup in PthreadLockChecker. No functionality change.
llvm-svn: 135518
2011-07-19 20:31:42 +00:00
Jordy Rose d9c522100e [analysis] Add checks for double-locking and lock order reversal bugs for
pthread and XNU locks. Patch by Rui Paulo!

llvm-svn: 135515
2011-07-19 20:21:41 +00:00
Ted Kremenek c85964ed90 [analyzer] Place checking for Core Foundation "Create" rule into a proper API. No functionality change.
llvm-svn: 135349
2011-07-16 19:50:32 +00:00
Jordy Rose 43426f8fcb Add tests for CFRefReport's path notes, and fix a few typos and non-standard terminology ('+0 retain counts') caught by the tests.
llvm-svn: 135310
2011-07-15 22:17:54 +00:00
Jordy Rose b72bd53f7d [analyzer] GNU __null is a pointer-sized integer, not a pointer. Fixes PR10372.
llvm-svn: 135294
2011-07-15 20:29:02 +00:00
Jordy Rose f3dd00a26c Clean up UnixAPIChecker, including switching its array of BugTypes to llvm::OwningPtr<BugType> vars (the new convention). No functionality change.
llvm-svn: 135255
2011-07-15 06:28:59 +00:00
Jordy Rose ede26958bf Clean up MacOSXAPIChecker, including switching its array of BugTypes to a single llvm::OwningPtr<BugType> (the new convention). No functionality change.
llvm-svn: 135250
2011-07-15 06:02:19 +00:00
John McCall 7c454bb8ce Create a new expression node, SubstNonTypeTemplateParmExpr,
to represent a fully-substituted non-type template parameter.
This should improve source fidelity, as well as being generically
useful for diagnostics and such.

llvm-svn: 135243
2011-07-15 05:09:51 +00:00
John McCall 4db5c3c83a In ARC, reclaim all return values of retainable type, not just those
where we have an immediate need of a retained value.

As an exception, don't do this when the call is made as the immediate
operand of a __bridge retain.  This is more in the way of a workaround
than an actual guarantee, so it's acceptable to be brittle here.

rdar://problem/9504800

llvm-svn: 134605
2011-07-07 06:58:02 +00:00
Douglas Gregor 5c70b06feb Teach the static analyzer's interpretation of Cocoa conventions to
obey the objc_method_family attribute when provided. Fixes
<rdar://problem/9726279>.

llvm-svn: 134493
2011-07-06 16:00:34 +00:00
Eric Christopher bf15d2b311 Update for llvm commit r134291.
Fixes rdar://9714064

llvm-svn: 134292
2011-07-02 00:20:22 +00:00
Jordy Rose 4d3c1511ac [analyzer] Use UnknownVal when default-initializing arrays whose element types we don't model, to distinguish them from uninitialized arrays (PR10163).
llvm-svn: 133937
2011-06-27 20:36:38 +00:00