Skip to content

Commit 381e805

Browse files
committed
[clang][Sema][NFC] Make worklist in CheckForIntOverflow const
1 parent 0a9d2fa commit 381e805

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13745,7 +13745,7 @@ class Sema final {
1374513745
private:
1374613746
void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
1374713747
void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
13748-
void CheckForIntOverflow(Expr *E);
13748+
void CheckForIntOverflow(const Expr *E);
1374913749
void CheckUnsequencedOperations(const Expr *E);
1375013750

1375113751
/// Perform semantic checks on a completed expression. This will either

clang/lib/Sema/SemaChecking.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15189,39 +15189,39 @@ void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) {
1518915189

1519015190
/// Diagnose when expression is an integer constant expression and its evaluation
1519115191
/// results in integer overflow
15192-
void Sema::CheckForIntOverflow (Expr *E) {
15192+
void Sema::CheckForIntOverflow (const Expr *E) {
1519315193
// Use a work list to deal with nested struct initializers.
15194-
SmallVector<Expr *, 2> Exprs(1, E);
15194+
SmallVector<const Expr *, 2> Exprs(1, E);
1519515195

1519615196
do {
15197-
Expr *OriginalE = Exprs.pop_back_val();
15198-
Expr *E = OriginalE->IgnoreParenCasts();
15197+
const Expr *OriginalE = Exprs.pop_back_val();
15198+
const Expr *E = OriginalE->IgnoreParenCasts();
1519915199

1520015200
if (isa<BinaryOperator, UnaryOperator>(E)) {
1520115201
E->EvaluateForOverflow(Context);
1520215202
continue;
1520315203
}
1520415204

15205-
if (auto InitList = dyn_cast<InitListExpr>(OriginalE))
15205+
if (const auto *InitList = dyn_cast<InitListExpr>(OriginalE))
1520615206
Exprs.append(InitList->inits().begin(), InitList->inits().end());
1520715207
else if (isa<ObjCBoxedExpr>(OriginalE))
1520815208
E->EvaluateForOverflow(Context);
15209-
else if (auto Call = dyn_cast<CallExpr>(E))
15209+
else if (const auto *Call = dyn_cast<CallExpr>(E))
1521015210
Exprs.append(Call->arg_begin(), Call->arg_end());
15211-
else if (auto Message = dyn_cast<ObjCMessageExpr>(E))
15211+
else if (const auto *Message = dyn_cast<ObjCMessageExpr>(E))
1521215212
Exprs.append(Message->arg_begin(), Message->arg_end());
15213-
else if (auto Construct = dyn_cast<CXXConstructExpr>(E))
15213+
else if (const auto *Construct = dyn_cast<CXXConstructExpr>(E))
1521415214
Exprs.append(Construct->arg_begin(), Construct->arg_end());
15215-
else if (auto Temporary = dyn_cast<CXXBindTemporaryExpr>(E))
15215+
else if (const auto *Temporary = dyn_cast<CXXBindTemporaryExpr>(E))
1521615216
Exprs.push_back(Temporary->getSubExpr());
15217-
else if (auto Array = dyn_cast<ArraySubscriptExpr>(E))
15217+
else if (const auto *Array = dyn_cast<ArraySubscriptExpr>(E))
1521815218
Exprs.push_back(Array->getIdx());
15219-
else if (auto Compound = dyn_cast<CompoundLiteralExpr>(E))
15219+
else if (const auto *Compound = dyn_cast<CompoundLiteralExpr>(E))
1522015220
Exprs.push_back(Compound->getInitializer());
15221-
else if (auto New = dyn_cast<CXXNewExpr>(E)) {
15222-
if (New->isArray())
15223-
if (auto ArraySize = New->getArraySize())
15224-
Exprs.push_back(*ArraySize);
15221+
else if (const auto *New = dyn_cast<CXXNewExpr>(E);
15222+
New && New->isArray()) {
15223+
if (auto ArraySize = New->getArraySize())
15224+
Exprs.push_back(*ArraySize);
1522515225
}
1522615226
} while (!Exprs.empty());
1522715227
}

0 commit comments

Comments
 (0)