]> granicus.if.org Git - clang/commitdiff
If the initializer is an rvalue and the variable is a const reference,
authorZhongxing Xu <xuzhongxing@gmail.com>
Sun, 19 Dec 2010 02:26:37 +0000 (02:26 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Sun, 19 Dec 2010 02:26:37 +0000 (02:26 +0000)
create a temporary object for it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122161 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/GRExprEngine.cpp
test/Analysis/reference.cpp

index 2977835f826a9533ad8d912545c8bbe83a3b5f45..549f7d9f8bbffa4db64d5b721589f18e97e04413 100644 (file)
@@ -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;
index 836abb446fd5cc697eac96e14236b3e3d0cf77d6..51c8aae66c1ec7f79f7722e6977215bb72382649 100644 (file)
@@ -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);