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
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index 2977835..549f7d9 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -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;