[clang-tools-extra] r347390 - Revert 347366, its prerequisite 347364 got reverted.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 21 04:49:22 PST 2018


Author: nico
Date: Wed Nov 21 04:49:22 2018
New Revision: 347390

URL: http://llvm.org/viewvc/llvm-project?rev=347390&view=rev
Log:
Revert 347366, its prerequisite 347364 got reverted.

Modified:
    clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
    clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
    clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp?rev=347390&r1=347389&r2=347390&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp Wed Nov 21 04:49:22 2018
@@ -65,16 +65,16 @@ static unsigned getMaxCalculationWidth(c
     if (Bop->getOpcode() == BO_Add)
       return std::max(LHSWidth, RHSWidth) + 1;
     if (Bop->getOpcode() == BO_Rem) {
-      Expr::EvalResult Result;
-      if (Bop->getRHS()->EvaluateAsInt(Result, Context))
-        return Result.Val.getInt().getActiveBits();
+      llvm::APSInt Val;
+      if (Bop->getRHS()->EvaluateAsInt(Val, Context))
+        return Val.getActiveBits();
     } else if (Bop->getOpcode() == BO_Shl) {
-      Expr::EvalResult Result;
-      if (Bop->getRHS()->EvaluateAsInt(Result, Context)) {
+      llvm::APSInt Bits;
+      if (Bop->getRHS()->EvaluateAsInt(Bits, Context)) {
         // We don't handle negative values and large values well. It is assumed
         // that compiler warnings are written for such values so the user will
         // fix that.
-        return LHSWidth + Result.Val.getInt().getExtValue();
+        return LHSWidth + Bits.getExtValue();
       }
 
       // Unknown bitcount, assume there is truncation.

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp?rev=347390&r1=347389&r2=347390&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp Wed Nov 21 04:49:22 2018
@@ -76,13 +76,10 @@ void SuspiciousMemsetUsageCheck::check(c
     // Case 2: fill_char of memset() is larger in size than an unsigned char
     // so it gets truncated during conversion.
 
+    llvm::APSInt NumValue;
     const auto UCharMax = (1 << Result.Context->getCharWidth()) - 1;
-    Expr::EvalResult EVResult;
-    if (!NumFill->EvaluateAsInt(EVResult, *Result.Context))
-      return;
-
-    llvm::APSInt NumValue = EVResult.Val.getInt();
-    if (NumValue >= 0 && NumValue <= UCharMax)
+    if (!NumFill->EvaluateAsInt(NumValue, *Result.Context) ||
+        (NumValue >= 0 && NumValue <= UCharMax))
       return;
 
     diag(NumFill->getBeginLoc(), "memset fill value is out of unsigned "
@@ -97,22 +94,18 @@ void SuspiciousMemsetUsageCheck::check(c
     const Expr *ByteCount = Call->getArg(2);
 
     // Return if `byte_count` is not zero at compile time.
-    Expr::EvalResult Value2;
+    llvm::APSInt Value1, Value2;
     if (ByteCount->isValueDependent() ||
-        !ByteCount->EvaluateAsInt(Value2, *Result.Context) ||
-        Value2.Val.getInt() != 0)
+        !ByteCount->EvaluateAsInt(Value2, *Result.Context) || Value2 != 0)
       return;
 
     // Return if `fill_char` is known to be zero or negative at compile
     // time. In these cases, swapping the args would be a nop, or
     // introduce a definite bug. The code is likely correct.
-    Expr::EvalResult EVResult;
     if (!FillChar->isValueDependent() &&
-        FillChar->EvaluateAsInt(EVResult, *Result.Context)) {
-      llvm::APSInt Value1 = EVResult.Val.getInt();
-      if (Value1 == 0 || Value1.isNegative())
-        return;
-    }
+        FillChar->EvaluateAsInt(Value1, *Result.Context) &&
+        (Value1 == 0 || Value1.isNegative()))
+      return;
 
     // `byte_count` is known to be zero at compile time, and `fill_char` is
     // either not known or known to be a positive integer. Emit a warning

Modified: clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp?rev=347390&r1=347389&r2=347390&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp Wed Nov 21 04:49:22 2018
@@ -101,8 +101,8 @@ void ProperlySeededRandomGeneratorCheck:
     return;
   }
 
-  Expr::EvalResult EVResult;
-  if (Func->getArg(0)->EvaluateAsInt(EVResult, *Result.Context)) {
+  llvm::APSInt Value;
+  if (Func->getArg(0)->EvaluateAsInt(Value, *Result.Context)) {
     diag(Func->getExprLoc(),
          "random number generator seeded with a constant value will generate a "
          "predictable sequence of values");




More information about the cfe-commits mailing list