[clang] 7521ce9 - [clang][bytecode] Don't get the expr without emitting a diagnostic (#141953)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 29 08:18:45 PDT 2025
Author: Timm Baeder
Date: 2025-05-29T17:18:42+02:00
New Revision: 7521ce9963733491229f612208cd44ab5b0337c8
URL: https://github.com/llvm/llvm-project/commit/7521ce9963733491229f612208cd44ab5b0337c8
DIFF: https://github.com/llvm/llvm-project/commit/7521ce9963733491229f612208cd44ab5b0337c8.diff
LOG: [clang][bytecode] Don't get the expr without emitting a diagnostic (#141953)
Added:
Modified:
clang/lib/AST/ByteCode/Interp.h
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 5473733578d7e..33de09a263b3e 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -200,15 +200,16 @@ bool CheckShift(InterpState &S, CodePtr OpPC, const LT &LHS, const RT &RHS,
if constexpr (Dir == ShiftDir::Left) {
if (LHS.isSigned() && !S.getLangOpts().CPlusPlus20) {
- const Expr *E = S.Current->getExpr(OpPC);
// C++11 [expr.shift]p2: A signed left shift must have a non-negative
// operand, and must not overflow the corresponding unsigned type.
if (LHS.isNegative()) {
+ const Expr *E = S.Current->getExpr(OpPC);
S.CCEDiag(E, diag::note_constexpr_lshift_of_negative) << LHS.toAPSInt();
if (!S.noteUndefinedBehavior())
return false;
} else if (LHS.toUnsigned().countLeadingZeros() <
static_cast<unsigned>(RHS)) {
+ const Expr *E = S.Current->getExpr(OpPC);
S.CCEDiag(E, diag::note_constexpr_lshift_discards);
if (!S.noteUndefinedBehavior())
return false;
More information about the cfe-commits
mailing list