From: Richard Trieu Date: Mon, 23 Jul 2012 20:21:35 +0000 (+0000) Subject: Change APInt to APSInt in one instance. Also change a call to operator==() to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1ecdc168175719d74e112bcacd4aae5e12d4631;p=clang Change APInt to APSInt in one instance. Also change a call to operator==() to APSInt::isSameValue() when comparing different sized APSInt's. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160641 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 26a31cdad4..33776b6c59 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1104,7 +1104,7 @@ static CSFC_Result CollectStatementsForCase(const Stmt *S, /// for a switch on constant. See the comment above CollectStatementsForCase /// for more details. static bool FindCaseStatementsForValue(const SwitchStmt &S, - const llvm::APInt &ConstantCondValue, + const llvm::APSInt &ConstantCondValue, SmallVectorImpl &ResultStmts, ASTContext &C) { // First step, find the switch case that is being branched to. We can do this @@ -1168,7 +1168,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) { // See if we can constant fold the condition of the switch and therefore only // emit the live case statement (if any) of the switch. - llvm::APInt ConstantCondValue; + llvm::APSInt ConstantCondValue; if (ConstantFoldsToSimpleInteger(S.getCond(), ConstantCondValue)) { SmallVector CaseStmts; if (FindCaseStatementsForValue(S, ConstantCondValue, CaseStmts, diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index fcd0fd9358..1d02861ed7 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -606,7 +606,7 @@ bool CodeGenFunction::containsBreak(const Stmt *S) { /// constant folds return true and set the boolean result in Result. bool CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond, bool &ResultBool) { - llvm::APInt ResultInt; + llvm::APSInt ResultInt; if (!ConstantFoldsToSimpleInteger(Cond, ResultInt)) return false; @@ -618,7 +618,7 @@ bool CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond, /// to a constant, or if it does but contains a label, return false. If it /// constant folds return true and set the folded value. bool CodeGenFunction:: -ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APInt &ResultInt) { +ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APSInt &ResultInt) { // FIXME: Rename and handle conversion of other evaluatable things // to bool. llvm::APSInt Int; diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index b737a9ed7a..697571bf1e 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -2511,7 +2511,7 @@ public: /// ConstantFoldsToSimpleInteger - If the specified expression does not fold /// to a constant, or if it does but contains a label, return false. If it /// constant folds return true and set the folded value. - bool ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APInt &Result); + bool ConstantFoldsToSimpleInteger(const Expr *Cond, llvm::APSInt &Result); /// EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g. for an /// if statement) to the specified blocks. Based on the condition, this might diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 2e92067665..73f9b01594 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -4259,7 +4259,7 @@ static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init, // Check whether the stored value is equal to the original value. TruncatedValue = TruncatedValue.extend(OriginalWidth); - if (Value == TruncatedValue) + if (llvm::APSInt::isSameValue(Value, TruncatedValue)) return false; // Special-case bitfields of width 1: booleans are naturally 0/1, and