Support lifetime-extension of conditional temporaries.
llvm-svn: 337767
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 208576e..be284da 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6362,7 +6362,6 @@
struct IndirectLocalPathEntry {
enum EntryKind {
DefaultInit,
- Conditional,
AddressOf,
VarInit,
LValToRVal,
@@ -6498,7 +6497,6 @@
case Stmt::ConditionalOperatorClass:
case Stmt::BinaryConditionalOperatorClass: {
- Path.push_back({IndirectLocalPathEntry::Conditional, Init});
auto *C = cast<AbstractConditionalOperator>(Init);
if (!C->getTrueExpr()->getType()->isVoidType())
visitLocalsRetainedByReferenceBinding(Path, C->getTrueExpr(), RK, Visit);
@@ -6685,7 +6683,6 @@
case Stmt::ConditionalOperatorClass:
case Stmt::BinaryConditionalOperatorClass: {
- Path.push_back({IndirectLocalPathEntry::Conditional, Init});
auto *C = cast<AbstractConditionalOperator>(Init);
// In C++, we can have a throw-expression operand, which has 'void' type
// and isn't interesting from a lifetime perspective.
@@ -6717,8 +6714,7 @@
/// supposed to lifetime-extend along (but don't).
static bool shouldLifetimeExtendThroughPath(const IndirectLocalPath &Path) {
for (auto Elem : Path) {
- if (Elem.Kind != IndirectLocalPathEntry::DefaultInit &&
- Elem.Kind != IndirectLocalPathEntry::Conditional)
+ if (Elem.Kind != IndirectLocalPathEntry::DefaultInit)
return false;
}
return true;
@@ -6731,7 +6727,6 @@
switch (Path[I].Kind) {
case IndirectLocalPathEntry::AddressOf:
case IndirectLocalPathEntry::LValToRVal:
- case IndirectLocalPathEntry::Conditional:
// These exist primarily to mark the path as not permitting or
// supporting lifetime extension.
break;
@@ -6791,7 +6786,6 @@
Diag(DiagLoc, RK == RK_ReferenceBinding
? diag::warn_unsupported_temporary_not_extended
: diag::warn_unsupported_init_list_not_extended)
- << (Path.front().Kind == IndirectLocalPathEntry::Conditional)
<< DiagRange;
} else {
// FIXME: Warn on this.
@@ -6898,7 +6892,6 @@
switch (Elem.Kind) {
case IndirectLocalPathEntry::AddressOf:
case IndirectLocalPathEntry::LValToRVal:
- case IndirectLocalPathEntry::Conditional:
// These exist primarily to mark the path as not permitting or
// supporting lifetime extension.
break;