From 646156bd93ea946a5ab70005e65701fbd1eb2a78 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Tue, 10 Jan 2023 20:19:02 -0800 Subject: [PATCH 1/9] Update clang-tidy to 15.0.6 And rebase the patches --- .github/workflows/clang-tidy-linux.yml | 2 +- .github/workflows/clang-tidy-macos.yml | 4 +- .../0001-Max-tokens-checks.diff} | 0 .../0002-potential-unbounded-loop-check.diff} | 0 .../15.x-patches/0001-Max-tokens-checks.diff | 309 ++ .../0002-potential-unbounded-loop-check.diff | 2982 +++++++++++++++++ tools/clang-tidy-checks/setup.sh | 4 +- 7 files changed, 3296 insertions(+), 5 deletions(-) rename tools/clang-tidy-checks/{max-tokens-check.diff => 11.x-patches/0001-Max-tokens-checks.diff} (100%) rename tools/clang-tidy-checks/{potential-unbounded-loop-check.diff => 11.x-patches/0002-potential-unbounded-loop-check.diff} (100%) create mode 100644 tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff create mode 100644 tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff diff --git a/.github/workflows/clang-tidy-linux.yml b/.github/workflows/clang-tidy-linux.yml index 60e8cc319e..d73cdca6bd 100644 --- a/.github/workflows/clang-tidy-linux.yml +++ b/.github/workflows/clang-tidy-linux.yml @@ -42,7 +42,7 @@ jobs: with: name: clang-tidy if-no-files-found: error - s3-prefix: linux64/11.1.0 + s3-prefix: linux64/15.0.6 s3-bucket: oss-clang-format path: clang-tidy aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} diff --git a/.github/workflows/clang-tidy-macos.yml b/.github/workflows/clang-tidy-macos.yml index 10c57d5127..34b6ab8699 100644 --- a/.github/workflows/clang-tidy-macos.yml +++ b/.github/workflows/clang-tidy-macos.yml @@ -44,7 +44,7 @@ jobs: with: name: clang-tidy if-no-files-found: error - s3-prefix: macos-i386/11.1.0 + s3-prefix: macos-i386/15.0.6 s3-bucket: oss-clang-format path: tools/clang-tidy-checks/llvm-project/build/bin/clang-tidy aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -73,7 +73,7 @@ jobs: with: name: clang-tidy if-no-files-found: error - s3-prefix: macos-arm/11.1.0 + s3-prefix: macos-arm/15.0.6 s3-bucket: oss-clang-format path: tools/clang-tidy-checks/llvm-project/build/bin/clang-tidy aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} diff --git a/tools/clang-tidy-checks/max-tokens-check.diff b/tools/clang-tidy-checks/11.x-patches/0001-Max-tokens-checks.diff similarity index 100% rename from tools/clang-tidy-checks/max-tokens-check.diff rename to tools/clang-tidy-checks/11.x-patches/0001-Max-tokens-checks.diff diff --git a/tools/clang-tidy-checks/potential-unbounded-loop-check.diff b/tools/clang-tidy-checks/11.x-patches/0002-potential-unbounded-loop-check.diff similarity index 100% rename from tools/clang-tidy-checks/potential-unbounded-loop-check.diff rename to tools/clang-tidy-checks/11.x-patches/0002-potential-unbounded-loop-check.diff diff --git a/tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff b/tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff new file mode 100644 index 0000000000..da6fbf7767 --- /dev/null +++ b/tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff @@ -0,0 +1,309 @@ +From e6d62c83b29eeda8c1b7bd45106b8364c45c7c72 Mon Sep 17 00:00:00 2001 +From: Nikita Shulga +Date: Tue, 10 Jan 2023 17:52:43 -0800 +Subject: [PATCH 1/2] Max tokens checks + +--- + .../clang-tidy/misc/CMakeLists.txt | 1 + + .../clang-tidy/misc/MaxTokensCheck.cpp | 66 +++++++++++++++++++ + .../clang-tidy/misc/MaxTokensCheck.h | 37 +++++++++++ + .../clang-tidy/misc/MiscTidyModule.cpp | 2 + + clang-tools-extra/docs/ReleaseNotes.rst | 5 ++ + .../docs/clang-tidy/checks/list.rst | 1 + + .../clang-tidy/checks/misc-max-tokens.rst | 6 ++ + .../clang-tidy/checkers/misc-max-tokens.cpp | 20 ++++++ + clang/include/clang/Lex/PPCallbacks.h | 22 +++++++ + clang/lib/Parse/ParsePragma.cpp | 5 ++ + clang/lib/Parse/Parser.cpp | 10 +++ + 11 files changed, 175 insertions(+) + create mode 100644 clang-tools-extra/clang-tidy/misc/MaxTokensCheck.cpp + create mode 100644 clang-tools-extra/clang-tidy/misc/MaxTokensCheck.h + create mode 100644 clang-tools-extra/docs/clang-tidy/checks/misc-max-tokens.rst + create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc-max-tokens.cpp + +diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +index de76b4b00..6b3084d5d 100644 +--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt ++++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +@@ -31,6 +31,7 @@ add_clang_library(clangTidyMiscModule + ConstCorrectnessCheck.cpp + DefinitionsInHeadersCheck.cpp + ConfusableIdentifierCheck.cpp ++ MaxTokensCheck.cpp + MiscTidyModule.cpp + MisleadingBidirectional.cpp + MisleadingIdentifier.cpp +diff --git a/clang-tools-extra/clang-tidy/misc/MaxTokensCheck.cpp b/clang-tools-extra/clang-tidy/misc/MaxTokensCheck.cpp +new file mode 100644 +index 000000000..1c7e5a18b +--- /dev/null ++++ b/clang-tools-extra/clang-tidy/misc/MaxTokensCheck.cpp +@@ -0,0 +1,66 @@ ++//===--- MaxTokensCheck.cpp - clang-tidy ----------------------------------===// ++// ++// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. ++// See https://llvm.org/LICENSE.txt for license information. ++// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ++// ++//===----------------------------------------------------------------------===// ++ ++#include "MaxTokensCheck.h" ++#include "clang/AST/ASTContext.h" ++#include "clang/ASTMatchers/ASTMatchFinder.h" ++#include "clang/Lex/PPCallbacks.h" ++#include "clang/Lex/Preprocessor.h" ++#include "llvm/Support/FormatVariadic.h" ++ ++using namespace clang::ast_matchers; ++ ++namespace clang { ++namespace tidy { ++namespace misc { ++namespace { ++class MaxTokensPPCallbacks : public PPCallbacks { ++public: ++ MaxTokensPPCallbacks(MaxTokensCheck *Check) : Check(Check) {} ++ ++ void diag(SourceLocation Loc, unsigned TokenCount, unsigned MaxTokenCount, bool SuggestFix) { ++ if (MaxTokenCount != 0 && TokenCount > MaxTokenCount && Loc.isValid()) { ++ std::string Msg = llvm::formatv( ++ "Number of tokens ({0}) exceeds the specified maximum ({1})", ++ TokenCount, MaxTokenCount); ++ auto BaseDiag = Check->diag(Loc, Msg); ++ if (SuggestFix) { ++ BaseDiag << FixItHint::CreateReplacement(Loc, std::to_string(TokenCount)); ++ } ++ } ++ } ++ ++ void PragmaMaxTokensHere(SourceLocation Loc, unsigned CurrTokenCount, ++ unsigned MaxTokenCount) override { ++ diag(Loc, CurrTokenCount, MaxTokenCount, true); ++ } ++ ++ void PragmaMaxTokensTotal(SourceLocation Loc, unsigned TokenCount, ++ unsigned MaxTokenCount, bool IsFromPragma) override { ++ MaxTokenCount = MaxTokenCount == 0 ? Check->FMaxTokens : MaxTokenCount; ++ diag(Loc, TokenCount, MaxTokenCount, IsFromPragma); ++ } ++ ++private: ++ MaxTokensCheck *Check; ++}; ++} // namespace ++ ++void MaxTokensCheck::registerPPCallbacks(const SourceManager &SM, ++ Preprocessor *PP, ++ Preprocessor *ModuleExpanderPP) { ++ PP->addPPCallbacks(std::make_unique(this)); ++} ++ ++void MaxTokensCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { ++ Options.store(Opts, "FMaxTokens", FMaxTokens); ++} ++ ++} // namespace misc ++} // namespace tidy ++} // namespace clang +diff --git a/clang-tools-extra/clang-tidy/misc/MaxTokensCheck.h b/clang-tools-extra/clang-tidy/misc/MaxTokensCheck.h +new file mode 100644 +index 000000000..5e73923ad +--- /dev/null ++++ b/clang-tools-extra/clang-tidy/misc/MaxTokensCheck.h +@@ -0,0 +1,37 @@ ++//===--- MaxTokensCheck.h - clang-tidy --------------------------*- C++ -*-===// ++// ++// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. ++// See https://llvm.org/LICENSE.txt for license information. ++// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ++// ++//===----------------------------------------------------------------------===// ++ ++#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MAXTOKENSCHECK_H ++#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MAXTOKENSCHECK_H ++ ++#include "../ClangTidyCheck.h" ++ ++namespace clang { ++namespace tidy { ++namespace misc { ++ ++/// Implements the -Wmax-tokens clang flag as a check ++/// ++/// For the user-facing documentation see: ++/// http://clang.llvm.org/extra/clang-tidy/checks/misc-max-tokens.html ++class MaxTokensCheck : public ClangTidyCheck { ++public: ++ MaxTokensCheck(StringRef Name, ClangTidyContext *Context) ++ : ClangTidyCheck(Name, Context), ++ FMaxTokens(Options.get("FMaxTokens", 0)) {} ++ const unsigned FMaxTokens; ++ void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, ++ Preprocessor *ModuleExpanderPP) override; ++ void storeOptions(ClangTidyOptions::OptionMap &Opts) override; ++}; ++ ++} // namespace misc ++} // namespace tidy ++} // namespace clang ++ ++#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MAXTOKENSCHECK_H +diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +index 127889230..29c576ea7 100644 +--- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp ++++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +@@ -41,6 +41,8 @@ public: + "misc-const-correctness"); + CheckFactories.registerCheck( + "misc-definitions-in-headers"); ++ CheckFactories.registerCheck( ++ "misc-max-tokens"); + CheckFactories.registerCheck( + "misc-misleading-bidirectional"); + CheckFactories.registerCheck( +diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst +index 182052785..43eb51ab4 100644 +--- a/clang-tools-extra/docs/ReleaseNotes.rst ++++ b/clang-tools-extra/docs/ReleaseNotes.rst +@@ -158,6 +158,11 @@ New checks + + Detects confusable Unicode identifiers. + ++- New :doc:`misc-max-tokens ++ ` check. ++ ++ FIXME: add release notes. ++ + - New :doc:`bugprone-assignment-in-if-condition + ` check. + +diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst +index ab6bdc4fe..d8f69345e 100644 +--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst ++++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst +@@ -241,6 +241,7 @@ Clang-Tidy Checks + `misc-confusable-identifiers `_, + `misc-const-correctness `_, "Yes" + `misc-definitions-in-headers `_, "Yes" ++ `misc-max-tokens `_, "Yes" + `misc-misleading-bidirectional `_, + `misc-misleading-identifier `_, + `misc-misplaced-const `_, +diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-max-tokens.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-max-tokens.rst +new file mode 100644 +index 000000000..e6995cd87 +--- /dev/null ++++ b/clang-tools-extra/docs/clang-tidy/checks/misc-max-tokens.rst +@@ -0,0 +1,6 @@ ++.. title:: clang-tidy - misc-max-tokens ++ ++misc-max-tokens ++=============== ++ ++FIXME: Describe what patterns does the check detect and why. Give examples. +diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc-max-tokens.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc-max-tokens.cpp +new file mode 100644 +index 000000000..661f168ac +--- /dev/null ++++ b/clang-tools-extra/test/clang-tidy/checkers/misc-max-tokens.cpp +@@ -0,0 +1,20 @@ ++// RUN: %check_clang_tidy %s misc-max-tokens %t ++// RUN: %check_clang_tidy -check-suffix=NOT-HIT-MAX-TOKEN %s misc-max-tokens %t -- -config="{CheckOptions: [{key: misc-max-tokens.FMaxTokens, value: 10}]}" ++// RUN: %check_clang_tidy -check-suffix=MAX-TOKEN %s misc-max-tokens %t -- -config="{CheckOptions: [{key: misc-max-tokens.FMaxTokens, value: 1}]}" ++// RUN: %check_clang_tidy -check-suffix=MAX-TOKEN-OVERRIDE %s misc-max-tokens %t -- -- -DMAX_TOKEN_OVERRIDE ++ ++int x, y, z; ++ ++#pragma clang max_tokens_here 1 ++// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Number of tokens (7) exceeds the specified maximum (1) ++// CHECK-MESSAGES-NOT-HIT-MAX-TOKEN: :[[@LINE-2]]:31: warning: Number of tokens (7) exceeds the specified maximum (1) ++// CHECK-MESSAGES-MAX-TOKEN: :[[@LINE-3]]:31: warning: Number of tokens (7) exceeds the specified maximum (1) ++// CHECK-MESSAGES-MAX-TOKEN-OVERRIDE: :[[@LINE-4]]:31: warning: Number of tokens (7) exceeds the specified maximum (1) ++ ++#pragma clang max_tokens_here 10 ++ ++#ifdef MAX_TOKEN_OVERRIDE ++#pragma clang max_tokens_total 3 ++// CHECK-MESSAGES-MAX-TOKEN-OVERRIDE: :[[@LINE-1]]:32: warning: Number of tokens (8) exceeds the specified maximum (3) ++#endif ++// CHECK-MESSAGES-MAX-TOKEN: :[[@LINE]]:3: warning: Number of tokens (8) exceeds the specified maximum (1) +diff --git a/clang/include/clang/Lex/PPCallbacks.h b/clang/include/clang/Lex/PPCallbacks.h +index 045df8711..dfd5d0464 100644 +--- a/clang/include/clang/Lex/PPCallbacks.h ++++ b/clang/include/clang/Lex/PPCallbacks.h +@@ -296,6 +296,18 @@ public: + /// is read. + virtual void PragmaAssumeNonNullEnd(SourceLocation Loc) {} + ++ /// Callback invoked when a \#pragma clang max_tokens_here directive is processed. ++ virtual void PragmaMaxTokensHere(SourceLocation Loc, ++ unsigned CurrTokenCount, ++ unsigned MaxTokenCount) {} ++ ++ /// Callback invoked when a \#pragma clang max_tokens_all directive is ++ /// processed, which happens at the end of the file ++ virtual void PragmaMaxTokensTotal(SourceLocation Loc, ++ unsigned TokenCount, ++ unsigned MaxTokenCount, ++ bool IsFromPragma) {} ++ + /// Called by Preprocessor::HandleMacroExpandedIdentifier when a + /// macro invocation is found. + virtual void MacroExpands(const Token &MacroNameTok, +@@ -593,6 +605,16 @@ public: + Second->PragmaAssumeNonNullEnd(Loc); + } + ++ void PragmaMaxTokensHere(SourceLocation Loc, unsigned CurTokenCount, unsigned MaxTokenCount) override { ++ First->PragmaMaxTokensHere(Loc, CurTokenCount, MaxTokenCount); ++ Second->PragmaMaxTokensHere(Loc, CurTokenCount, MaxTokenCount); ++ } ++ ++ void PragmaMaxTokensTotal(SourceLocation Loc, unsigned TokenCount, unsigned MaxTokenCount, bool IsFromPragma) override { ++ First->PragmaMaxTokensTotal(Loc, TokenCount, MaxTokenCount, IsFromPragma); ++ Second->PragmaMaxTokensTotal(Loc, TokenCount, MaxTokenCount, IsFromPragma); ++ } ++ + void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, + SourceRange Range, const MacroArgs *Args) override { + First->MacroExpands(MacroNameTok, MD, Range, Args); +diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp +index 74fa70379..5964a1d81 100644 +--- a/clang/lib/Parse/ParsePragma.cpp ++++ b/clang/lib/Parse/ParsePragma.cpp +@@ -3915,6 +3915,11 @@ void PragmaMaxTokensHereHandler::HandlePragma(Preprocessor &PP, + return; + } + ++ PPCallbacks *Callbacks = PP.getPPCallbacks(); ++ if (Callbacks) { ++ Callbacks->PragmaMaxTokensHere(Loc, PP.getTokenCount(), MaxTokens); ++ } ++ + if (PP.getTokenCount() > MaxTokens) { + PP.Diag(Loc, diag::warn_max_tokens) + << PP.getTokenCount() << (unsigned)MaxTokens; +diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp +index fd0446608..fb7d407d9 100644 +--- a/clang/lib/Parse/Parser.cpp ++++ b/clang/lib/Parse/Parser.cpp +@@ -705,6 +705,16 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result, + } + } + ++ if (PP.getPPCallbacks()) { ++ SourceLocation Loc = PP.getMaxTokensOverrideLoc(); ++ bool IsFromPragma = true; ++ if (!Loc.isValid()) { ++ Loc = Tok.getLocation(); ++ IsFromPragma = false; ++ } ++ PP.getPPCallbacks()->PragmaMaxTokensTotal(Loc, PP.getTokenCount(), PP.getMaxTokens(), IsFromPragma); ++ } ++ + // Late template parsing can begin. + Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this); + if (!PP.isIncrementalProcessingEnabled()) +-- +2.31.1 + diff --git a/tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff b/tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff new file mode 100644 index 0000000000..c5b6cf6c66 --- /dev/null +++ b/tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff @@ -0,0 +1,2982 @@ +From 32c040718880435fbb5eae1933d89e376c2a0a94 Mon Sep 17 00:00:00 2001 +From: Nikita Shulga +Date: Tue, 10 Jan 2023 20:13:19 -0800 +Subject: [PATCH 2/2] potential unbounded loop check + +--- + .../clang-tidy/misc/CMakeLists.txt | 1 + + .../clang-tidy/misc/MiscTidyModule.cpp | 3 + + .../misc/PotentialUnboundedLoopCheck.cpp | 116 + + .../misc/PotentialUnboundedLoopCheck.h | 34 + + .../misc/gen_potential_unbounded_loop_test.py | 170 ++ + .../docs/clang-tidy/checks/list.rst | 3 +- + .../checks/misc-potential-unbounded-loop.rst | 6 + + .../misc-potential-unbounded-loop-extra.cpp | 72 + + .../misc-potential-unbounded-loop.cpp | 2468 +++++++++++++++++ + 9 files changed, 2872 insertions(+), 1 deletion(-) + create mode 100644 clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.cpp + create mode 100644 clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.h + create mode 100644 clang-tools-extra/clang-tidy/misc/gen_potential_unbounded_loop_test.py + create mode 100644 clang-tools-extra/docs/clang-tidy/checks/misc-potential-unbounded-loop.rst + create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop-extra.cpp + create mode 100644 clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop.cpp + +diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +index 6b3084d5d..a69e0bb71 100644 +--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt ++++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +@@ -40,6 +40,7 @@ add_clang_library(clangTidyMiscModule + NoRecursionCheck.cpp + NonCopyableObjects.cpp + NonPrivateMemberVariablesInClassesCheck.cpp ++ PotentialUnboundedLoopCheck.cpp + RedundantExpressionCheck.cpp + StaticAssertCheck.cpp + ThrowByValueCatchByReferenceCheck.cpp +diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +index 29c576ea7..2602c74d3 100644 +--- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp ++++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +@@ -19,6 +19,7 @@ + #include "NoRecursionCheck.h" + #include "NonCopyableObjects.h" + #include "NonPrivateMemberVariablesInClassesCheck.h" ++#include "PotentialUnboundedLoopCheck.h" + #include "RedundantExpressionCheck.h" + #include "StaticAssertCheck.h" + #include "ThrowByValueCatchByReferenceCheck.h" +@@ -55,6 +56,8 @@ public: + "misc-non-copyable-objects"); + CheckFactories.registerCheck( + "misc-non-private-member-variables-in-classes"); ++ CheckFactories.registerCheck( ++ "misc-potential-unbounded-loop"); + CheckFactories.registerCheck( + "misc-redundant-expression"); + CheckFactories.registerCheck("misc-static-assert"); +diff --git a/clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.cpp b/clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.cpp +new file mode 100644 +index 000000000..1f7b7347c +--- /dev/null ++++ b/clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.cpp +@@ -0,0 +1,116 @@ ++//===--- PotentialUnboundedLoopCheck.cpp - clang-tidy ++//-------------------------------===// ++// ++// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. ++// See https://llvm.org/LICENSE.txt for license information. ++// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ++// ++//===----------------------------------------------------------------------===// ++ ++#include "PotentialUnboundedLoopCheck.h" ++#include "clang/AST/ASTContext.h" ++#include "clang/ASTMatchers/ASTMatchFinder.h" ++#include "llvm/Support/FormatVariadic.h" ++ ++using namespace clang::ast_matchers; ++ ++namespace clang { ++namespace tidy { ++namespace misc { ++ ++void PotentialUnboundedLoopCheck::registerMatchers(MatchFinder *Finder) { ++ Finder->addMatcher( ++ forStmt(allOf(hasCondition( ++ binaryOperator( ++ hasLHS(hasDescendant(declRefExpr().bind("lhs"))), ++ hasRHS(hasDescendant(declRefExpr().bind("rhs"))), ++ anyOf(hasOperatorName("<"), hasOperatorName("<="), ++ hasOperatorName(">"), hasOperatorName(">="))) ++ .bind("op")), ++ hasIncrement( ++ unaryOperator( ++ anyOf(hasOperatorName("++"), hasOperatorName("--")), ++ hasDescendant(declRefExpr().bind("inc"))) ++ .bind("inc_op")))) ++ .bind("for"), ++ this); ++} ++ ++inline bool isInc(UnaryOperatorKind Op) { ++ return Op == UnaryOperatorKind::UO_PostInc || ++ Op == UnaryOperatorKind::UO_PreInc; ++} ++ ++inline bool isDec(UnaryOperatorKind Op) { ++ return Op == UnaryOperatorKind::UO_PostDec || ++ Op == UnaryOperatorKind::UO_PreDec; ++} ++ ++inline bool isLT(BinaryOperatorKind Op) { ++ return Op == BinaryOperatorKind::BO_LT; ++} ++ ++inline bool isLE(BinaryOperatorKind Op) { ++ return Op == BinaryOperatorKind::BO_LE; ++} ++inline bool isGT(BinaryOperatorKind Op) { ++ return Op == BinaryOperatorKind::BO_GT; ++} ++ ++inline bool isGE(BinaryOperatorKind Op) { ++ return Op == BinaryOperatorKind::BO_GE; ++} ++ ++void PotentialUnboundedLoopCheck::check( ++ const MatchFinder::MatchResult &Result) { ++ const auto *LHSDecl = Result.Nodes.getNodeAs("lhs")->getDecl(); ++ const auto *RHSDecl = Result.Nodes.getNodeAs("rhs")->getDecl(); ++ const auto *IncDecl = Result.Nodes.getNodeAs("inc")->getDecl(); ++ auto Op = Result.Nodes.getNodeAs("op")->getOpcode(); ++ auto IncOp = Result.Nodes.getNodeAs("inc_op")->getOpcode(); ++ const auto *MatchedFor = Result.Nodes.getNodeAs("for"); ++ ++ // only analyze integer types ++ if (!LHSDecl->getType()->isIntegerType() || ++ !RHSDecl->getType()->isIntegerType() || ++ !IncDecl->getType()->isIntegerType()) { ++ return; ++ } ++ ++ // only analyze loops in which increment var is used in condition ++ if (IncDecl->getName() != LHSDecl->getName() && ++ IncDecl->getName() != RHSDecl->getName()) { ++ return; ++ } ++ ++ auto LHSWidth = ++ LHSDecl->getASTContext().getTypeInfo(LHSDecl->getType()).Width; ++ auto RHSWidth = ++ RHSDecl->getASTContext().getTypeInfo(RHSDecl->getType()).Width; ++ ++ if (LHSWidth < RHSWidth) { ++ if (((isLT(Op) || isLE(Op)) && isInc(IncOp)) || ++ ((isGT(Op) || isGE(Op)) && isDec(IncOp))) { ++ std::string Msg = llvm::formatv( ++ "Found LHS of bitwidth {0} and RHS of bitwidth {1}. This can \ ++potentially lead to an unbounded loop. Explicitly cast the RHS before \ ++performing the comparison.", LHSWidth, RHSWidth); ++ diag(MatchedFor->getForLoc(), Msg); ++ } ++ } else if (LHSWidth > RHSWidth) { ++ if (((isGT(Op) || isGE(Op)) && isInc(IncOp)) || ++ ((isLT(Op) || isLE(Op)) && isDec(IncOp))) { ++ std::string Msg = llvm::formatv( ++ "Found LHS of bitwidth {0} and RHS of bitwidth {1}. This can \ ++potentially lead to an unbounded loop. Explicitly cast the LHS before \ ++performing the comparison.", LHSWidth, RHSWidth); ++ diag(MatchedFor->getForLoc(), Msg); ++ } ++ } else { ++ return; ++ } ++} ++ ++} // namespace misc ++} // namespace tidy ++} // namespace clang +diff --git a/clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.h b/clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.h +new file mode 100644 +index 000000000..2db44bcdd +--- /dev/null ++++ b/clang-tools-extra/clang-tidy/misc/PotentialUnboundedLoopCheck.h +@@ -0,0 +1,34 @@ ++//===--- PotentialUnboundedLoopCheck.h - clang-tidy -------------*- C++ -*-===// ++// ++// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. ++// See https://llvm.org/LICENSE.txt for license information. ++// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ++// ++//===----------------------------------------------------------------------===// ++ ++#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_POTENTIALUNBOUNDEDLOOPCHECK_H ++#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_POTENTIALUNBOUNDEDLOOPCHECK_H ++ ++#include "../ClangTidyCheck.h" ++ ++namespace clang { ++namespace tidy { ++namespace misc { ++ ++/// FIXME: Write a short description. ++/// ++/// For the user-facing documentation see: ++/// http://clang.llvm.org/extra/clang-tidy/checks/misc-potential-unbounded-loop.html ++class PotentialUnboundedLoopCheck : public ClangTidyCheck { ++public: ++ PotentialUnboundedLoopCheck(StringRef Name, ClangTidyContext *Context) ++ : ClangTidyCheck(Name, Context) {} ++ void registerMatchers(ast_matchers::MatchFinder *Finder) override; ++ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; ++}; ++ ++} // namespace misc ++} // namespace tidy ++} // namespace clang ++ ++#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_POTENTIALUNBOUNDEDLOOPCHECK_H +diff --git a/clang-tools-extra/clang-tidy/misc/gen_potential_unbounded_loop_test.py b/clang-tools-extra/clang-tidy/misc/gen_potential_unbounded_loop_test.py +new file mode 100644 +index 000000000..052c28f24 +--- /dev/null ++++ b/clang-tools-extra/clang-tidy/misc/gen_potential_unbounded_loop_test.py +@@ -0,0 +1,170 @@ ++"""Potential Unbounded Loop Test Generator ++ ++This script autogenerates tests for checking loop unbounded with integer types ++The list of types used can be found in the `main()` function ++ ++Usage: ++ python3 gen_potential_unbounded_loop_test.py > path/to/test/file ++""" ++ ++import textwrap ++import re ++ ++CHECK_NAME = "misc-potential-unbounded-loop" ++ ++def op_to_str(op): ++ if op == "<": ++ return "lt" ++ elif op == "<=": ++ return "lte" ++ elif op == ">": ++ return "gt" ++ elif op == ">=": ++ return "gte" ++ elif op == "++": ++ return "inc" ++ elif op == "--": ++ return "dec" ++ else: ++ raise f"invalid op: {op}" ++ ++ ++def sizeof_op(op): ++ return int(re.findall("\d+", op)[0]) ++ ++ ++def _gencode_helper(comp_op, inc_op, t1, t2, trigger=False, swap_comp_order=False): ++ """Generates a C/C++ function containing a for-loop. ++ ++ Arguments: ++ comp_op The comparision op to use in the loop header ++ inc_op The increment op (++ or --) to use in the loop header ++ t1 The type of the loop variable ++ t2 The type of the bounds variable ++ """ ++ code_indent = 4 ++ ++ # build check_msg ++ check_msg = "" ++ if trigger: ++ # build warning message ++ lhs_sz, rhs_sz = sizeof_op(t1), sizeof_op(t2) ++ if swap_comp_order: ++ lhs_sz, rhs_sz = rhs_sz, lhs_sz ++ warning_base = f"Found LHS of bitwidth {lhs_sz} and RHS of bitwidth {rhs_sz}. This can potentially lead to an unbounded loop." ++ warning_rest = "Explicitly cast the RHS before performing the comparison." ++ if swap_comp_order: ++ warning_rest = "Explicitly cast the LHS before performing the comparison." ++ warning = f"warning: {warning_base} {warning_rest} [{CHECK_NAME}]" ++ ++ check_msg = f"// CHECK-MESSAGES: :[[@LINE-1]]:{code_indent + 1}: {warning}" ++ ++ comp = f"i {comp_op} j" ++ if swap_comp_order: ++ comp = f"j {comp_op} i" ++ ++ return textwrap.dedent( ++ f"""\ ++ void test_{t1}_{op_to_str(comp_op)}_{t2}_{op_to_str(inc_op)}() {{ ++ {t2} j; ++ ++ // postfix ++ for ({t1} i = 0; {comp}; i{inc_op}); ++ {check_msg} ++ ++ // prefix ++ for ({t1} i = 0; {comp}; {inc_op}i); ++ {check_msg} ++ }} ++ """ ++ ) ++ ++ ++def gencode_lt(t1, t2): ++ """Generates tests using two loop var types ++ ++ Arguments: ++ t1 Integer type ++ t2 Integer type ++ ++ Notes: ++ precondition: t1 < t2 (code generator depends on this property) ++ """ ++ ++ tests = [ ++ _gencode_helper("<", "++", t2, t1), ++ _gencode_helper("<=", "++", t2, t1), ++ _gencode_helper(">", "--", t2, t1), ++ _gencode_helper(">=", "--", t2, t1), ++ _gencode_helper(">", "++", t2, t1, swap_comp_order=True), ++ _gencode_helper(">=", "++", t2, t1, swap_comp_order=True), ++ _gencode_helper("<", "--", t2, t1, swap_comp_order=True), ++ _gencode_helper("<=", "--", t2, t1, swap_comp_order=True), ++ _gencode_helper("<", "++", t1, t2, trigger=True), ++ _gencode_helper("<=", "++", t1, t2, trigger=True), ++ _gencode_helper(">", "--", t1, t2, trigger=True), ++ _gencode_helper(">=", "--", t1, t2, trigger=True), ++ # swap comparision order for t1 and t2 ++ # ensures that a potential unbounded loop exists ++ _gencode_helper(">", "++", t1, t2, trigger=True, swap_comp_order=True), ++ _gencode_helper(">=", "++", t1, t2, trigger=True, swap_comp_order=True), ++ _gencode_helper("<", "--", t1, t2, trigger=True, swap_comp_order=True), ++ _gencode_helper("<=", "--", t1, t2, trigger=True, swap_comp_order=True), ++ ] ++ ++ return "".join(tests) ++ ++ ++def gencode_eq(t1): ++ """Generates tests using single loop var type ++ ++ Arguments: ++ t1 Integer type ++ """ ++ tests = [ ++ _gencode_helper("<", "++", t1, t1), ++ _gencode_helper("<=", "++", t1, t1), ++ _gencode_helper(">", "--", t1, t1), ++ _gencode_helper(">=", "--", t1, t1), ++ ] ++ ++ return "".join(tests) ++ ++ ++def gen(test): ++ _, types = test ++ n = len(types) ++ ++ code = [] ++ ++ for i in range(n): ++ code.append(gencode_eq(types[i])) ++ for j in range(i + 1, n): ++ code.append(gencode_lt(types[i], types[j])) ++ ++ return "".join(code) ++ ++ ++def main(): ++ test_suite = { ++ "signed_int_types": ["int8_t", "int16_t", "int32_t", "int64_t"], ++ "unsigned_int_types": ["uint8_t", "uint16_t", "uint32_t", "uint64_t"], ++ } ++ ++ preamble = textwrap.dedent( ++ f"""\ ++ // @generated clang-tools-extra/clang-tidy/misc/gen_potential_unbounded_loop_test.py ++ // RUN: %check_clang_tidy %s {CHECK_NAME} %t ++ """ ++ ) ++ ++ code = ["#include\n"] ++ ++ for test in test_suite.items(): ++ code.append(gen(test)) ++ ++ print(f'{preamble} {"".join(code)}') ++ ++ ++if __name__ == "__main__": ++ main() +diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst +index d8f69345e..ebedd22de 100644 +--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst ++++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst +@@ -103,7 +103,7 @@ Clang-Tidy Checks + `bugprone-misplaced-widening-cast `_, + `bugprone-move-forwarding-reference `_, "Yes" + `bugprone-multiple-statement-macro `_, +- `bugprone-no-escape `_, ++ `bugprone-no-escape `_, "Yes" + `bugprone-not-null-terminated-result `_, "Yes" + `bugprone-parent-virtual-call `_, "Yes" + `bugprone-posix-return `_, "Yes" +@@ -249,6 +249,7 @@ Clang-Tidy Checks + `misc-no-recursion `_, + `misc-non-copyable-objects `_, + `misc-non-private-member-variables-in-classes `_, ++ `misc-potential-unbounded-loop `_, + `misc-redundant-expression `_, "Yes" + `misc-static-assert `_, "Yes" + `misc-throw-by-value-catch-by-reference `_, +diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-potential-unbounded-loop.rst b/clang-tools-extra/docs/clang-tidy/checks/misc-potential-unbounded-loop.rst +new file mode 100644 +index 000000000..d1da15754 +--- /dev/null ++++ b/clang-tools-extra/docs/clang-tidy/checks/misc-potential-unbounded-loop.rst +@@ -0,0 +1,6 @@ ++.. title:: clang-tidy - misc-potential-unbounded-loop ++ ++misc-potential-unbounded-loop ++============================= ++ ++FIXME: Describe what patterns does the check detect and why. Give examples. +diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop-extra.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop-extra.cpp +new file mode 100644 +index 000000000..e65c6d190 +--- /dev/null ++++ b/clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop-extra.cpp +@@ -0,0 +1,72 @@ ++// RUN: %check_clang_tidy %s misc-potential-unbounded-loop %t ++#include ++ ++// Although the autogenerated tests check for this, we need to add a "test that ++// triggers the lint" to make testing infra happy :) ++void test_int() { ++ int16_t j; ++ ++ for (int8_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++ ++// Ignore non-integer types ++void test_float() { ++ double j; ++ ++ // postfix ++ for (float i = 0; i < j; i++); ++ ++ // prefix ++ for (float i = 0; i < j; ++i); ++} ++ ++// Lint should ignore if literals used in loop ++void test_literals() { ++ for (int i = 0; i < 10; i++); ++ for (int i = 0; 5 < 10; i++); ++} ++ ++// Lint should ignore if loop elements are missing ++void test_missing_loop_elements() { ++ for (;;); ++ for (int i = 0;;i++); ++ ++ int j; ++ for (;j > 10;); ++ ++ for (int i = 0;;); ++} ++ ++// Lint should ignore if increment variable is different from variable used in comparison ++void test_unrelated() { ++ int8_t a; ++ int32_t b; ++ for (int i = 0; a < b; i++); ++} ++ ++// Lint should ignore complex types ++class A { ++ int x; ++ public: ++ A(int y) { ++ x = y; ++ } ++ ++ int getX() { ++ return x; ++ } ++ ++ void setX(int y) { ++ x = y; ++ } ++ ++ bool operator <(const A& a) { ++ return x < a.x; ++ } ++}; ++ ++void test_complex() { ++ A A1(10), A2(20); ++ for (int i = 0; A1 < A2; i++); ++} +diff --git a/clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop.cpp b/clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop.cpp +new file mode 100644 +index 000000000..c194e1552 +--- /dev/null ++++ b/clang-tools-extra/test/clang-tidy/checkers/misc-potential-unbounded-loop.cpp +@@ -0,0 +1,2468 @@ ++// @generated clang-tools-extra/clang-tidy/misc/gen_potential_unbounded_loop_test.py ++// RUN: %check_clang_tidy %s misc-potential-unbounded-loop %t ++ #include ++void test_int8_t_lt_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int8_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int8_t i = 0; i < j; ++i); ++ ++} ++void test_int8_t_lte_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int8_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int8_t i = 0; i <= j; ++i); ++ ++} ++void test_int8_t_gt_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int8_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int8_t i = 0; i > j; --i); ++ ++} ++void test_int8_t_gte_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int8_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int8_t i = 0; i >= j; --i); ++ ++} ++void test_int16_t_lt_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int16_t i = 0; i < j; ++i); ++ ++} ++void test_int16_t_lte_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int16_t i = 0; i <= j; ++i); ++ ++} ++void test_int16_t_gt_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int16_t i = 0; i > j; --i); ++ ++} ++void test_int16_t_gte_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int16_t i = 0; i >= j; --i); ++ ++} ++void test_int16_t_gt_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (int16_t i = 0; j > i; ++i); ++ ++} ++void test_int16_t_gte_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (int16_t i = 0; j >= i; ++i); ++ ++} ++void test_int16_t_lt_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (int16_t i = 0; j < i; --i); ++ ++} ++void test_int16_t_lte_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int16_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (int16_t i = 0; j <= i; --i); ++ ++} ++void test_int8_t_lt_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lte_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gt_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gte_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gt_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gte_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lt_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lte_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int8_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_lt_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; i < j; ++i); ++ ++} ++void test_int32_t_lte_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; i <= j; ++i); ++ ++} ++void test_int32_t_gt_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; i > j; --i); ++ ++} ++void test_int32_t_gte_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; i >= j; --i); ++ ++} ++void test_int32_t_gt_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; j > i; ++i); ++ ++} ++void test_int32_t_gte_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; j >= i; ++i); ++ ++} ++void test_int32_t_lt_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; j < i; --i); ++ ++} ++void test_int32_t_lte_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int32_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; j <= i; --i); ++ ++} ++void test_int8_t_lt_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lte_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gt_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gte_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gt_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gte_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lt_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lte_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int8_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int64_t_lt_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i < j; ++i); ++ ++} ++void test_int64_t_lte_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i <= j; ++i); ++ ++} ++void test_int64_t_gt_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i > j; --i); ++ ++} ++void test_int64_t_gte_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i >= j; --i); ++ ++} ++void test_int64_t_gt_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; j > i; ++i); ++ ++} ++void test_int64_t_gte_int8_t_inc() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; j >= i; ++i); ++ ++} ++void test_int64_t_lt_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; j < i; --i); ++ ++} ++void test_int64_t_lte_int8_t_dec() { ++ int8_t j; ++ ++ // postfix ++ for (int64_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; j <= i; --i); ++ ++} ++void test_int8_t_lt_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lte_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gt_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gte_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gt_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_gte_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lt_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int8_t_lte_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int8_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int8_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_lt_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int16_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int16_t i = 0; i < j; ++i); ++ ++} ++void test_int16_t_lte_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int16_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int16_t i = 0; i <= j; ++i); ++ ++} ++void test_int16_t_gt_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int16_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int16_t i = 0; i > j; --i); ++ ++} ++void test_int16_t_gte_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int16_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int16_t i = 0; i >= j; --i); ++ ++} ++void test_int32_t_lt_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; i < j; ++i); ++ ++} ++void test_int32_t_lte_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; i <= j; ++i); ++ ++} ++void test_int32_t_gt_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; i > j; --i); ++ ++} ++void test_int32_t_gte_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; i >= j; --i); ++ ++} ++void test_int32_t_gt_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; j > i; ++i); ++ ++} ++void test_int32_t_gte_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; j >= i; ++i); ++ ++} ++void test_int32_t_lt_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; j < i; --i); ++ ++} ++void test_int32_t_lte_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int32_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; j <= i; --i); ++ ++} ++void test_int16_t_lt_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_lte_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gt_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gte_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gt_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gte_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_lt_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_lte_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int16_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int64_t_lt_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i < j; ++i); ++ ++} ++void test_int64_t_lte_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i <= j; ++i); ++ ++} ++void test_int64_t_gt_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i > j; --i); ++ ++} ++void test_int64_t_gte_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i >= j; --i); ++ ++} ++void test_int64_t_gt_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; j > i; ++i); ++ ++} ++void test_int64_t_gte_int16_t_inc() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; j >= i; ++i); ++ ++} ++void test_int64_t_lt_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; j < i; --i); ++ ++} ++void test_int64_t_lte_int16_t_dec() { ++ int16_t j; ++ ++ // postfix ++ for (int64_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; j <= i; --i); ++ ++} ++void test_int16_t_lt_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_lte_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gt_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gte_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gt_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_gte_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_lt_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int16_t_lte_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int16_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int16_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_lt_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int32_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; i < j; ++i); ++ ++} ++void test_int32_t_lte_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int32_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int32_t i = 0; i <= j; ++i); ++ ++} ++void test_int32_t_gt_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int32_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; i > j; --i); ++ ++} ++void test_int32_t_gte_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int32_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int32_t i = 0; i >= j; --i); ++ ++} ++void test_int64_t_lt_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i < j; ++i); ++ ++} ++void test_int64_t_lte_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i <= j; ++i); ++ ++} ++void test_int64_t_gt_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i > j; --i); ++ ++} ++void test_int64_t_gte_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i >= j; --i); ++ ++} ++void test_int64_t_gt_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; j > i; ++i); ++ ++} ++void test_int64_t_gte_int32_t_inc() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; j >= i; ++i); ++ ++} ++void test_int64_t_lt_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; j < i; --i); ++ ++} ++void test_int64_t_lte_int32_t_dec() { ++ int32_t j; ++ ++ // postfix ++ for (int64_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; j <= i; --i); ++ ++} ++void test_int32_t_lt_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_lte_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_gt_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_gte_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_gt_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_gte_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_lt_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int32_t_lte_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int32_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (int32_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_int64_t_lt_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i < j; ++i); ++ ++} ++void test_int64_t_lte_int64_t_inc() { ++ int64_t j; ++ ++ // postfix ++ for (int64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (int64_t i = 0; i <= j; ++i); ++ ++} ++void test_int64_t_gt_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i > j; --i); ++ ++} ++void test_int64_t_gte_int64_t_dec() { ++ int64_t j; ++ ++ // postfix ++ for (int64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (int64_t i = 0; i >= j; --i); ++ ++} ++void test_uint8_t_lt_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint8_t i = 0; i < j; ++i); ++ ++} ++void test_uint8_t_lte_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint8_t i = 0; i <= j; ++i); ++ ++} ++void test_uint8_t_gt_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint8_t i = 0; i > j; --i); ++ ++} ++void test_uint8_t_gte_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint8_t i = 0; i >= j; --i); ++ ++} ++void test_uint16_t_lt_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i < j; ++i); ++ ++} ++void test_uint16_t_lte_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i <= j; ++i); ++ ++} ++void test_uint16_t_gt_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i > j; --i); ++ ++} ++void test_uint16_t_gte_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i >= j; --i); ++ ++} ++void test_uint16_t_gt_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (uint16_t i = 0; j > i; ++i); ++ ++} ++void test_uint16_t_gte_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (uint16_t i = 0; j >= i; ++i); ++ ++} ++void test_uint16_t_lt_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (uint16_t i = 0; j < i; --i); ++ ++} ++void test_uint16_t_lte_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (uint16_t i = 0; j <= i; --i); ++ ++} ++void test_uint8_t_lt_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lte_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gt_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gte_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gt_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gte_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lt_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lte_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_lt_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i < j; ++i); ++ ++} ++void test_uint32_t_lte_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i <= j; ++i); ++ ++} ++void test_uint32_t_gt_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i > j; --i); ++ ++} ++void test_uint32_t_gte_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i >= j; --i); ++ ++} ++void test_uint32_t_gt_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j > i; ++i); ++ ++} ++void test_uint32_t_gte_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j >= i; ++i); ++ ++} ++void test_uint32_t_lt_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j < i; --i); ++ ++} ++void test_uint32_t_lte_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j <= i; --i); ++ ++} ++void test_uint8_t_lt_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lte_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gt_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gte_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gt_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gte_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lt_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lte_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint64_t_lt_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i < j; ++i); ++ ++} ++void test_uint64_t_lte_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i <= j; ++i); ++ ++} ++void test_uint64_t_gt_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i > j; --i); ++ ++} ++void test_uint64_t_gte_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i >= j; --i); ++ ++} ++void test_uint64_t_gt_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j > i; ++i); ++ ++} ++void test_uint64_t_gte_uint8_t_inc() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j >= i; ++i); ++ ++} ++void test_uint64_t_lt_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j < i; --i); ++ ++} ++void test_uint64_t_lte_uint8_t_dec() { ++ uint8_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j <= i; --i); ++ ++} ++void test_uint8_t_lt_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lte_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gt_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gte_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 8 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gt_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_gte_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lt_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint8_t_lte_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint8_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint8_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 8. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_lt_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i < j; ++i); ++ ++} ++void test_uint16_t_lte_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i <= j; ++i); ++ ++} ++void test_uint16_t_gt_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i > j; --i); ++ ++} ++void test_uint16_t_gte_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint16_t i = 0; i >= j; --i); ++ ++} ++void test_uint32_t_lt_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i < j; ++i); ++ ++} ++void test_uint32_t_lte_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i <= j; ++i); ++ ++} ++void test_uint32_t_gt_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i > j; --i); ++ ++} ++void test_uint32_t_gte_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i >= j; --i); ++ ++} ++void test_uint32_t_gt_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j > i; ++i); ++ ++} ++void test_uint32_t_gte_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j >= i; ++i); ++ ++} ++void test_uint32_t_lt_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j < i; --i); ++ ++} ++void test_uint32_t_lte_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; j <= i; --i); ++ ++} ++void test_uint16_t_lt_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_lte_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gt_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gte_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gt_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gte_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_lt_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_lte_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint64_t_lt_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i < j; ++i); ++ ++} ++void test_uint64_t_lte_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i <= j; ++i); ++ ++} ++void test_uint64_t_gt_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i > j; --i); ++ ++} ++void test_uint64_t_gte_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i >= j; --i); ++ ++} ++void test_uint64_t_gt_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j > i; ++i); ++ ++} ++void test_uint64_t_gte_uint16_t_inc() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j >= i; ++i); ++ ++} ++void test_uint64_t_lt_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j < i; --i); ++ ++} ++void test_uint64_t_lte_uint16_t_dec() { ++ uint16_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j <= i; --i); ++ ++} ++void test_uint16_t_lt_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_lte_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gt_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gte_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 16 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gt_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_gte_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_lt_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint16_t_lte_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint16_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint16_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 16. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_lt_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i < j; ++i); ++ ++} ++void test_uint32_t_lte_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i <= j; ++i); ++ ++} ++void test_uint32_t_gt_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i > j; --i); ++ ++} ++void test_uint32_t_gte_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint32_t i = 0; i >= j; --i); ++ ++} ++void test_uint64_t_lt_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i < j; ++i); ++ ++} ++void test_uint64_t_lte_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i <= j; ++i); ++ ++} ++void test_uint64_t_gt_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i > j; --i); ++ ++} ++void test_uint64_t_gte_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i >= j; --i); ++ ++} ++void test_uint64_t_gt_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j > i; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j > i; ++i); ++ ++} ++void test_uint64_t_gte_uint32_t_inc() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j >= i; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j >= i; ++i); ++ ++} ++void test_uint64_t_lt_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j < i; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j < i; --i); ++ ++} ++void test_uint64_t_lte_uint32_t_dec() { ++ uint32_t j; ++ ++ // postfix ++ for (uint64_t i = 0; j <= i; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; j <= i; --i); ++ ++} ++void test_uint32_t_lt_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i < j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; i < j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_lte_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i <= j; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; i <= j; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_gt_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i > j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; i > j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_gte_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; i >= j; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; i >= j; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 32 and RHS of bitwidth 64. This can potentially lead to an unbounded loop. Explicitly cast the RHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_gt_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j > i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; j > i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_gte_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j >= i; i++); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; j >= i; ++i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_lt_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j < i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; j < i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint32_t_lte_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint32_t i = 0; j <= i; i--); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++ ++ // prefix ++ for (uint32_t i = 0; j <= i; --i); ++ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Found LHS of bitwidth 64 and RHS of bitwidth 32. This can potentially lead to an unbounded loop. Explicitly cast the LHS before performing the comparison. [misc-potential-unbounded-loop] ++} ++void test_uint64_t_lt_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i < j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i < j; ++i); ++ ++} ++void test_uint64_t_lte_uint64_t_inc() { ++ uint64_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i <= j; i++); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i <= j; ++i); ++ ++} ++void test_uint64_t_gt_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i > j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i > j; --i); ++ ++} ++void test_uint64_t_gte_uint64_t_dec() { ++ uint64_t j; ++ ++ // postfix ++ for (uint64_t i = 0; i >= j; i--); ++ ++ ++ // prefix ++ for (uint64_t i = 0; i >= j; --i); ++ ++} ++ +-- +2.31.1 + diff --git a/tools/clang-tidy-checks/setup.sh b/tools/clang-tidy-checks/setup.sh index 3f12aef3b5..1dc0e2f9a8 100755 --- a/tools/clang-tidy-checks/setup.sh +++ b/tools/clang-tidy-checks/setup.sh @@ -48,14 +48,14 @@ function clone_llvm() { if [[ -d llvm-project ]]; then rm -rf llvm-project fi - git clone -b llvmorg-11.1.0 https://github.com/llvm/llvm-project.git --depth=1 + git clone -b llvmorg-15.0.6 https://github.com/llvm/llvm-project.git --depth=1 success } function apply_patches() { info "applying patches" cd llvm-project - for check in ../*.diff; do + for check in ../15.x-patches/*.diff; do patch -p1 -N -d . < "$check" done success From 99d4b7015eac6132c39e795b5973b41541e06601 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Wed, 11 Jan 2023 09:02:54 -0800 Subject: [PATCH 2/9] Add missing header --- .../15.x-patches/0001-Max-tokens-checks.diff | 18 +++++++++++++----- .../0002-potential-unbounded-loop-check.diff | 8 ++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff b/tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff index da6fbf7767..2f7aa3a800 100644 --- a/tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff +++ b/tools/clang-tidy-checks/15.x-patches/0001-Max-tokens-checks.diff @@ -1,4 +1,4 @@ -From e6d62c83b29eeda8c1b7bd45106b8364c45c7c72 Mon Sep 17 00:00:00 2001 +From d9c63bd71de07bfff508981dcf4dfbfa3f0c8fd3 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Tue, 10 Jan 2023 17:52:43 -0800 Subject: [PATCH 1/2] Max tokens checks @@ -7,7 +7,7 @@ Subject: [PATCH 1/2] Max tokens checks .../clang-tidy/misc/CMakeLists.txt | 1 + .../clang-tidy/misc/MaxTokensCheck.cpp | 66 +++++++++++++++++++ .../clang-tidy/misc/MaxTokensCheck.h | 37 +++++++++++ - .../clang-tidy/misc/MiscTidyModule.cpp | 2 + + .../clang-tidy/misc/MiscTidyModule.cpp | 3 + clang-tools-extra/docs/ReleaseNotes.rst | 5 ++ .../docs/clang-tidy/checks/list.rst | 1 + .../clang-tidy/checks/misc-max-tokens.rst | 6 ++ @@ -15,7 +15,7 @@ Subject: [PATCH 1/2] Max tokens checks clang/include/clang/Lex/PPCallbacks.h | 22 +++++++ clang/lib/Parse/ParsePragma.cpp | 5 ++ clang/lib/Parse/Parser.cpp | 10 +++ - 11 files changed, 175 insertions(+) + 11 files changed, 176 insertions(+) create mode 100644 clang-tools-extra/clang-tidy/misc/MaxTokensCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/misc/MaxTokensCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/misc-max-tokens.rst @@ -149,10 +149,18 @@ index 000000000..5e73923ad + +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MAXTOKENSCHECK_H diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp -index 127889230..29c576ea7 100644 +index 127889230..c24aa8470 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp -@@ -41,6 +41,8 @@ public: +@@ -12,6 +12,7 @@ + #include "ConfusableIdentifierCheck.h" + #include "ConstCorrectnessCheck.h" + #include "DefinitionsInHeadersCheck.h" ++#include "MaxTokensCheck.h" + #include "MisleadingBidirectional.h" + #include "MisleadingIdentifier.h" + #include "MisplacedConstCheck.h" +@@ -41,6 +42,8 @@ public: "misc-const-correctness"); CheckFactories.registerCheck( "misc-definitions-in-headers"); diff --git a/tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff b/tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff index c5b6cf6c66..4e92d2ce71 100644 --- a/tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff +++ b/tools/clang-tidy-checks/15.x-patches/0002-potential-unbounded-loop-check.diff @@ -1,4 +1,4 @@ -From 32c040718880435fbb5eae1933d89e376c2a0a94 Mon Sep 17 00:00:00 2001 +From 39cbe114c84df19e8b116897ee7b31b89066515f Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Tue, 10 Jan 2023 20:13:19 -0800 Subject: [PATCH 2/2] potential unbounded loop check @@ -34,10 +34,10 @@ index 6b3084d5d..a69e0bb71 100644 StaticAssertCheck.cpp ThrowByValueCatchByReferenceCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp -index 29c576ea7..2602c74d3 100644 +index c24aa8470..2c2e9c00d 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp -@@ -19,6 +19,7 @@ +@@ -20,6 +20,7 @@ #include "NoRecursionCheck.h" #include "NonCopyableObjects.h" #include "NonPrivateMemberVariablesInClassesCheck.h" @@ -45,7 +45,7 @@ index 29c576ea7..2602c74d3 100644 #include "RedundantExpressionCheck.h" #include "StaticAssertCheck.h" #include "ThrowByValueCatchByReferenceCheck.h" -@@ -55,6 +56,8 @@ public: +@@ -56,6 +57,8 @@ public: "misc-non-copyable-objects"); CheckFactories.registerCheck( "misc-non-private-member-variables-in-classes"); From 073400123dd76799bc10faada2b523e158919324 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Wed, 11 Jan 2023 11:20:25 -0800 Subject: [PATCH 3/9] And run this on a bigger machines --- .github/workflows/clang-tidy-linux.yml | 2 +- .github/workflows/clang-tidy-macos.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clang-tidy-linux.yml b/.github/workflows/clang-tidy-linux.yml index d73cdca6bd..c37d07bb89 100644 --- a/.github/workflows/clang-tidy-linux.yml +++ b/.github/workflows/clang-tidy-linux.yml @@ -16,7 +16,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: linux.12xlarge steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/clang-tidy-macos.yml b/.github/workflows/clang-tidy-macos.yml index 34b6ab8699..9796baf861 100644 --- a/.github/workflows/clang-tidy-macos.yml +++ b/.github/workflows/clang-tidy-macos.yml @@ -18,7 +18,7 @@ on: jobs: build-Intel: - runs-on: macos-12 + runs-on: macos-12-xl steps: - name: Checkout uses: actions/checkout@v3 From d832d8d3ed02f8220065f7a52d4d83725bdacd41 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 12 Jan 2023 16:14:51 -0800 Subject: [PATCH 4/9] Small fix --- tools/clang-tidy-checks/setup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/clang-tidy-checks/setup.sh b/tools/clang-tidy-checks/setup.sh index 1dc0e2f9a8..90f642d9f7 100755 --- a/tools/clang-tidy-checks/setup.sh +++ b/tools/clang-tidy-checks/setup.sh @@ -54,14 +54,16 @@ function clone_llvm() { function apply_patches() { info "applying patches" - cd llvm-project + pushd llvm-project for check in ../15.x-patches/*.diff; do patch -p1 -N -d . < "$check" done + popd success } function build() { + cd llvm-project local cmake_common_args=( -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ From b50f562accf4d0a72f757559c0b4e0f27c2041ac Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 12 Jan 2023 17:37:33 -0800 Subject: [PATCH 5/9] Do not crash plz --- ...003-Do-not-use-pthread_rwlock_wrlock.patch | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.patch diff --git a/tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.patch b/tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.patch new file mode 100644 index 0000000000..7fffabd060 --- /dev/null +++ b/tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.patch @@ -0,0 +1,31 @@ +From e86ae476ba38350366e8cfd5c0f29174c10ea9a3 Mon Sep 17 00:00:00 2001 +From: Nikita Shulga +Date: Thu, 12 Jan 2023 17:35:55 -0800 +Subject: [PATCH] Do not use pthread_rwlock_wrlock + +As it causes crash during initialization on Linux, see https://github.com/pytorch/test-infra/pull/1382#issuecomment-1381197416 +--- + llvm/include/llvm/Support/RWMutex.h | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/llvm/include/llvm/Support/RWMutex.h b/llvm/include/llvm/Support/RWMutex.h +index 3dd962586..1342db6f3 100644 +--- a/llvm/include/llvm/Support/RWMutex.h ++++ b/llvm/include/llvm/Support/RWMutex.h +@@ -19,12 +19,8 @@ + #include + #include + +-// std::shared_timed_mutex is only availble on macOS 10.12 and later. +-#if defined(__APPLE__) && defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200 ++// Always use homegrown implementation for static linking + #define LLVM_USE_RW_MUTEX_IMPL +-#endif +-#endif + + namespace llvm { + namespace sys { +-- +2.31.1 + From 185f365f7f7bab31d237ffc012c4eab1ddd4cd35 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 12 Jan 2023 17:39:04 -0800 Subject: [PATCH 6/9] Add runner types --- .github/actionlint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 7cdfc4c9f3..ad2b5648f5 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -1,6 +1,8 @@ self-hosted-runner: labels: + - macos-12-xl - macos-m1-12 + - linux.12xlarge - linux.2xlarge - linux.4xlarge.nvidia.gpu - linux.g5.4xlarge.nvidia.gpu From 84e785de7939933fd0137ac4ae7910b6c8631a47 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 12 Jan 2023 18:42:03 -0800 Subject: [PATCH 7/9] Me is stupid --- ...ck_wrlock.patch => 0003-Do-not-use-pthread_rwlock_wrlock.diff} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tools/clang-tidy-checks/15.x-patches/{0003-Do-not-use-pthread_rwlock_wrlock.patch => 0003-Do-not-use-pthread_rwlock_wrlock.diff} (100%) diff --git a/tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.patch b/tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.diff similarity index 100% rename from tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.patch rename to tools/clang-tidy-checks/15.x-patches/0003-Do-not-use-pthread_rwlock_wrlock.diff From e0bbfa23c1d1bf25e68c6f431789c7959ce0c3c7 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 12 Jan 2023 19:00:27 -0800 Subject: [PATCH 8/9] Tweak check --- tools/clang-tidy-checks/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clang-tidy-checks/setup.sh b/tools/clang-tidy-checks/setup.sh index 90f642d9f7..f888f7c946 100755 --- a/tools/clang-tidy-checks/setup.sh +++ b/tools/clang-tidy-checks/setup.sh @@ -115,7 +115,7 @@ function setup() { function check_if_static() { case $(uname) in Linux) - ldd ./bin/clang-tidy 2>&1 | grep -q "not a dynamic executable" + ldd ./bin/clang-tidy 2>&1 | grep -q -e "not a dynamic executable" -e "statically linked" ;; Darwin) # No static link check for MacOS From 85ad93517f237a6e1a580713827ef84122de6fd3 Mon Sep 17 00:00:00 2001 From: Nikita Shulga Date: Thu, 12 Jan 2023 19:44:03 -0800 Subject: [PATCH 9/9] And finally tweak verify --- .../{0001-Max-tokens-checks.diff => max-tokens-check.diff} | 0 ...nded-loop-check.diff => potential-unbounded-loop-check.diff} | 0 tools/clang-tidy-checks/verify.sh | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename tools/clang-tidy-checks/11.x-patches/{0001-Max-tokens-checks.diff => max-tokens-check.diff} (100%) rename tools/clang-tidy-checks/11.x-patches/{0002-potential-unbounded-loop-check.diff => potential-unbounded-loop-check.diff} (100%) diff --git a/tools/clang-tidy-checks/11.x-patches/0001-Max-tokens-checks.diff b/tools/clang-tidy-checks/11.x-patches/max-tokens-check.diff similarity index 100% rename from tools/clang-tidy-checks/11.x-patches/0001-Max-tokens-checks.diff rename to tools/clang-tidy-checks/11.x-patches/max-tokens-check.diff diff --git a/tools/clang-tidy-checks/11.x-patches/0002-potential-unbounded-loop-check.diff b/tools/clang-tidy-checks/11.x-patches/potential-unbounded-loop-check.diff similarity index 100% rename from tools/clang-tidy-checks/11.x-patches/0002-potential-unbounded-loop-check.diff rename to tools/clang-tidy-checks/11.x-patches/potential-unbounded-loop-check.diff diff --git a/tools/clang-tidy-checks/verify.sh b/tools/clang-tidy-checks/verify.sh index 620d630bf1..dac11b58aa 100755 --- a/tools/clang-tidy-checks/verify.sh +++ b/tools/clang-tidy-checks/verify.sh @@ -2,7 +2,7 @@ set -xe -checks=$(ls *.diff) +checks=$(pushd 11.x-patches > /dev/null; ls *.diff; popd >/dev/null) found_checks=$(clang-tidy -checks=* --list-checks) for check in $checks; do name=${check%-check.*}