diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2016-06-23 18:11:15 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-06-23 18:11:15 +0000 |
| commit | b77ebd749af6171a565c19139849fc7d8d4209e4 (patch) | |
| tree | 124ac4e509017b031febc648fd1cd2d9d0ac75e9 /clang/lib/Sema/SemaExprCXX.cpp | |
| parent | 38bb1c15fdf76ab0632c0062d06867cb6c93c7af (diff) | |
| download | bcm5719-llvm-b77ebd749af6171a565c19139849fc7d8d4209e4.tar.gz bcm5719-llvm-b77ebd749af6171a565c19139849fc7d8d4209e4.zip | |
Revert r273548, "Rearrange condition handling so that semantic checks on a condition variable"
as it caused a regression in -Wfor-loop-analysis.
llvm-svn: 273589
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index f97b9c9d81b..d5e944fa110 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3054,21 +3054,11 @@ void Sema::CheckVirtualDtorCall(CXXDestructorDecl *dtor, SourceLocation Loc, } } -Sema::ConditionResult Sema::ActOnConditionVariable(Decl *ConditionVar, - SourceLocation StmtLoc, - ConditionKind CK) { - ExprResult E = - CheckConditionVariable(cast<VarDecl>(ConditionVar), StmtLoc, CK); - if (E.isInvalid()) - return ConditionError(); - return ConditionResult(ConditionVar, MakeFullExpr(E.get(), StmtLoc)); -} - /// \brief Check the use of the given variable as a C++ condition in an if, /// while, do-while, or switch statement. ExprResult Sema::CheckConditionVariable(VarDecl *ConditionVar, SourceLocation StmtLoc, - ConditionKind CK) { + bool ConvertToBoolean) { if (ConditionVar->isInvalidDecl()) return ExprError(); @@ -3092,15 +3082,13 @@ ExprResult Sema::CheckConditionVariable(VarDecl *ConditionVar, MarkDeclRefReferenced(cast<DeclRefExpr>(Condition.get())); - switch (CK) { - case ConditionKind::Boolean: - return CheckBooleanCondition(StmtLoc, Condition.get()); - - case ConditionKind::Switch: - return CheckSwitchCondition(StmtLoc, Condition.get()); + if (ConvertToBoolean) { + Condition = CheckBooleanCondition(Condition.get(), StmtLoc); + if (Condition.isInvalid()) + return ExprError(); } - llvm_unreachable("unexpected condition kind"); + return Condition; } /// CheckCXXBooleanCondition - Returns true if a conversion to bool is invalid. |

