Skip to content

Commit 63992b0

Browse files
committed
Revert 347366, its prerequisite 347364 got reverted.
llvm-svn: 347390
1 parent 9f0246d commit 63992b0

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ static unsigned getMaxCalculationWidth(const ASTContext &Context,
6565
if (Bop->getOpcode() == BO_Add)
6666
return std::max(LHSWidth, RHSWidth) + 1;
6767
if (Bop->getOpcode() == BO_Rem) {
68-
Expr::EvalResult Result;
69-
if (Bop->getRHS()->EvaluateAsInt(Result, Context))
70-
return Result.Val.getInt().getActiveBits();
68+
llvm::APSInt Val;
69+
if (Bop->getRHS()->EvaluateAsInt(Val, Context))
70+
return Val.getActiveBits();
7171
} else if (Bop->getOpcode() == BO_Shl) {
72-
Expr::EvalResult Result;
73-
if (Bop->getRHS()->EvaluateAsInt(Result, Context)) {
72+
llvm::APSInt Bits;
73+
if (Bop->getRHS()->EvaluateAsInt(Bits, Context)) {
7474
// We don't handle negative values and large values well. It is assumed
7575
// that compiler warnings are written for such values so the user will
7676
// fix that.
77-
return LHSWidth + Result.Val.getInt().getExtValue();
77+
return LHSWidth + Bits.getExtValue();
7878
}
7979

8080
// Unknown bitcount, assume there is truncation.

clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,10 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
7676
// Case 2: fill_char of memset() is larger in size than an unsigned char
7777
// so it gets truncated during conversion.
7878

79+
llvm::APSInt NumValue;
7980
const auto UCharMax = (1 << Result.Context->getCharWidth()) - 1;
80-
Expr::EvalResult EVResult;
81-
if (!NumFill->EvaluateAsInt(EVResult, *Result.Context))
82-
return;
83-
84-
llvm::APSInt NumValue = EVResult.Val.getInt();
85-
if (NumValue >= 0 && NumValue <= UCharMax)
81+
if (!NumFill->EvaluateAsInt(NumValue, *Result.Context) ||
82+
(NumValue >= 0 && NumValue <= UCharMax))
8683
return;
8784

8885
diag(NumFill->getBeginLoc(), "memset fill value is out of unsigned "
@@ -97,22 +94,18 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
9794
const Expr *ByteCount = Call->getArg(2);
9895

9996
// Return if `byte_count` is not zero at compile time.
100-
Expr::EvalResult Value2;
97+
llvm::APSInt Value1, Value2;
10198
if (ByteCount->isValueDependent() ||
102-
!ByteCount->EvaluateAsInt(Value2, *Result.Context) ||
103-
Value2.Val.getInt() != 0)
99+
!ByteCount->EvaluateAsInt(Value2, *Result.Context) || Value2 != 0)
104100
return;
105101

106102
// Return if `fill_char` is known to be zero or negative at compile
107103
// time. In these cases, swapping the args would be a nop, or
108104
// introduce a definite bug. The code is likely correct.
109-
Expr::EvalResult EVResult;
110105
if (!FillChar->isValueDependent() &&
111-
FillChar->EvaluateAsInt(EVResult, *Result.Context)) {
112-
llvm::APSInt Value1 = EVResult.Val.getInt();
113-
if (Value1 == 0 || Value1.isNegative())
114-
return;
115-
}
106+
FillChar->EvaluateAsInt(Value1, *Result.Context) &&
107+
(Value1 == 0 || Value1.isNegative()))
108+
return;
116109

117110
// `byte_count` is known to be zero at compile time, and `fill_char` is
118111
// either not known or known to be a positive integer. Emit a warning

clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ void ProperlySeededRandomGeneratorCheck::checkSeed(
101101
return;
102102
}
103103

104-
Expr::EvalResult EVResult;
105-
if (Func->getArg(0)->EvaluateAsInt(EVResult, *Result.Context)) {
104+
llvm::APSInt Value;
105+
if (Func->getArg(0)->EvaluateAsInt(Value, *Result.Context)) {
106106
diag(Func->getExprLoc(),
107107
"random number generator seeded with a constant value will generate a "
108108
"predictable sequence of values");

0 commit comments

Comments
 (0)