Commit Graph

388 Commits

Author SHA1 Message Date
Ted Kremenek 036223bdcf Fix horrible GRExprEngine bug where switch statements with no 'case:' statements would cause the path to get prematurely aborted. Fixes <rdar://problem/8360854>.
llvm-svn: 112233
2010-08-26 22:19:33 +00:00
Ted Kremenek c8bd967430 Remove redundant cast<...>.
llvm-svn: 112229
2010-08-26 22:04:01 +00:00
John McCall 8e7d656a4a De-memberify the VarDecl and FunctionDecl StorageClass enums.
This lets us remove Sema.h's dependency on Expr.h and Decl.h.

llvm-svn: 112156
2010-08-26 03:08:43 +00:00
Chris Lattner 8c3283857e zap dead ctor
llvm-svn: 112132
2010-08-26 01:17:33 +00:00
John McCall e302792b61 GCC didn't care for my attempt at API compatibility, so brute-force everything
to the new constants.

llvm-svn: 112047
2010-08-25 11:45:40 +00:00
Tom Care a460311710 Improvements to IdempotentOperationChecker and its use of PseudoConstantAnalysis
- Added wasReferenced function to PseudoConstantAnalysis to determine if a variable was ever referenced in a function (outside of a self-assignment)
- BlockDeclRefExpr referenced variables are now explicitly added to the non-constant list
- Remove unnecessary ignore of implicit casts
- Generalized parameter self-assign detection to detect deliberate self-assigns of variables to avoid unused variable warnings
- Updated test cases with deliberate self-assignments
- Fixed bug with C++ references and pseudoconstants
- Added test case for C++ references and pseudoconstants

llvm-svn: 111965
2010-08-24 21:09:07 +00:00
Zhongxing Xu 5b297da1de Improve comments.
llvm-svn: 111897
2010-08-24 04:26:55 +00:00
Tom Care e332c3b762 Several small changes to PseudoConstantAnalysis and the way IdempotentOperationChecker uses it.
- Psuedo -> Pseudo (doh...)
- C++ reference support
- Added pseudoconstant test case for __block vars
- Separated out static local checking from pseudoconstant analysis and generalized to non-local checking
- Added missing test cases for storage false positives

llvm-svn: 111832
2010-08-23 19:51:57 +00:00
Zhongxing Xu fee32dc783 Adjust code placement.
llvm-svn: 111790
2010-08-23 01:37:32 +00:00
Eli Friedman 04831926ec Detabify.
llvm-svn: 111768
2010-08-22 01:00:03 +00:00
Zhongxing Xu faf150bbc3 Place method near its class.
llvm-svn: 111737
2010-08-21 12:24:38 +00:00
Zhongxing Xu 7a1a8e25ea Remove dead code.
llvm-svn: 111736
2010-08-21 11:05:46 +00:00
Zhongxing Xu e11f17f5ed Improve comments.
llvm-svn: 111735
2010-08-21 11:03:37 +00:00
Zhongxing Xu 5cba6c85c9 Remove a special case for OSAtomic functions. We can already bind and retrieve
with the same binding key. The only trick here is that sometimes the Symbolic
region is stored in with an LocAsInteger wrapper. We unwrap that in 
SVal::getAsLocSymbol().

llvm-svn: 111734
2010-08-21 11:00:26 +00:00
Zhongxing Xu e70b6d17a4 Remove dead code. We no longer need it because now we treat the first element
region and its base region as the same binding key.

llvm-svn: 111732
2010-08-21 08:55:42 +00:00
Zhongxing Xu cdadf8d9b2 remove unused variable.
llvm-svn: 111731
2010-08-21 06:51:45 +00:00
Zhongxing Xu adc3ac7012 When invalidating a struct region, whether its type definition exists is not
relavant any more, because we set its default value to a symbol, and the type of
default symbolic value is irrelavant.

