-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for suppressing clang static analyzer issues with [[clang…
…::suppress]] https://bugs.webkit.org/show_bug.cgi?id=267981 <rdar://121489134> Reviewed by Alex Christensen and Darin Adler. This adds support for the `[[clang::suppress]]` attribute in clang-17. Currently there is no way to ignore specific analyzer warnings, but the macros add support for documenting the warning(s) in case support is added later. The `[[clang::suppress]]` attribute can be applied to a single line of code or to a block of code. * Source/WTF/wtf/Compiler.h: (COMPILER_HAS_ATTRIBUTE): Add. - Define helper macro since __has_attribute() is used more than once. (COMPILER_HAS_CLANG_FEATURE): - Update documentation link to https. (FALLTHROUGH): (NOT_TAIL_CALLED): - Use COMPILER_HAS_ATTRIBUTE(). (IGNORE_CLANG_STATIC_ANALYZER_WARNINGS_ATTRIBUTE): Add. (IGNORE_CLANG_STATIC_ANALYZER_WARNINGS_BEGIN): Add. (IGNORE_CLANG_STATIC_ANALYZER_WARNINGS_END): Add. - Add support for the [[clang::suppress]] attribute. (IGNORE_CLANG_STATIC_ANALYZER_USE_AFTER_MOVE_ATTRIBUTE): Add. (TLS_MODEL_INITIAL_EXEC): - Use COMPILER_HAS_ATTRIBUTE(). * Tools/TestWebKitAPI/Tests/WTF/CheckedPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/CompactPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/CompactRefPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp: * Tools/TestWebKitAPI/Tests/WTF/ListHashSet.cpp: * Tools/TestWebKitAPI/Tests/WTF/NakedPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/PackedRefPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/URL.cpp: * Tools/TestWebKitAPI/Tests/WTF/Vector.cpp: * Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/cf/RetainPtr.cpp: * Tools/TestWebKitAPI/Tests/WTF/cocoa/TypeCastsCocoa.mm: * Tools/TestWebKitAPI/Tests/WTF/ns/RetainPtr.mm: * Tools/TestWebKitAPI/Tests/WebKit/cocoa/WeakObjCPtr.mm: - Ignore expected cplusplus.Move warnings using IGNORE_CLANG_STATIC_ANALYZER_USE_AFTER_MOVE_ATTRIBUTE. Canonical link: https://commits.webkit.org/273460@main
- Loading branch information
Showing
16 changed files
with
156 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,6 +180,7 @@ TEST(WTF_FixedVector, Move) | |
vec1[2] = 2; | ||
|
||
FixedVector<unsigned> vec2(WTFMove(vec1)); | ||
IGNORE_CLANG_STATIC_ANALYZER_USE_AFTER_MOVE_ATTRIBUTE | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cdumez
Contributor
|
||
EXPECT_EQ(0U, vec1.size()); | ||
EXPECT_EQ(3U, vec2.size()); | ||
for (unsigned i = 0; i < vec2.size(); ++i) | ||
|
@@ -195,6 +196,7 @@ TEST(WTF_FixedVector, MoveAssign) | |
|
||
FixedVector<unsigned> vec2; | ||
vec2 = WTFMove(vec1); | ||
IGNORE_CLANG_STATIC_ANALYZER_USE_AFTER_MOVE_ATTRIBUTE | ||
EXPECT_EQ(0U, vec1.size()); | ||
EXPECT_EQ(3U, vec2.size()); | ||
for (unsigned i = 0; i < vec2.size(); ++i) | ||
|
@@ -206,6 +208,7 @@ TEST(WTF_FixedVector, MoveVector) | |
auto vec1 = Vector<MoveOnly>::from(MoveOnly(0), MoveOnly(1), MoveOnly(2), MoveOnly(3)); | ||
EXPECT_EQ(4U, vec1.size()); | ||
FixedVector<MoveOnly> vec2(WTFMove(vec1)); | ||
IGNORE_CLANG_STATIC_ANALYZER_USE_AFTER_MOVE_ATTRIBUTE | ||
EXPECT_EQ(0U, vec1.size()); | ||
EXPECT_EQ(4U, vec2.size()); | ||
for (unsigned index = 0; index < vec2.size(); ++index) | ||
|
@@ -219,6 +222,7 @@ TEST(WTF_FixedVector, MoveAssignVector) | |
auto vec1 = Vector<MoveOnly>::from(MoveOnly(0), MoveOnly(1), MoveOnly(2), MoveOnly(3)); | ||
EXPECT_EQ(4U, vec1.size()); | ||
vec2 = WTFMove(vec1); | ||
IGNORE_CLANG_STATIC_ANALYZER_USE_AFTER_MOVE_ATTRIBUTE | ||
EXPECT_EQ(0U, vec1.size()); | ||
} | ||
EXPECT_EQ(4U, vec2.size()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Personally I find these super confusing. I have no idea what they apply to. I wish we'd use
_BEGIN
&_END
to wrap the affected code, similarly to what we already do to suppress deprecation warnings.Can we fix that?