summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CheckDeadStores.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Split libAnalysis into two libraries: libAnalysis and libChecker.Ted Kremenek2010-01-251-279/+0
| | | | | | | | | | | | | | | | | | | | | | | | | (1) libAnalysis is a generic analysis library that can be used by Sema. It defines the CFG, basic dataflow analysis primitives, and inexpensive flow-sensitive analyses (e.g. LiveVariables). (2) libChecker contains the guts of the static analyzer, incuding the path-sensitive analysis engine and domain-specific checks. Now any clients that want to use the frontend to build their own tools don't need to link in the entire static analyzer. This change exposes various obvious cleanups that can be made to the layout of files and headers in libChecker. More changes pending. :) This change also exposed a layering violation between AnalysisContext and MemRegion. BlockInvocationContext shouldn't explicitly know about BlockDataRegions. For now I've removed the BlockDataRegion* from BlockInvocationContext (removing context-sensitivity; although this wasn't used yet). We need to have a better way to extend BlockInvocationContext (and any LocationContext) to add context-sensitivty. llvm-svn: 94406
* Suppress dead store warnings involving objects initialized with ↵Ted Kremenek2009-12-231-0/+4
| | | | | | CXXExprTemporaries. llvm-svn: 91986
* Add (initial?) static analyzer support for handling C++ references.Ted Kremenek2009-12-161-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change was a lot bigger than I originally anticipated; among other things it requires us storing more information in the CFG to record what block-level expressions need to be evaluated as lvalues. The big change is that CFGBlocks no longer contain Stmt*'s by CFGElements. Currently CFGElements just wrap Stmt*, but they also store a bit indicating whether the block-level expression should be evalauted as an lvalue. DeclStmts involving the initialization of a reference require us treating the initialization expression as an lvalue, even though that information isn't recorded in the AST. Conceptually this change isn't that complicated, but it required bubbling up the data through the CFGBuilder, to GRCoreEngine, and eventually to GRExprEngine. The addition of CFGElement is also useful for when we want to handle more control-flow constructs or other data we want to keep in the CFG that isn't represented well with just a block of statements. In GRExprEngine, this patch introduces logic for evaluating the lvalues of references, which currently retrieves the internal "pointer value" that the reference represents. EvalLoad does a two stage load to catch null dereferences involving an invalid reference (although this could possibly be caught earlier during the initialization of a reference). Symbols are currently symbolicated using the reference type, instead of a pointer type, and special handling is required creating ElementRegions that layer on SymbolicRegions (see the changes to RegionStoreManager). Along the way, the DeadStoresChecker also silences warnings involving dead stores to references. This was the original change I introduced (which I wrote test cases for) that I realized caused GRExprEngine to crash. llvm-svn: 91501
* Until we can make the dead stores checker smarter, dont' emit dead store ↵Ted Kremenek2009-12-151-0/+4
| | | | | | warnings for C++ objects (whose constructors/destructors have possible side-effects). llvm-svn: 91412
* Add a heuristic to the dead stores checker to prune dead stores for ↵Ted Kremenek2009-12-031-1/+2
| | | | | | variables annotated with '__block'. This is overly conservative, but now the analyzer doesn't report dead stores for variables that can be updated by a block call. llvm-svn: 90364
* Port BugReporter and BugType to StringRef.Benjamin Kramer2009-11-291-1/+1
| | | | llvm-svn: 90086
* lib/Analysis: Remove VISIBILITY_HIDDEN from definitions in anonymous namespaceKovarththanan Rajaratnam2009-11-281-3/+2
| | | | llvm-svn: 90028
* Change CheckDeadStores to use Expr::isNullPointerConstant, which will ↵Ted Kremenek2009-11-221-6/+5
| | | | | | | | correctly determine whether an expression is a null pointer constant. Patch by Kovarththanan Rajaratnam! llvm-svn: 89621
* Make AnalysisManager stateless. Now other analyzer components only depends onZhongxing Xu2009-09-101-4/+5
| | | | | | local node information. llvm-svn: 81433
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-45/+45
| | | | llvm-svn: 81346
* Remove the ASTContext parameter from the attribute-related methods of Decl.Argyrios Kyrtzidis2009-06-301-2/+2
| | | | | | | | | The implementations of these methods can Use Decl::getASTContext() to get the ASTContext. This commit touches a lot of files since call sites for these methods are everywhere. I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it. llvm-svn: 74501
* Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.Douglas Gregor2009-06-181-2/+2
| | | | llvm-svn: 73702
* Remove hack from LiveVariables analysis where variables whose address are takenTed Kremenek2009-04-071-4/+38
| | | | | | | | | | | | are considered 'live'. This hack isn't needed anymore because we have a separation in the path-sensitive analyzer between variable names and bindings; the analyzer can continue to reason about the storage of a variable after its name is no longer directly referenced. Now the live variables analysis literally means "is this name live". Along this line, update the dead stores checker to explicitly look for variables whose values have escaped. llvm-svn: 68504
* Sentence-type bug type and category.Ted Kremenek2009-04-021-5/+5
| | | | llvm-svn: 68345
* Fix: <rdar://problem/6740387>. Sending nil to an object that returns a structTed Kremenek2009-04-011-43/+3
| | | | | | | should only be an error if that value is consumed. This fix was largely accomplished by moving 'isConsumedExpr' back to ParentMap. llvm-svn: 68195
* Fix PR 2514: Do not flag dead initializations for variables initialized to a ↵Ted Kremenek2009-02-091-2/+15
| | | | | | constant global variable. llvm-svn: 64149
* Rename Expr::isConstantExpr to Expr::isConstantInitializer; this more Eli Friedman2009-01-251-1/+1
| | | | | | | | accurately states what the function is trying to do and how it is different from Expr::isEvaluatable. Also get rid of a parameter that is both unused and inaccurate. llvm-svn: 62951
* Dead stores checker: Fix <rdar://problem/6506065> by being more selective ↵Ted Kremenek2009-01-201-5/+44
| | | | | | when say that a store is dead even though the computed value is used in the enclosing expression. llvm-svn: 62552
* Dead stores checker: Don't flag dead stores for self-assignments (common ↵Ted Kremenek2009-01-091-3/+10
| | | | | | escape hatch for 'unused variable' warnings). llvm-svn: 62010
* Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of Chris Lattner2008-11-241-1/+1
| | | | | | | | | | | uses of getName() with uses of getDeclName(). This upgrades a bunch of diags to take DeclNames instead of std::strings. This also tweaks a couple of diagnostics to be cleaner and changes CheckInitializerTypes/PerformInitializationByConstructor to pass around DeclarationNames instead of std::strings. llvm-svn: 59947
* Enhance dead store checker to not flag preincrements to dead variables where ↵Ted Kremenek2008-10-151-0/+7
| | | | | | the preincrement is a subexpression, e.g. foo(++x); This can cause false negatives, but will remove a whole class of false positives. llvm-svn: 57554
* Add "category" to BugTypes, allowing bugs to be grouped.Ted Kremenek2008-09-201-3/+3
| | | | | | Changed casing of many bug names. The convention will be to have bug names (mostly) lower cased, and categories use some capitalization. llvm-svn: 56385
* Added FIXME.Ted Kremenek2008-08-091-0/+1
| | | | llvm-svn: 54568
* Don't use Expr::isIntegerConstantExpr just to check if a pointer value is ↵Ted Kremenek2008-08-091-13/+9
| | | | | | initialize to NULL. llvm-svn: 54563
* Don't flag any dead stores for variables marked unused.Ted Kremenek2008-08-071-1/+1
| | | | llvm-svn: 54492
* Added decl_iterator to DeclStmt to provide an abstract interface to iterate ↵Ted Kremenek2008-08-051-2/+3
| | | | | | | | over the ScopedDecls of a DeclStmt. Updated a few clients of DeclStmt::getNextDeclarator() to use decl_iterator instead. Will update other clients after additional testing. llvm-svn: 54368
* Change 'dead store (++/--)' to 'dead increment'Ted Kremenek2008-08-021-1/+1
| | | | llvm-svn: 54268
* Don't emit 'dead initialization' warnings for variables marked 'unused'.Ted Kremenek2008-07-251-3/+9
| | | | | | This fixes PR 2573: http://llvm.org/bugs/show_bug.cgi?id=2573 llvm-svn: 54009
* Issue dead store warnings for preincrements involved in a subexpression.Ted Kremenek2008-07-241-6/+1
| | | | llvm-svn: 53983
* Don't flag dead stores when the result of a preincrement/predecrement is ↵Ted Kremenek2008-07-231-1/+6
| | | | | | used in an enclosing expression. llvm-svn: 53964
* Further refine dead store checking to distinguish between dead stores and ↵Ted Kremenek2008-07-231-22/+65
| | | | | | dead increments. llvm-svn: 53960
* Rename file.Ted Kremenek2008-07-221-0/+152
llvm-svn: 53906
OpenPOWER on IntegriCloud