llvm-svn: 111730
2010-08-21 06:26:59 +00:00
Ted Kremenek 87562e8371 Remove dead code.
llvm-svn: 111616
2010-08-20 06:06:41 +00:00
Jordy Rose 796b5122d9 Handle nested compound values in BindArray for multidimensional arrays. Fixes PR7945.
llvm-svn: 111602
2010-08-20 01:05:59 +00:00
Jordy Rose 1cd2472ac2 Remove dead code. Patch by Jon Mulder!
llvm-svn: 111541
2010-08-19 18:59:37 +00:00
Sebastian Redl d44cd6adba More PCH -> AST renaming.
llvm-svn: 111472
2010-08-18 23:57:06 +00:00
Alexis Hunt dcfba7b35b Generate Attr subclasses with TableGen.
Now all classes derived from Attr are generated from TableGen.
Additionally, Attr* is no longer its own linked list; SmallVectors or
Attr* are used. The accompanying LLVM commit contains the updates to
TableGen necessary for this.

Some other notes about newly-generated attribute classes:

 - The constructor arguments are a SourceLocation and a Context&,
   followed by the attributes arguments in the order that they were
   defined in Attr.td

 - Every argument in Attr.td has an appropriate accessor named getFoo,
   and there are sometimes a few extra ones (such as to get the length
   of a variadic argument).

Additionally, specific_attr_iterator has been introduced, which will
iterate over an AttrVec, but only over attributes of a certain type. It
can be accessed through either Decl::specific_attr_begin/end or
the global functions of the same name.

llvm-svn: 111455
2010-08-18 23:23:40 +00:00
Tom Care b9933f365e Added psuedo-constant analysis and integrated it into the false positive reduction stage in IdempotentOperationChecker.
- Renamed IdempotentOperationChecker::isConstant to isConstantOrPseudoConstant to better reflect the function
- Changed IdempotentOperationChecker::PreVisitBinaryOperator to only run 'CanVary' once on undefined assumptions
- Created new PsuedoConstantAnalysis class and added it to AnalysisContext
- Changed IdempotentOperationChecker to exploit the new analysis
- Updated tests with psuedo-constants
- Added check to IdempotentOperationChecker to see if a Decl is const qualified

llvm-svn: 111426
2010-08-18 21:17:24 +00:00
Jordy Rose 8258499f42 Remove dead malloc symbols from the symbol-state map.
llvm-svn: 111353
2010-08-18 04:33:47 +00:00
Jordy Rose bc80329f1f Use RegionStateTy everywhere we mean ImmutableMap<SymbolRef, RefState>
llvm-svn: 111351
2010-08-18 04:26:59 +00:00
Chris Lattner 2a2a468d1a zap dead code.
llvm-svn: 111347
2010-08-18 02:45:56 +00:00
Ted Kremenek 5322150a7f Rewrite code fragment to avoide ICE in MSVC. Fixes PR 7875. Patch by Dimitry Andric!
llvm-svn: 111327
2010-08-17 23:29:06 +00:00
Daniel Dunbar 56df97761d StringRef'ication of lots stuff, patch by Peter Davies!
llvm-svn: 111314
2010-08-17 22:39:59 +00:00
Ted Kremenek 5c3cea7b09 Remove dead code.
llvm-svn: 111304
2010-08-17 22:05:33 +00:00
Benjamin Kramer 35b077e674 Convert all uses of StringLiteral::getStrData() to StringLiteral::getString()
and remove getStrData().  Patch by Peter Davies (with some tweaks).

llvm-svn: 111229
2010-08-17 12:54:38 +00:00
Zhongxing Xu a66d1694f4 Generate a node instead of a sink. A leak is not a fatal error.
llvm-svn: 111217
2010-08-17 00:36:37 +00:00
Jordy Rose 5ccde8593f Allow the "size" of a buffer access check to be either signed or unsigned. Fixes PR7925.
llvm-svn: 111205
2010-08-16 23:25:19 +00:00
Tom Care c129cc18f0 Added basic psuedoconstant checking in IdempotentOperationChecker and fixed some test cases.
llvm-svn: 111190
2010-08-16 21:43:52 +00:00
Jordy Rose 63a38a1b94 Instead of using operator bool() for testing if a BindingKey is valid, use an explicit isValid() method.
llvm-svn: 111181
2010-08-16 20:53:01 +00:00
Jordy Rose 4a57ec86bb Move GRState::AssumeInBound out of its header file -- it's not really inline-friendly anymore.
llvm-svn: 111179
2010-08-16 20:34:06 +00:00
Jordy Rose 722f558f07 Model the effects of strcpy() and stpcpy() in CStringChecker. Other changes:
- Fix memcpy() and friends to actually invalidate the destination buffer.
- Emit a different message for out-of-bounds buffer accesses if the buffer is being written to.
- When conjuring symbols, let ValueManager figure out the type.

