Skip to content

[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

Merged
merged 1 commit into from
Feb 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
Original file line number Diff line number Diff line change
@@ -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