Author: Timm Bäder Date: 2023-07-02T06:49:55+02:00 New Revision: 381e8052d0966a247f811cfc301059393d3c650a
URL: https://github.com/llvm/llvm-project/commit/381e8052d0966a247f811cfc301059393d3c650a DIFF: https://github.com/llvm/llvm-project/commit/381e8052d0966a247f811cfc301059393d3c650a.diff LOG: [clang][Sema][NFC] Make worklist in CheckForIntOverflow const Added: Modified: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaChecking.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 4cb02f31b6514f..eed23e5ba99c89 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -13745,7 +13745,7 @@ class Sema final { private: void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation()); void CheckBoolLikeConversion(Expr *E, SourceLocation CC); - void CheckForIntOverflow(Expr *E); + void CheckForIntOverflow(const Expr *E); void CheckUnsequencedOperations(const Expr *E); /// Perform semantic checks on a completed expression. This will either diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 09ce790f7b5ca1..294d9bfac73a5c 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -15189,39 +15189,39 @@ void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) { /// Diagnose when expression is an integer constant expression and its evaluation /// results in integer overflow -void Sema::CheckForIntOverflow (Expr *E) { +void Sema::CheckForIntOverflow (const Expr *E) { // Use a work list to deal with nested struct initializers. - SmallVector<Expr *, 2> Exprs(1, E); + SmallVector<const Expr *, 2> Exprs(1, E); do { - Expr *OriginalE = Exprs.pop_back_val(); - Expr *E = OriginalE->IgnoreParenCasts(); + const Expr *OriginalE = Exprs.pop_back_val(); + const Expr *E = OriginalE->IgnoreParenCasts(); if (isa<BinaryOperator, UnaryOperator>(E)) { E->EvaluateForOverflow(Context); continue; } - if (auto InitList = dyn_cast<InitListExpr>(OriginalE)) + if (const auto *InitList = dyn_cast<InitListExpr>(OriginalE)) Exprs.append(InitList->inits().begin(), InitList->inits().end()); else if (isa<ObjCBoxedExpr>(OriginalE)) E->EvaluateForOverflow(Context); - else if (auto Call = dyn_cast<CallExpr>(E)) + else if (const auto *Call = dyn_cast<CallExpr>(E)) Exprs.append(Call->arg_begin(), Call->arg_end()); - else if (auto Message = dyn_cast<ObjCMessageExpr>(E)) + else if (const auto *Message = dyn_cast<ObjCMessageExpr>(E)) Exprs.append(Message->arg_begin(), Message->arg_end()); - else if (auto Construct = dyn_cast<CXXConstructExpr>(E)) + else if (const auto *Construct = dyn_cast<CXXConstructExpr>(E)) Exprs.append(Construct->arg_begin(), Construct->arg_end()); - else if (auto Temporary = dyn_cast<CXXBindTemporaryExpr>(E)) + else if (const auto *Temporary = dyn_cast<CXXBindTemporaryExpr>(E)) Exprs.push_back(Temporary->getSubExpr()); - else if (auto Array = dyn_cast<ArraySubscriptExpr>(E)) + else if (const auto *Array = dyn_cast<ArraySubscriptExpr>(E)) Exprs.push_back(Array->getIdx()); - else if (auto Compound = dyn_cast<CompoundLiteralExpr>(E)) + else if (const auto *Compound = dyn_cast<CompoundLiteralExpr>(E)) Exprs.push_back(Compound->getInitializer()); - else if (auto New = dyn_cast<CXXNewExpr>(E)) { - if (New->isArray()) - if (auto ArraySize = New->getArraySize()) - Exprs.push_back(*ArraySize); + else if (const auto *New = dyn_cast<CXXNewExpr>(E); + New && New->isArray()) { + if (auto ArraySize = New->getArraySize()) + Exprs.push_back(*ArraySize); } } while (!Exprs.empty()); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits