aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRExprEngine.cpp
AgeCommit message (Collapse)Author
2008-10-31Comment out invalid assertion. I'm leaving it in the code for now as a ↵Ted Kremenek
reminder to produce a test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58510 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Fix 80-col violations.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58495 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Add a tentative assertion.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58492 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-31Fix a comment.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58487 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Handle the case in VisitInitListExprs where there are no initializers in the ↵Ted Kremenek
compound literal. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58468 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Use the correct predecessor node.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58446 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Add missing return statement.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58444 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Use a worklist in GRExprEngine::VisitInitListExpr to process subexpressions.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58440 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Merge the array and struct case. They are essentially the same.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58422 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Rename:Zhongxing Xu
- SetSVal(GRState*, Loc, SVal) => BindLoc - SetSVal(GRState*, Expr*, SVal) => BindExpr git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58421 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Implement VisitInitListExpr(). InitListExpr will have a nonloc::CompoundVal ↵Zhongxing Xu
value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58419 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-30Mark yy_fatal_error as a panic function.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58410 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-29Rename: AddDecl => BindDeclZhongxing Xu
BindDecl better describes what the function does: - Bind the VarDecl to its memory region - Bind the memory region to some initial value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58359 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28Rename ExplicitCCastExpr to CStyleCastExprDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58331 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-28Improve our handling of (C++) references within Clang. Specifically:Douglas Gregor
- Do not allow expressions to ever have reference type - Extend Expr::isLvalue to handle more cases where having written a reference into the source implies that the expression is an lvalue (e.g., function calls, C++ casts). - Make GRExprEngine::VisitCall treat the call arguments as lvalues when they are being bound to a reference parameter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27Remove type-punning warning in GRExprEngine. No functionality change.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58292 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27Added preliminary support for CompoundLiterals in the static analyzer:Ted Kremenek
- GRExprEngine::VisitCompoundLiteral... (1) visits the initializer list (generating ExplodedNodes) (2) creates a CompoundMemRegion for the literal (3) creates a new state with the bound literal values using GRStateManager::BindCompoundLiteral - GRStateManager::BindCompoundLiteral simply calls StoreManager::BindCompoundLiteral to get a new store and returns a persistent GRState with that store. - BasicStore::BindCompoundLiteral simply returns the same store, as it doesn't handle field sensitivity - RegionStore::BindCompoundLiteral currently fires an assert (pending discussion of how to best implement mappings for CompoundLiteralRegion). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58277 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-27Refactor the expression class hierarchy for casts. Most importantly:Douglas Gregor
- CastExpr is the root of all casts - ImplicitCastExpr is (still) used for all explicit casts - ExplicitCastExpr is now the root of all *explicit* casts - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++ - CXXFunctionalCastExpr inherits from ExplicitCastExpr - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all of the C++ named cast expression types (static_cast, dynamic_cast, etc.) - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr to Also, fixed returned-stack-addr.cpp, which broke once when we fixed reinterpret_cast to diagnose double->int* conversions and again when we eliminated implicit conversions to reference types. The fix is in both testcase and SemaChecking.cpp. Most of this patch is simply support for the renaming. There's very little actual change in semantics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58264 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-25Do not crash when performing VisitLValue on union types.Ted Kremenek
This fixes PR 2948. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58148 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-25Add code for get the lvalue for string literals. Now we return a StringRegionZhongxing Xu
for StringLiteral lvalue evaluation, instead of directly returning a loc::StringLiteralVal by the Environment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58138 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-25Now we can handle arrays.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58135 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24Implicit conversions from arrays can also be conversions to references (will ↵Ted Kremenek
add a test case shortly). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58110 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24Added method "getSelfRegion" to Store. This method returns the region ↵Ted Kremenek
associated with the "this" or "self" object (C++ and Objective-C respectively). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58107 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24Fix 80-col violation.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58070 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-24Make the analyzer store (memory model) a command line option.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58056 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-23Add an assertion to make our intention more clear.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58030 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-23Let StoreManager do different cast on arrays. BasicStore will just keep it ↵Zhongxing Xu
intact. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58028 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22Adjust parameter order to more natural one.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57964 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-22Exprs of function type is another special case for ImplicitCast.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57963 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21When conjuring symbols for compound assignments, use the promoted type to ↵Ted Kremenek
determine if the symbolic value as a "loc::" or "nonloc::" value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57917 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21Preliminary support for function overloadingDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57909 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-21Localize the special processing of array variable inside Zhongxing Xu
GRExprEngine::VisitCast() so that other parts of the analyzer can be ignorant. When we cast "array of type T" to "pointer to T", we get the loc::MemRegionVal corresponding to the array variable. This is sufficient for BasicStore, but not for RegionStore. RegionStore should get the element region for the first array element in the cast. So next comes to the revamping of transfer functions for different store model. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57897 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-20Further improve path-sensitivity with divide-by-zero checking by assuming ↵Ted Kremenek
that a denominator cannot be zero even when the result of an '/' or '%' expression is unknown. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57855 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-20Used conjured symbols to recover path-sensitivity when the result of a ↵Ted Kremenek
compound assignment is UnknownVal(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57851 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18Add support in GRExprEngine for UnaryOperator::AlignOf. This fixes one ↵Ted Kremenek
crash report in PR 2796. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57777 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18Generalize VisitLValue: not only can CallExprs and ObjCMessageExprs return ↵Ted Kremenek
aggregate temporaries, so can many other expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57761 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18Function calls and ObjC message expressions can be used in a lvalue context ↵Ted Kremenek
if they return a structure. E.g foo().x == 1. We don't really support, however, such temporaries yet in the environment or the store. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57760 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18Use "VisitLValue" when processing the base for "x.f" field accesses, and ↵Ted Kremenek
"Visit" when processing the base for "x->f" field accesses. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57754 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17When conjuring symbols to recover path-sensitivity, don't conjure symbols ↵Ted Kremenek
that represent an entire struct. We need to implement struct temporaries as an actual "region", and then bind symbols to the FieldRegion of those temporaries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57739 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17"Implement" GRExprEngine::VisitLValue for ObjCPropertyRefExpr. This is only ↵Ted Kremenek
a bandid; we need to properly handle properties by using locv/nonloc objects and specially handling property assignments in the transfer function for BinaryOperator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57693 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17This patch did the following renaming. There should be no functional changes.Zhongxing Xu
RVal => SVal LVal => Loc NonLVal => NonLoc lval => loc nonlval => nonloc git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57671 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17Get array's lvalue through standard interface.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57666 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17Return the corresponding MemRegionVal for both rvalue and lvalue of array ofZhongxing Xu
type T. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57665 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17Remove an untrue assertion: lval::FuncVals can be returned in both rvalue ↵Ted Kremenek
and lvalue contexts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57659 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17Remove lval::FieldOffset, lval::ArrayOffset. These will be replaced with ↵Ted Kremenek
regions. Remove GRExprEngine::getLVal and RValues::MakeVal. Enhance StoreManager "GetLValue" methods to dispatch for specific kinds of lvalue queries, as opposed to interogating the expression tree (GRExprEngine already does this). Added FIXMEs. In particular, we no longer "assume" that a base pointer in a field/array access is null (this logic was removed). Perhaps we should do this when fetching the lvalue for fields and array elements? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57657 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-17Add transfer function support for ObjCIvarRefExpr.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57654 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-16This is the first step to build a better evaluation model for GRExprEngine. AZhongxing Xu
new VisitLValue method is added to replace the old VisitLVal. The semantics model becomes more explicit to separate rvalue evaluation from lvalue evaluation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57627 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-09Check some cases for previous patch. Make the code more robust.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57317 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-07Added a function call case that generates sink nodes.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57240 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-06Don't use DeclStmt::getDecl(); this will eventually disappear. Just fetch ↵Ted Kremenek
the first decl using the DeclStmt::decl_iterator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57194 91177308-0d34-0410-b5e6-96231b3b80d8