[clang] e9fb239 - [WebKit Checkers] Treat attributes as trivial (#127289)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 14 17:43:47 PST 2025
Author: Ryosuke Niwa
Date: 2025-02-14T17:43:43-08:00
New Revision: e9fb2391210e20d1d4dcf8bbe37085df902ed028
URL: https://github.com/llvm/llvm-project/commit/e9fb2391210e20d1d4dcf8bbe37085df902ed028
DIFF: https://github.com/llvm/llvm-project/commit/e9fb2391210e20d1d4dcf8bbe37085df902ed028.diff
LOG: [WebKit Checkers] Treat attributes as trivial (#127289)
For the purpose of determining triviality, ignore all attributes.
Added:
Modified:
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 5b8d1184050e9..8340de9e5a7a9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -392,6 +392,11 @@ class TrivialFunctionAnalysisVisitor
return false;
}
+ bool VisitAttributedStmt(const AttributedStmt *AS) {
+ // Ignore attributes.
+ return Visit(AS->getSubStmt());
+ }
+
bool VisitCompoundStmt(const CompoundStmt *CS) {
// A compound statement is allowed as long each individual sub-statement
// is trivial.
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
index cf403851b74fd..fe7ce158eb8ba 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
@@ -376,6 +376,7 @@ class RefCounted {
};
void trivial68() { point pt = { 1.0 }; }
unsigned trivial69() { return offsetof(RefCounted, children); }
+ DerivedNumber* trivial70() { [[clang::suppress]] return static_cast<DerivedNumber*>(number); }
static RefCounted& singleton() {
static RefCounted s_RefCounted;
@@ -564,6 +565,7 @@ class UnrelatedClass {
getFieldTrivial().trivial67()->trivial6(); // no-warning
getFieldTrivial().trivial68(); // no-warning
getFieldTrivial().trivial69(); // no-warning
+ getFieldTrivial().trivial70(); // no-warning
RefCounted::singleton().trivial18(); // no-warning
RefCounted::singleton().someFunction(); // no-warning
More information about the cfe-commits
mailing list