[cfe-commits] r122161 - in /cfe/trunk: lib/Checker/GRExprEngine.cpp test/Analysis/reference.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Sat Dec 18 18:26:37 PST 2010
Author: zhongxingxu
Date: Sat Dec 18 20:26:37 2010
New Revision: 122161
URL: http://llvm.org/viewvc/llvm-project?rev=122161&view=rev
Log:
If the initializer is an rvalue and the variable is a const reference,
create a temporary object for it.
Modified:
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/test/Analysis/reference.cpp
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=122161&r1=122160&r2=122161&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Sat Dec 18 20:26:37 2010
@@ -2506,9 +2506,12 @@
// 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;
Modified: cfe/trunk/test/Analysis/reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/reference.cpp?rev=122161&r1=122160&r2=122161&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/reference.cpp (original)
+++ cfe/trunk/test/Analysis/reference.cpp Sat Dec 18 20:26:37 2010
@@ -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);
More information about the cfe-commits
mailing list