diff options
| author | David Blaikie <dblaikie@gmail.com> | 2012-08-06 22:47:24 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2012-08-06 22:47:24 +0000 |
| commit | 131fcb4a064e59cdff1333164f0ee741074e7123 (patch) | |
| tree | a5528a2d5a19a7a771740d797055d69d77c1b6b6 /clang/lib | |
| parent | 2da09fd79464bebc24da0c01f383e1cdd0cc7d92 (diff) | |
| download | bcm5719-llvm-131fcb4a064e59cdff1333164f0ee741074e7123.tar.gz bcm5719-llvm-131fcb4a064e59cdff1333164f0ee741074e7123.zip | |
Refactor checks for unevaluated contexts into a common utility function.
The one caller that's surrounded by nearby code manipulating the underlying
evaluation context list is left unmodified for readability.
Review by Sean Silva and Richard Smith.
llvm-svn: 161355
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 2 |
3 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index dce912c4771..f9c993beb12 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4710,7 +4710,7 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) { /// conversion void Sema::CheckImplicitConversions(Expr *E, SourceLocation CC) { // Don't diagnose in unevaluated contexts. - if (ExprEvalContexts.back().Context == Sema::Unevaluated) + if (isUnevaluatedContext()) return; // Don't diagnose for value- or type-dependent expressions. diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f13408e6326..ea121b8b3ce 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -584,8 +584,7 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) { // is a prvalue for the temporary. // FIXME: add some way to gate this entire thing for correctness in // potentially potentially evaluated contexts. - if (getLangOpts().CPlusPlus && E->isGLValue() && - ExprEvalContexts.back().Context != Unevaluated) { + if (getLangOpts().CPlusPlus && E->isGLValue() && !isUnevaluatedContext()) { ExprResult Temp = PerformCopyInitialization( InitializedEntity::InitializeTemporary(E->getType()), E->getExprLoc(), @@ -2403,7 +2402,7 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS, // FIXME: Does the addition of const really only apply in // potentially-evaluated contexts? Since the variable isn't actually // captured in an unevaluated context, it seems that the answer is no. - if (ExprEvalContexts.back().Context != Sema::Unevaluated) { + if (!isUnevaluatedContext()) { QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc); if (!CapturedType.isNull()) type = CapturedType; @@ -10039,7 +10038,7 @@ namespace { // Error on DeclRefExprs referring to FieldDecls. ExprResult TransformDeclRefExpr(DeclRefExpr *E) { if (isa<FieldDecl>(E->getDecl()) && - SemaRef.ExprEvalContexts.back().Context != Sema::Unevaluated) + !SemaRef.isUnevaluatedContext()) return SemaRef.Diag(E->getLocation(), diag::err_invalid_non_static_member_use) << E->getDecl() << E->getSourceRange(); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 31a87dc8a0d..20fe036348b 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1085,7 +1085,7 @@ static QualType inferARCLifetimeForPointee(Sema &S, QualType type, // If we are in an unevaluated context, like sizeof, skip adding a // qualification. - } else if (S.ExprEvalContexts.back().Context == Sema::Unevaluated) { + } else if (S.isUnevaluatedContext()) { return type; // If that failed, give an error and recover using __strong. __strong |

