[cfe-commits] r164952 - in /cfe/trunk: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp test/Analysis/array-struct-region.cpp test/Analysis/ctor-inlining.mm
Jordan Rose
jordan_rose at apple.com
Mon Oct 1 10:51:36 PDT 2012
Author: jrose
Date: Mon Oct 1 12:51:35 2012
New Revision: 164952
URL: http://llvm.org/viewvc/llvm-project?rev=164952&view=rev
Log:
Reapply "[analyzer] Handle inlined constructors for rvalue temporaries correctly."
This is related to but not blocked by <rdar://problem/12137950>
("Return-by-value structs do not have associated regions")
This reverts r164875 / 3278d41e17749dbedb204a81ef373499f10251d7.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/test/Analysis/array-struct-region.cpp
cfe/trunk/test/Analysis/ctor-inlining.mm
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=164952&r1=164951&r2=164952&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Mon Oct 1 12:51:35 2012
@@ -160,7 +160,14 @@
svalBuilder.getCXXThis(CCE->getConstructor()->getParent(), calleeCtx);
SVal ThisV = state->getSVal(This);
- // Always bind the region to the CXXConstructExpr.
+ // If the constructed object is a prvalue, get its bindings.
+ // Note that we have to be careful here because constructors embedded
+ // in DeclStmts are not marked as lvalues.
+ if (!CCE->isGLValue())
+ if (const MemRegion *MR = ThisV.getAsRegion())
+ if (isa<CXXTempObjectRegion>(MR))
+ ThisV = state->getSVal(cast<Loc>(ThisV));
+
state = state->BindExpr(CCE, callerCtx, ThisV);
}
}
Modified: cfe/trunk/test/Analysis/array-struct-region.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/array-struct-region.cpp?rev=164952&r1=164951&r2=164952&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/array-struct-region.cpp (original)
+++ cfe/trunk/test/Analysis/array-struct-region.cpp Mon Oct 1 12:51:35 2012
@@ -52,12 +52,6 @@
void testArgument() {
clang_analyzer_eval(getConstrainedField(getS()) == 42); // expected-warning{{TRUE}}
-#if __cplusplus
- // FIXME: Passing the struct by value seems to be confusing C++.
- // Possibly related to <rdar://problem/12137950>.
- // expected-warning at -4{{UNKNOWN}}
-#endif
-
clang_analyzer_eval(getAssignedField(getS()) == 42); // expected-warning{{TRUE}}
}
Modified: cfe/trunk/test/Analysis/ctor-inlining.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor-inlining.mm?rev=164952&r1=164951&r2=164952&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/ctor-inlining.mm (original)
+++ cfe/trunk/test/Analysis/ctor-inlining.mm Mon Oct 1 12:51:35 2012
@@ -103,3 +103,17 @@
return;
}
}
+
+
+namespace ConstructorUsedAsRValue {
+ using TemporaryConstructor::BoolWrapper;
+
+ bool extractValue(BoolWrapper b) {
+ return b.value;
+ }
+
+ void test() {
+ bool result = extractValue(BoolWrapper());
+ clang_analyzer_eval(result); // expected-warning{{TRUE}}
+ }
+}
More information about the cfe-commits
mailing list