llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Baranov Victor (vbvictor) <details> <summary>Changes</summary> --- Patch is 33.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/167131.diff 19 Files Affected: - (modified) clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp (+3-3) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp (+4-4) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp (+3-3) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp (+7-5) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp (+10-10) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp (+10-8) - (modified) clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp (+4-4) - (modified) clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp (+16-16) - (modified) clang-tools-extra/clang-tidy/bugprone/UncheckedStringToNumberConversionCheck.cpp (+3-2) - (modified) clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp (+3-2) - (modified) clang-tools-extra/clang-tidy/bugprone/UnintendedCharOstreamOutputCheck.cpp (+3-3) - (modified) clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp (+2-1) - (modified) clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp (+3-3) - (modified) clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp (+20-20) ``````````diff diff --git a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp index 93a55ef549896..8454fd1045673 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp @@ -129,7 +129,7 @@ void StringIntegerAssignmentCheck::check( const auto *Argument = Result.Nodes.getNodeAs<Expr>("expr"); const auto CharType = Result.Nodes.getNodeAs<QualType>("type")->getCanonicalType(); - SourceLocation Loc = Argument->getBeginLoc(); + const SourceLocation Loc = Argument->getBeginLoc(); // Try to detect a few common expressions to reduce false positives. if (CharExpressionDetector(CharType, *Result.Context) @@ -145,7 +145,7 @@ void StringIntegerAssignmentCheck::check( if (Loc.isMacroID()) return; - bool IsWideCharType = CharType->isWideCharType(); + const bool IsWideCharType = CharType->isWideCharType(); if (!CharType->isCharType() && !IsWideCharType) return; bool IsOneDigit = false; @@ -155,7 +155,7 @@ void StringIntegerAssignmentCheck::check( IsLiteral = true; } - SourceLocation EndLoc = Lexer::getLocForEndOfToken( + const SourceLocation EndLoc = Lexer::getLocForEndOfToken( Argument->getEndLoc(), 0, *Result.SourceManager, getLangOpts()); if (IsOneDigit) { Diag << FixItHint::CreateInsertion(Loc, IsWideCharType ? "L'" : "'") diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp index 8dbe1c0153f35..ef7f0b5b54eb3 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp @@ -54,7 +54,7 @@ static int enumLength(const EnumDecl *EnumDec) { static bool hasDisjointValueRange(const EnumDecl *Enum1, const EnumDecl *Enum2) { - ValueRange Range1(Enum1), Range2(Enum2); + const ValueRange Range1(Enum1), Range2(Enum2); return llvm::APSInt::compareValues(Range1.MaxVal, Range2.MinVal) < 0 || llvm::APSInt::compareValues(Range2.MaxVal, Range1.MinVal) < 0; } @@ -94,9 +94,9 @@ static int countNonPowOfTwoLiteralNum(const EnumDecl *EnumDec) { /// last enumerator is the sum of the lesser values (and initialized by a /// literal) or when it could contain consecutive values. static bool isPossiblyBitMask(const EnumDecl *EnumDec) { - ValueRange VR(EnumDec); - int EnumLen = enumLength(EnumDec); - int NonPowOfTwoCounter = countNonPowOfTwoLiteralNum(EnumDec); + const ValueRange VR(EnumDec); + const int EnumLen = enumLength(EnumDec); + const int NonPowOfTwoCounter = countNonPowOfTwoLiteralNum(EnumDec); return NonPowOfTwoCounter >= 1 && NonPowOfTwoCounter <= 2 && NonPowOfTwoCounter < EnumLen / 2 && (VR.MaxVal - VR.MinVal != EnumLen - 1) && diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp index aaf0594a02dfc..5abbadafc0d63 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp @@ -66,7 +66,7 @@ void SuspiciousIncludePPCallbacks::InclusionDirective( if (!Check.IgnoredRegexString.empty() && Check.IgnoredRegex.match(FileName)) return; - SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1); + const SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1); const std::optional<StringRef> IFE = utils::getFileExtension(FileName, Check.ImplementationFileExtensions); @@ -81,7 +81,7 @@ void SuspiciousIncludePPCallbacks::InclusionDirective( llvm::sys::path::replace_extension(GuessedFileName, (!HFE.empty() ? "." : "") + HFE); - OptionalFileEntryRef File = + const OptionalFileEntryRef File = PP->LookupFile(DiagLoc, GuessedFileName, IsAngled, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); if (File) { diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp index d1df2a8634035..7890afb41addb 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp @@ -44,10 +44,10 @@ void SuspiciousMemoryComparisonCheck::check( for (unsigned int ArgIndex = 0; ArgIndex < 2; ++ArgIndex) { const Expr *ArgExpr = CE->getArg(ArgIndex); - QualType ArgType = ArgExpr->IgnoreImplicit()->getType(); + const QualType ArgType = ArgExpr->IgnoreImplicit()->getType(); const Type *PointeeType = ArgType->getPointeeOrArrayElementType(); assert(PointeeType != nullptr && "PointeeType should always be available."); - QualType PointeeQualifiedType(PointeeType, 0); + const QualType PointeeQualifiedType(PointeeType, 0); if (PointeeType->isRecordType()) { if (const RecordDecl *RD = @@ -65,7 +65,7 @@ void SuspiciousMemoryComparisonCheck::check( } if (!PointeeType->isIncompleteType()) { - uint64_t PointeeSize = Ctx.getTypeSize(PointeeType); + const uint64_t PointeeSize = Ctx.getTypeSize(PointeeType); if (ComparedBits && *ComparedBits >= PointeeSize && !Ctx.hasUniqueObjectRepresentations(PointeeQualifiedType)) { diag(CE->getBeginLoc(), diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp index b1d12ba306814..51ae132ce38a6 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp @@ -60,7 +60,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) { // Case 1: fill_char of memset() is a character '0'. Probably an // integer zero was intended. - SourceRange CharRange = CharZeroFill->getSourceRange(); + const SourceRange CharRange = CharZeroFill->getSourceRange(); auto Diag = diag(CharZeroFill->getBeginLoc(), "memset fill value is char '0', " "potentially mistaken for int 0"); @@ -82,7 +82,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) { if (!NumFill->EvaluateAsInt(EVResult, *Result.Context)) return; - llvm::APSInt NumValue = EVResult.Val.getInt(); + const llvm::APSInt NumValue = EVResult.Val.getInt(); if (NumValue >= 0 && NumValue <= UCharMax) return; @@ -110,7 +110,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) { Expr::EvalResult EVResult; if (!FillChar->isValueDependent() && FillChar->EvaluateAsInt(EVResult, *Result.Context)) { - llvm::APSInt Value1 = EVResult.Val.getInt(); + const llvm::APSInt Value1 = EVResult.Val.getInt(); if (Value1 == 0 || Value1.isNegative()) return; } @@ -120,8 +120,10 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) { // and fix-its to swap the arguments. auto D = diag(Call->getBeginLoc(), "memset of size zero, potentially swapped arguments"); - StringRef RHSString = tooling::fixit::getText(*ByteCount, *Result.Context); - StringRef LHSString = tooling::fixit::getText(*FillChar, *Result.Context); + const StringRef RHSString = + tooling::fixit::getText(*ByteCount, *Result.Context); + const StringRef LHSString = + tooling::fixit::getText(*FillChar, *Result.Context); if (LHSString.empty() || RHSString.empty()) return; diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp index a41f65083653a..cf8bc9794d9ce 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp @@ -19,7 +19,7 @@ static bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx, // String literals surrounded by parentheses are assumed to be on purpose. // i.e.: const char* Array[] = { ("a" "b" "c"), "d", [...] }; - TraversalKindScope RAII(*Ctx, TK_AsIs); + const TraversalKindScope RAII(*Ctx, TK_AsIs); auto Parents = Ctx->getParents(*Lit); if (Parents.size() == 1 && Parents[0].get<ParenExpr>() != nullptr) return true; @@ -35,15 +35,15 @@ static bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx, // }; const SourceManager &SM = Ctx->getSourceManager(); bool IndentedCorrectly = true; - SourceLocation FirstToken = Lit->getStrTokenLoc(0); - FileID BaseFID = SM.getFileID(FirstToken); - unsigned int BaseIndent = SM.getSpellingColumnNumber(FirstToken); - unsigned int BaseLine = SM.getSpellingLineNumber(FirstToken); + const SourceLocation FirstToken = Lit->getStrTokenLoc(0); + const FileID BaseFID = SM.getFileID(FirstToken); + const unsigned int BaseIndent = SM.getSpellingColumnNumber(FirstToken); + const unsigned int BaseLine = SM.getSpellingLineNumber(FirstToken); for (unsigned int TokNum = 1; TokNum < Lit->getNumConcatenated(); ++TokNum) { - SourceLocation Token = Lit->getStrTokenLoc(TokNum); - FileID FID = SM.getFileID(Token); - unsigned int Indent = SM.getSpellingColumnNumber(Token); - unsigned int Line = SM.getSpellingLineNumber(Token); + const SourceLocation Token = Lit->getStrTokenLoc(TokNum); + const FileID FID = SM.getFileID(Token); + const unsigned int Indent = SM.getSpellingColumnNumber(Token); + const unsigned int Line = SM.getSpellingLineNumber(Token); if (FID != BaseFID || Line != BaseLine + TokNum || Indent <= BaseIndent) { IndentedCorrectly = false; break; @@ -100,7 +100,7 @@ void SuspiciousMissingCommaCheck::check( assert(InitializerList && ConcatenatedLiteral); // Skip small arrays as they often generate false-positive. - unsigned int Size = InitializerList->getNumInits(); + const unsigned int Size = InitializerList->getNumInits(); if (Size < SizeThreshold) return; diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp index b5da8016f2cc8..7cc3630204e63 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp @@ -44,7 +44,7 @@ class IsSamePtrExpr : public StmtVisitor<IsSamePtrExpr, bool> { return false; if (!check(E1->getBase(), E2->getBase())) return false; - DeclAccessPair FD = E1->getFoundDecl(); + const DeclAccessPair FD = E1->getFoundDecl(); return isa<FieldDecl>(FD.getDecl()) && FD == E2->getFoundDecl(); } @@ -145,7 +145,7 @@ void SuspiciousReallocUsageCheck::check( if (FindAssignToVarBefore{Var, DeclRef, SM}.Visit(Func->getBody())) return; - StringRef CodeOfAssignedExpr = Lexer::getSourceText( + const StringRef CodeOfAssignedExpr = Lexer::getSourceText( CharSourceRange::getTokenRange(PtrResultExpr->getSourceRange()), SM, getLangOpts()); diag(Call->getBeginLoc(), "'%0' may be set to null if 'realloc' fails, which " diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp index 543d31285af8c..9d37fc1e8728e 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp @@ -31,7 +31,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) { return; const auto *Semicolon = Result.Nodes.getNodeAs<NullStmt>("semi"); - SourceLocation LocStart = Semicolon->getBeginLoc(); + const SourceLocation LocStart = Semicolon->getBeginLoc(); if (LocStart.isMacroID()) return; @@ -40,7 +40,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) { auto Token = utils::lexer::getPreviousToken(LocStart, Ctxt.getSourceManager(), Ctxt.getLangOpts()); auto &SM = *Result.SourceManager; - unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart); + const unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart); const auto *Statement = Result.Nodes.getNodeAs<Stmt>("stmt"); const bool IsIfStmt = isa<IfStmt>(Statement); @@ -49,18 +49,20 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) { SM.getSpellingLineNumber(Token.getLocation()) != SemicolonLine) return; - SourceLocation LocEnd = Semicolon->getEndLoc(); - FileID FID = SM.getFileID(LocEnd); - llvm::MemoryBufferRef Buffer = SM.getBufferOrFake(FID, LocEnd); + const SourceLocation LocEnd = Semicolon->getEndLoc(); + const FileID FID = SM.getFileID(LocEnd); + const llvm::MemoryBufferRef Buffer = SM.getBufferOrFake(FID, LocEnd); Lexer Lexer(SM.getLocForStartOfFile(FID), Ctxt.getLangOpts(), Buffer.getBufferStart(), SM.getCharacterData(LocEnd) + 1, Buffer.getBufferEnd()); if (Lexer.LexFromRawLexer(Token)) return; - unsigned BaseIndent = SM.getSpellingColumnNumber(Statement->getBeginLoc()); - unsigned NewTokenIndent = SM.getSpellingColumnNumber(Token.getLocation()); - unsigned NewTokenLine = SM.getSpellingLineNumber(Token.getLocation()); + const unsigned BaseIndent = + SM.getSpellingColumnNumber(Statement->getBeginLoc()); + const unsigned NewTokenIndent = + SM.getSpellingColumnNumber(Token.getLocation()); + const unsigned NewTokenLine = SM.getSpellingLineNumber(Token.getLocation()); if (!IsIfStmt && NewTokenIndent <= BaseIndent && Token.getKind() != tok::l_brace && NewTokenLine != SemicolonLine) diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp index 7519685418c8c..5da9240de74dc 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp @@ -88,7 +88,7 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) { // Add the list of known string compare-like functions and add user-defined // functions. - std::vector<StringRef> FunctionNames = utils::options::parseListPair( + const std::vector<StringRef> FunctionNames = utils::options::parseListPair( KnownStringCompareFunctions, StringCompareLikeFunctions); // Match a call to a string compare functions. @@ -163,7 +163,7 @@ void SuspiciousStringCompareCheck::check( assert(Decl != nullptr && Call != nullptr); if (Result.Nodes.getNodeAs<Stmt>("missing-comparison")) { - SourceLocation EndLoc = Lexer::getLocForEndOfToken( + const SourceLocation EndLoc = Lexer::getLocForEndOfToken( Call->getRParenLoc(), 0, Result.Context->getSourceManager(), getLangOpts()); @@ -173,10 +173,10 @@ void SuspiciousStringCompareCheck::check( } if (const auto *E = Result.Nodes.getNodeAs<Expr>("logical-not-comparison")) { - SourceLocation EndLoc = Lexer::getLocForEndOfToken( + const SourceLocation EndLoc = Lexer::getLocForEndOfToken( Call->getRParenLoc(), 0, Result.Context->getSourceManager(), getLangOpts()); - SourceLocation NotLoc = E->getBeginLoc(); + const SourceLocation NotLoc = E->getBeginLoc(); diag(Call->getBeginLoc(), "function %0 is compared using logical not operator") diff --git a/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp index bcedff5ef5aa2..152c0cbd106f5 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SwappedArgumentsCheck.cpp @@ -70,7 +70,7 @@ static bool areArgumentsPotentiallySwapped(const QualType LTo, if (LTo == RFrom && REq) return true; - bool LEq = areTypesSemiEqual(LTo, RFrom); + const bool LEq = areTypesSemiEqual(LTo, RFrom); if (RTo == LFrom && LEq) return true; diff --git a/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp index 56ec5a5af182e..80905e260d5d4 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ThrowingStaticInitializationCheck.cpp @@ -44,7 +44,7 @@ void ThrowingStaticInitializationCheck::check( "duration may throw an exception that cannot be caught") << VD << (VD->getStorageDuration() == SD_Static ? 0 : 1); - SourceLocation FuncLocation = Func->getLocation(); + const SourceLocation FuncLocation = Func->getLocation(); if (FuncLocation.isValid()) { diag(FuncLocation, "possibly throwing %select{constructor|function}0 declared here", diff --git a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp index 536b6806c66e6..71b785f1c04f1 100644 --- a/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp @@ -67,21 +67,21 @@ void TooSmallLoopVariableCheck::storeOptions( /// LoopName: The entire for loop (as a ForStmt) /// void TooSmallLoopVariableCheck::registerMatchers(MatchFinder *Finder) { - StatementMatcher LoopVarMatcher = + const StatementMatcher LoopVarMatcher = expr(ignoringParenImpCasts( anyOf(declRefExpr(to(varDecl(hasType(isInteger())))), memberExpr(member(fieldDecl(hasType(isInteger()))))))) .bind(LoopVarName); // We need to catch only those comparisons which contain any integer cast. - StatementMatcher LoopVarConversionMatcher = traverse( + const StatementMatcher LoopVarConversionMatcher = traverse( TK_AsIs, implicitCastExpr(hasImplicitDestinationType(isInteger()), has(ignoringParenImpCasts(LoopVarMatcher))) .bind(LoopVarCastName)); // We are interested in only those cases when the loop bound is a variable // value (not const, enum, etc.). - StatementMatcher LoopBoundMatcher = + const StatementMatcher LoopBoundMatcher = expr(ignoringParenImpCasts(allOf( hasType(isInteger()), unless(integerLiteral()), unless(allOf( @@ -94,7 +94,7 @@ void TooSmallLoopVariableCheck::registerMatchers(MatchFinder *Finder) { // We use the loop increment expression only to make sure we found the right // loop variable. - StatementMatcher IncrementMatcher = + const StatementMatcher IncrementMatcher = expr(ignoringParenImpCasts(hasType(isInteger()))).bind(LoopIncrementName); Finder->addMatcher( @@ -121,14 +121,14 @@ static MagnitudeBits calcMagnitudeBits(const ASTContext &Context, const Expr *IntExpr) { assert(IntExprType->isIntegerType()); - unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U; + const unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U; if (const auto *BitField = IntExpr->getSourceBitField()) { - unsigned BitFieldWidth = BitField->getBitWidthValue(); + const unsigned BitFieldWidth = BitField->getBitWidthValue(); return {BitFieldWidth - SignedBits, BitFieldWidth}; } - unsigned IntWidth = Context.getIntWidth(IntExprType); + const unsigned IntWidth = Context.getIntWidth(IntExprType); return {IntWidth - SignedBits, 0U}; } @@ -143,18 +143,18 @@ calcUpperBoundMagnitudeBits(const ASTContext &Context, const Expr *UpperBound, const Expr *RHSE = BinOperator->getRHS()->IgnoreParenImpCasts(); const Expr *LHSE = BinOperator->getLHS()->IgnoreParenImpCasts(); - QualType RHSEType = RHSE->getType(); - QualType LHSEType = LHSE->getType(); + const QualType RHSEType = RHSE->getType(); + const QualType LHSEType = LHSE->getType(); if (!RHSEType->isIntegerType() || !LHSET... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/167131 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
