From: Jordan Rose Date: Sat, 29 Sep 2012 01:36:42 +0000 (+0000) Subject: Revert "[analyzer] Handle inlined constructors for rvalue temporaries correctly." X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=846c898cebf02cb753125633c52e0d1d7fd94b4b;p=clang Revert "[analyzer] Handle inlined constructors for rvalue temporaries correctly." This reverts commit 580cd17f256259f39a382e967173f34d68e73859. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164875 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 2e460b79e7..eb5395e93c 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -160,14 +160,7 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) { svalBuilder.getCXXThis(CCE->getConstructor()->getParent(), calleeCtx); SVal ThisV = state->getSVal(This); - // 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(MR)) - ThisV = state->getSVal(cast(ThisV)); - + // Always bind the region to the CXXConstructExpr. state = state->BindExpr(CCE, callerCtx, ThisV); } } diff --git a/test/Analysis/array-struct-region.cpp b/test/Analysis/array-struct-region.cpp index e7fbe4d987..22fbf2ff33 100644 --- a/test/Analysis/array-struct-region.cpp +++ b/test/Analysis/array-struct-region.cpp @@ -61,6 +61,12 @@ int getAssignedField(struct S s) { 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 . + // expected-warning@-4{{UNKNOWN}} +#endif + clang_analyzer_eval(getAssignedField(getS()) == 42); // expected-warning{{TRUE}} } diff --git a/test/Analysis/ctor-inlining.mm b/test/Analysis/ctor-inlining.mm index ac963e5d9b..918de0a456 100644 --- a/test/Analysis/ctor-inlining.mm +++ b/test/Analysis/ctor-inlining.mm @@ -103,17 +103,3 @@ namespace TemporaryConstructor { 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}} - } -}