llvm-svn: 111120
2010-08-16 07:51:42 +00:00
Jordy Rose df28e8ec41 - Allow making ElementRegions with complex offsets (expressions or symbols) for the purpose of bounds-checking.
- Rewrite GRState::AssumeInBound to actually do that checking, and to use the normal constraint path.
- Remove ConstraintManager::AssumeInBound.
- Teach RegionStore and FlatStore to ignore those regions for now.

llvm-svn: 111116
2010-08-16 01:15:17 +00:00
Jordy Rose d2b777a409 Move GRState's bind* methods out of its header file -- they're too big for inlining now.
llvm-svn: 111113
2010-08-15 22:19:33 +00:00
Zhongxing Xu ee770d40fd StoreManager::RemoveDeadBindings() can take a Store instead of an entire GRState now.
llvm-svn: 111103
2010-08-15 12:45:09 +00:00
Zhongxing Xu 0ba9fd6c47 Remove redundant method.
llvm-svn: 111099
2010-08-15 10:08:38 +00:00
Zhongxing Xu bce831f7e0 Implement MallocChecker::EvalDeadSymbols() with the new API. This time we
iterate over symbols being tracked, instead of symbols being dead.

llvm-svn: 111097
2010-08-15 08:19:57 +00:00
Argyrios Kyrtzidis 1cec2cc798 Remove dead code, caught by unused function warnings.
llvm-svn: 111091
2010-08-15 01:15:58 +00:00
Jordy Rose 2a2e21c902 Update CStringChecker to take advantage of the new metadata symbols and region change callback. Now does basic tracking of string length for general regions. Currently this is still only used for modeling strlen().
llvm-svn: 111081
2010-08-14 21:02:52 +00:00
Jordy Rose ac0ab20e3b Add a callback for when region changes occur. Still somewhat of a work-in-progress, but working! Effect on clients: all changes to a store now go through GRState.
llvm-svn: 111078
2010-08-14 20:44:32 +00:00
Jordy Rose 1f3a553b9b Another metadata symbol change (missed a file)
llvm-svn: 111077
2010-08-14 20:22:12 +00:00
Jordy Rose 7fa9bf05bc Add a new metadata symbol type for checkers to use. Metadata symbols must be associated with a region and will be collected if the region dies or its checker fails to mark it as in use.
llvm-svn: 111076
2010-08-14 20:18:45 +00:00
Eli Friedman a2622dd266 Zap unused UnaryOperator::OffsetOf.
llvm-svn: 110996
2010-08-13 01:36:11 +00:00
Tom Care af9bbad718 Small changes to UnreachableCodeChecker
- Added detection of Empty CFGBlocks (artificial blocks)
- Relaxed an assertion based on an incorrect assumption until further investigation

llvm-svn: 110974
2010-08-12 23:01:06 +00:00
Tom Care f8a9863df9 Improved IdempotentOperationChecker false positives and false negatives.
- Unfinished analysis may still report valid warnings if the path was completely analyzed
- New 'CanVary' heuristic to recursively determine if a subexpression has a varying element
- Updated test cases, including one known bug
- Exposed GRCoreEngine through GRExprEngine

llvm-svn: 110970
2010-08-12 22:45:47 +00:00
Jordy Rose 5af0e3cbba Remove OwnershipAttr::Kind, since it's essentially redundant with attr::Kind the way it's being used. Also fix isa<OwnershipAttr> support, break more-than-80-char lines, and other miscellaneous ownership attr cleanup.
llvm-svn: 110908
2010-08-12 08:54:03 +00:00