diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 18 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 10 |
3 files changed, 11 insertions, 23 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 9bb532b532..44513020bb 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -3662,12 +3662,10 @@ bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, Expr *OriginalInit = Init->IgnoreParenImpCasts(); - Expr::EvalResult InitValue; - if (!OriginalInit->EvaluateAsRValue(InitValue, S.Context) || - !InitValue.Val.isInt()) + llvm::APSInt Value; + if (!OriginalInit->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) return false; - const llvm::APSInt &Value = InitValue.Val.getInt(); unsigned OriginalWidth = Value.getBitWidth(); unsigned FieldWidth = Bitfield->getBitWidthValue(S.Context); diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 2325711b29..d79218d849 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -16,7 +16,6 @@ #include "clang/Sema/ScopeInfo.h" #include "clang/Sema/Initialization.h" #include "clang/Sema/Lookup.h" -#include "clang/AST/APValue.h" #include "clang/AST/ASTContext.h" #include "clang/AST/CharUnits.h" #include "clang/AST/DeclObjC.h" @@ -664,20 +663,15 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // condition is constant. llvm::APSInt ConstantCondValue; bool HasConstantCond = false; - bool ShouldCheckConstantCond = false; if (!HasDependentValue && !TheDefaultStmt) { - Expr::EvalResult Result; HasConstantCond - = CondExprBeforePromotion->EvaluateAsRValue(Result, Context); - if (HasConstantCond) { - assert(Result.Val.isInt() && "switch condition evaluated to non-int"); - ConstantCondValue = Result.Val.getInt(); - ShouldCheckConstantCond = true; - - assert(ConstantCondValue.getBitWidth() == CondWidth && - ConstantCondValue.isSigned() == CondIsSigned); - } + = CondExprBeforePromotion->EvaluateAsInt(ConstantCondValue, Context, + Expr::SE_AllowSideEffects); + assert(!HasConstantCond || + (ConstantCondValue.getBitWidth() == CondWidth && + ConstantCondValue.isSigned() == CondIsSigned)); } + bool ShouldCheckConstantCond = HasConstantCond; // Sort all the scalar case values so we can easily detect duplicates. std::stable_sort(CaseVals.begin(), CaseVals.end(), CmpCaseVals); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 53a541ab46..34f6a93528 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1180,13 +1180,9 @@ static bool isArraySizeVLA(Expr *ArraySize, llvm::APSInt &SizeVal, Sema &S) { // If we're in a GNU mode (like gnu99, but not c99) accept any evaluatable // value as an extension. - Expr::EvalResult Result; - if (S.LangOpts.GNUMode && ArraySize->EvaluateAsRValue(Result, S.Context)) { - if (!Result.hasSideEffects() && Result.Val.isInt()) { - SizeVal = Result.Val.getInt(); - S.Diag(ArraySize->getLocStart(), diag::ext_vla_folded_to_constant); - return false; - } + if (S.LangOpts.GNUMode && ArraySize->EvaluateAsInt(SizeVal, S.Context)) { + S.Diag(ArraySize->getLocStart(), diag::ext_vla_folded_to_constant); + return false; } return true; |