-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][bytecode][NFC] Only get expr when checking for UB #125397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The Expr and its Type were unused otherwise.
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesThe Expr and its Type were unused otherwise. Full diff: https://github.com/llvm/llvm-project/pull/125397.diff 1 Files Affected:
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 2a39e3932077f57..9f029adc7083908 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -379,15 +379,14 @@ bool AddSubMulHelper(InterpState &S, CodePtr OpPC, unsigned Bits, const T &LHS,
APSInt Value = OpAP<APSInt>()(LHS.toAPSInt(Bits), RHS.toAPSInt(Bits));
// Report undefined behaviour, stopping if required.
- const Expr *E = S.Current->getExpr(OpPC);
- QualType Type = E->getType();
if (S.checkingForUndefinedBehavior()) {
+ const Expr *E = S.Current->getExpr(OpPC);
+ QualType Type = E->getType();
SmallString<32> Trunc;
Value.trunc(Result.bitWidth())
.toString(Trunc, 10, Result.isSigned(), /*formatAsCLiteral=*/false,
/*UpperCase=*/true, /*InsertSeparators=*/true);
- auto Loc = E->getExprLoc();
- S.report(Loc, diag::warn_integer_constant_overflow)
+ S.report(E->getExprLoc(), diag::warn_integer_constant_overflow)
<< Trunc << Type << E->getSourceRange();
}
@@ -737,16 +736,14 @@ bool Neg(InterpState &S, CodePtr OpPC) {
S.Stk.push<T>(Result);
APSInt NegatedValue = -Value.toAPSInt(Value.bitWidth() + 1);
- const Expr *E = S.Current->getExpr(OpPC);
- QualType Type = E->getType();
-
if (S.checkingForUndefinedBehavior()) {
+ const Expr *E = S.Current->getExpr(OpPC);
+ QualType Type = E->getType();
SmallString<32> Trunc;
NegatedValue.trunc(Result.bitWidth())
.toString(Trunc, 10, Result.isSigned(), /*formatAsCLiteral=*/false,
/*UpperCase=*/true, /*InsertSeparators=*/true);
- auto Loc = E->getExprLoc();
- S.report(Loc, diag::warn_integer_constant_overflow)
+ S.report(E->getExprLoc(), diag::warn_integer_constant_overflow)
<< Trunc << Type << E->getSourceRange();
return true;
}
@@ -800,15 +797,14 @@ bool IncDecHelper(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
APResult = --Value.toAPSInt(Bits);
// Report undefined behaviour, stopping if required.
- const Expr *E = S.Current->getExpr(OpPC);
- QualType Type = E->getType();
if (S.checkingForUndefinedBehavior()) {
+ const Expr *E = S.Current->getExpr(OpPC);
+ QualType Type = E->getType();
SmallString<32> Trunc;
APResult.trunc(Result.bitWidth())
.toString(Trunc, 10, Result.isSigned(), /*formatAsCLiteral=*/false,
/*UpperCase=*/true, /*InsertSeparators=*/true);
- auto Loc = E->getExprLoc();
- S.report(Loc, diag::warn_integer_constant_overflow)
+ S.report(E->getExprLoc(), diag::warn_integer_constant_overflow)
<< Trunc << Type << E->getSourceRange();
return true;
}
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/12884 Here is the relevant piece of the build log for the reference
|
The Expr and its Type were unused otherwise.