mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 05:26:58 +08:00
clang-analyzer: Suppress warnings in intentional use-after-move cases
This commit is contained in:
@@ -301,12 +301,14 @@ static bool testMoveConstruct(std::vector<Event>& expected)
|
||||
cm::optional<EventLogger> o3{};
|
||||
const cm::optional<EventLogger> o4{ std::move(o3) };
|
||||
|
||||
#ifndef __clang_analyzer__ /* cplusplus.Move */
|
||||
expected = {
|
||||
{ Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
|
||||
{ Event::MOVE_CONSTRUCT, &*o2, &*o1, 4 },
|
||||
{ Event::DESTRUCT, &*o2, nullptr, 4 },
|
||||
{ Event::DESTRUCT, &*o1, nullptr, 4 },
|
||||
};
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -326,12 +326,14 @@ static bool testConstructMove()
|
||||
std::cout << "testConstructMove()\n";
|
||||
cm::String s1 = std::string("abc");
|
||||
cm::String s2 = std::move(s1);
|
||||
#ifndef __clang_analyzer__ /* cplusplus.Move */
|
||||
ASSERT_TRUE(s1.data() == nullptr);
|
||||
ASSERT_TRUE(s1.size() == 0);
|
||||
ASSERT_TRUE(s2.size() == 3);
|
||||
ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
|
||||
ASSERT_TRUE(s1.is_stable());
|
||||
ASSERT_TRUE(s2.is_stable());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -356,12 +358,14 @@ static bool testAssignMove()
|
||||
cm::String s1 = std::string("abc");
|
||||
cm::String s2;
|
||||
s2 = std::move(s1);
|
||||
#ifndef __clang_analyzer__ /* cplusplus.Move */
|
||||
ASSERT_TRUE(s1.data() == nullptr);
|
||||
ASSERT_TRUE(s1.size() == 0);
|
||||
ASSERT_TRUE(s2.size() == 3);
|
||||
ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
|
||||
ASSERT_TRUE(s1.is_stable());
|
||||
ASSERT_TRUE(s2.is_stable());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user