aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-12-19 02:26:37 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-12-19 02:26:37 +0000
commitf45fbad13ee1f143a2cb6e806fefe22b48f68940 (patch)
tree01375f1a0f1448551d475afa7bf6f0e7b643db7a
parent9c2bac02c1d1204bcf2c5a025ab901d09bc7ae26 (diff)
If the initializer is an rvalue and the variable is a const reference,
create a temporary object for it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122161 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Checker/GRExprEngine.cpp9
-rw-r--r--test/Analysis/reference.cpp2
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index 2977835f82..549f7d9f8b 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -2506,9 +2506,12 @@ void GRExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
// time a function is called those values may not be current.
ExplodedNodeSet Tmp;
- if (InitEx)
- Visit(InitEx, Pred, Tmp);
- else
+ if (InitEx) {
+ if (VD->getType()->isReferenceType() && !InitEx->isLValue()) {
+ CreateCXXTemporaryObject(InitEx, Pred, Tmp);
+ } else
+ Visit(InitEx, Pred, Tmp);
+ } else
Tmp.Add(Pred);
ExplodedNodeSet Tmp2;
diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp
index 836abb446f..51c8aae66c 100644
--- a/test/Analysis/reference.cpp
+++ b/test/Analysis/reference.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
-// XFAIL: *
+
typedef typeof(sizeof(int)) size_t;
void malloc (size_t);