aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-07-16 23:38:09 +0000
committerJordan Rose <jordan_rose@apple.com>2012-07-16 23:38:09 +0000
commit89e5aaf57e20b39e35b0d068ebbc09ae736f2e1e (patch)
tree81e26f5fefbe3d2d30ce0fc2387f82ac5aed1dd1 /lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
parentb04a45720ba0cbc4bdb08aebceefa184e22f8a93 (diff)
[analyzer] Handle new-expressions with initializers for scalars.
<rdar://problem/11818967> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160328 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExprEngineCXX.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngineCXX.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index 3fa052817c..9a1264e17c 100644
--- a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -136,6 +136,19 @@ void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred,
State = State->BindExpr(CNE, LCtx, symVal);
}
+ // If the type is not a record, we won't have a CXXConstructExpr as an
+ // initializer. Copy the value over.
+ if (const Expr *Init = CNE->getInitializer()) {
+ if (!isa<CXXConstructExpr>(Init)) {
+ QualType ObjTy = CNE->getType()->getAs<PointerType>()->getPointeeType();
+ (void)ObjTy;
+ assert(!ObjTy->isRecordType());
+ SVal Location = State->getSVal(CNE, LCtx);
+ if (isa<Loc>(Location))
+ State = State->bindLoc(cast<Loc>(Location), State->getSVal(Init, LCtx));
+ }
+ }
+
Bldr.generateNode(CNE, Pred, State);
}