treewide: Add NOLINT where needed to make clang-tidy happy
These are not real bugs, clang-tidy doesn't understand how we are
preventing UB.
Change-Id: I4305ab0b59aae07151d5978ba8642bece076139f
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/stdplus/net/addr/subnet.hpp b/include/stdplus/net/addr/subnet.hpp
index 862237b..e9a174c 100644
--- a/include/stdplus/net/addr/subnet.hpp
+++ b/include/stdplus/net/addr/subnet.hpp
@@ -13,10 +13,11 @@
__attribute__((no_sanitize("undefined"))) constexpr uint32_t
addr32Mask(std::ptrdiff_t pfx) noexcept
{
+ // NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult)
+ auto v = ~uint32_t{0} << (32 - pfx);
// Positive prefix check + mask to handle UB when the left shift becomes
// more than 31 bits
- return hton(static_cast<uint32_t>(-int32_t{pfx > 0}) & ~uint32_t{0}
- << (32 - pfx));
+ return hton(static_cast<uint32_t>(-int32_t{pfx > 0}) & v);
}
constexpr In4Addr addrToSubnet(In4Addr a, std::size_t pfx) noexcept
diff --git a/include/stdplus/raw.hpp b/include/stdplus/raw.hpp
index dbec33e..21dc728 100644
--- a/include/stdplus/raw.hpp
+++ b/include/stdplus/raw.hpp
@@ -172,7 +172,7 @@
Tp& ret = refFrom<Tp, A>(data);
static_assert(sizeof(Tp) % sizeof(IntT) == 0);
data = data.subspan(sizeof(Tp) / sizeof(IntT));
- return ret;
+ return ret; // NOLINT(clang-analyzer-cplusplus.InnerPointer)
}
/** @brief Returns the std::span referencing the data of the raw trivial type
diff --git a/test/handle/copyable.cpp b/test/handle/copyable.cpp
index 161b808..fa95419 100644
--- a/test/handle/copyable.cpp
+++ b/test/handle/copyable.cpp
@@ -262,6 +262,7 @@
StoreHandle h2(std::move(h1));
EXPECT_TRUE(dropped.empty());
EXPECT_FALSE(h1);
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
EXPECT_THROW(h1.value(), std::bad_optional_access);
EXPECT_TRUE(h2);
EXPECT_EQ(expected, *h2);
@@ -285,6 +286,7 @@
EXPECT_EQ(std::vector{expected2}, dropped);
dropped.clear();
EXPECT_FALSE(h1);
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
EXPECT_THROW(h1.value(), std::bad_optional_access);
EXPECT_TRUE(h2);
EXPECT_EQ(expected, *h2);
diff --git a/test/handle/managed.cpp b/test/handle/managed.cpp
index 74816e5..0cdbe74 100644
--- a/test/handle/managed.cpp
+++ b/test/handle/managed.cpp
@@ -217,6 +217,7 @@
StoreHandle h2(std::move(h1));
EXPECT_TRUE(dropped.empty());
EXPECT_FALSE(h1);
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
EXPECT_THROW(h1.value(), std::bad_optional_access);
EXPECT_TRUE(h2);
EXPECT_EQ(expected, *h2);
@@ -240,6 +241,7 @@
EXPECT_EQ(std::vector{expected2}, dropped);
dropped.clear();
EXPECT_FALSE(h1);
+ // NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
EXPECT_THROW(h1.value(), std::bad_optional_access);
EXPECT_TRUE(h2);
EXPECT_EQ(expected, *h2);
diff --git a/test/pinned.cpp b/test/pinned.cpp
index dd83375..88c9bef 100644
--- a/test/pinned.cpp
+++ b/test/pinned.cpp
@@ -39,6 +39,7 @@
TEST(Pinned, Fundamental)
{
Pinned pi = 4;
+ // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn)
EXPECT_EQ(4, [](int& f) { return f; }(pi));
EXPECT_EQ(4, [](int f) { return f; }(pi));
}