diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-01-20 01:26:23 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-01-20 01:26:23 +0000 |
commit | ef331b783bb96a0f0e34afdb7ef46677dc4764cb (patch) | |
tree | 76961cf2e3a83c1dedb9490266157be929dd64b4 /lib/Sema/SemaExprCXX.cpp | |
parent | 2bf8fd84087231fd92dfdebe18895e01a6ae405c (diff) |
Remove PotentiallyPotentiallyEvaluated, and replace it with a much simpler and less error-prone way of handling the relevant cases. Towards marking of whether a declaration is used more accurately.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index db41f5a3ca..f0b31fd0f1 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -310,7 +310,6 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *E, SourceLocation RParenLoc) { - bool isUnevaluatedOperand = true; if (E && !E->isTypeDependent()) { if (E->getType()->isPlaceholderType()) { ExprResult result = CheckPlaceholderExpr(E); @@ -332,7 +331,11 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, // polymorphic class type [...] [the] expression is an unevaluated // operand. [...] if (RecordD->isPolymorphic() && E->Classify(Context).isGLValue()) { - isUnevaluatedOperand = false; + // The subexpression is potentially evaluated; switch the context + // and recheck the subexpression. + ExprResult Result = TranformToPotentiallyEvaluated(E); + if (Result.isInvalid()) return ExprError(); + E = Result.take(); // We require a vtable to query the type at run time. MarkVTableUsed(TypeidLoc, RecordD); @@ -352,12 +355,6 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, } } - // If this is an unevaluated operand, clear out the set of - // declaration references we have been computing and eliminate any - // temporaries introduced in its computation. - if (isUnevaluatedOperand) - ExprEvalContexts.back().Context = Unevaluated; - return Owned(new (Context) CXXTypeidExpr(TypeInfoType.withConst(), E, SourceRange(TypeidLoc, RParenLoc))); @@ -695,14 +692,7 @@ void Sema::CheckCXXThisCapture(SourceLocation Loc) { continue; } // This context can't implicitly capture 'this'; fail out. - // (We need to delay the diagnostic in the - // PotentiallyPotentiallyEvaluated case because it doesn't apply to - // unevaluated contexts.) - if (ExprEvalContexts.back().Context == PotentiallyPotentiallyEvaluated) - ExprEvalContexts.back() - .addDiagnostic(Loc, PDiag(diag::err_implicit_this_capture)); - else - Diag(Loc, diag::err_implicit_this_capture); + Diag(Loc, diag::err_implicit_this_capture); return; } break; |