summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core
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
commit61a4f6682ae0837f2590e0cd8e60ce342ea9ff42 (patch)
tree4c1478f414d2aba36336813a674748650bc352f8 /clang/lib/StaticAnalyzer/Core
parentae044c06bf530c0aaf5038c7e69b202e350a8fbd (diff)
downloadbcm5719-llvm-61a4f6682ae0837f2590e0cd8e60ce342ea9ff42.tar.gz
bcm5719-llvm-61a4f6682ae0837f2590e0cd8e60ce342ea9ff42.zip
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.
llvm-svn: 128611
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core')
-rw-r--r--clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
index b015d4f264d..b299fcc1c1d 100644
--- a/clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud