aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-31 04:04:48 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-31 04:04:48 +0000
commit41c5f498b2d10fab683f1c5685ff79c90a737d24 (patch)
tree193eae790b8bfa286295dff9f77fd0e792836888 /lib/StaticAnalyzer/Core/CXXExprEngine.cpp
parent5af02db5a48476e0748f135369663080eae87c64 (diff)
Teach static analyzer about the basics of handling new[]. We still don't simulate constructors, but at least the analyzer doesn't think the return value is uninitialized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/CXXExprEngine.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/CXXExprEngine.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/StaticAnalyzer/Core/CXXExprEngine.cpp b/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
index b015d4f264..b299fcc1c1 100644
--- a/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
+++ b/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
@@ -199,20 +199,23 @@ void ExprEngine::VisitCXXDestructor(const CXXDestructorDecl *DD,
void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred,
ExplodedNodeSet &Dst) {
- if (CNE->isArray()) {
- // FIXME: allocating an array has not been handled.
- return;
- }
-
+
unsigned Count = Builder->getCurrentBlockCount();
DefinedOrUnknownSVal symVal =
svalBuilder.getConjuredSymbolVal(NULL, CNE, CNE->getType(), Count);
- const MemRegion *NewReg = cast<loc::MemRegionVal>(symVal).getRegion();
-
+ const MemRegion *NewReg = cast<loc::MemRegionVal>(symVal).getRegion();
QualType ObjTy = CNE->getType()->getAs<PointerType>()->getPointeeType();
-
const ElementRegion *EleReg =
- getStoreManager().GetElementZeroRegion(NewReg, ObjTy);
+ getStoreManager().GetElementZeroRegion(NewReg, ObjTy);
+
+ if (CNE->isArray()) {
+ // FIXME: allocating an array requires simulating the constructors.
+ // For now, just return a symbolicated region.
+ const GRState *state = GetState(Pred);
+ state = state->BindExpr(CNE, loc::MemRegionVal(EleReg));
+ MakeNode(Dst, CNE, Pred, state);
+ return;
+ }
// Evaluate constructor arguments.
const FunctionProtoType *FnType = NULL;