[clang-tools-extra] [clang-tidy] Avoid overflow when dumping unsigned integer values (PR #85060)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 22 03:02:09 PDT 2024


================
@@ -422,7 +425,10 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
     store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
           std::optional<T> Value) const {
       if (Value)
-        storeInt(Options, LocalName, *Value);
+        if constexpr (std::is_signed_v<T>)
+          storeInt(Options, LocalName, *Value);
+        else
+          storeUnsigned(Options, LocalName, *Value);
----------------
PiotrZSL wrote:

you could just call: `store(Options, LocalName, *Value)`
And this way could avoid duplicates.

https://github.com/llvm/llvm-project/pull/85060


More information about the cfe-commits mailing list