From: Richard Smith Date: Tue, 24 Jul 2018 21:18:30 +0000 (+0000) Subject: Don't lifetime-extend or track lifetime problems through the LHS of '->*'. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b8872507a7209e39655cec6b5fb32f91a3e328d;p=clang Don't lifetime-extend or track lifetime problems through the LHS of '->*'. Fixes a false-positive warning found by selfhost. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337857 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 3d11619ec4..7e652b778b 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -108,7 +108,7 @@ const Expr *Expr::skipRValueSubobjectAdjustments( } } } else if (const BinaryOperator *BO = dyn_cast(E)) { - if (BO->isPtrMemOp()) { + if (BO->getOpcode() == BO_PtrMemD) { assert(BO->getRHS()->isRValue()); E = BO->getLHS(); const MemberPointerType *MPT = diff --git a/test/SemaCXX/return-stack-addr.cpp b/test/SemaCXX/return-stack-addr.cpp index a5f84adf0b..08aaa749b4 100644 --- a/test/SemaCXX/return-stack-addr.cpp +++ b/test/SemaCXX/return-stack-addr.cpp @@ -157,3 +157,9 @@ void ret_from_lambda() { (void) [&]() -> int& { int &a = b; return a; }; (void) [=]() mutable -> int& { int &a = b; return a; }; } + +namespace mem_ptr { + struct X {}; + int X::*f(); + int &r(X *p) { return p->*f(); } +}