-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[WebKit Checkers] Treat attributes as trivial #127289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For the purpose of determining triviality, ignore all attributes.
@llvm/pr-subscribers-clang-static-analyzer-1 Author: Ryosuke Niwa (rniwa) ChangesFor the purpose of determining triviality, ignore all attributes. Full diff: https://github.com/llvm/llvm-project/pull/127289.diff 2 Files Affected:
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
|
@llvm/pr-subscribers-clang Author: Ryosuke Niwa (rniwa) ChangesFor the purpose of determining triviality, ignore all attributes. Full diff: https://github.com/llvm/llvm-project/pull/127289.diff 2 Files Affected:
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks for the quick review! |
For the purpose of determining triviality, ignore all attributes.
For the purpose of determining triviality, ignore all attributes.
For the purpose of determining triviality, ignore all attributes.