Skip to content

Commit bb9f025

Browse files
rniwasivan-shani
authored andcommitted
[WebKit Checkers] Treat attributes as trivial (llvm#127289)
For the purpose of determining triviality, ignore all attributes.
1 parent a0a1f37 commit bb9f025

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ class TrivialFunctionAnalysisVisitor
392392
return false;
393393
}
394394

395+
bool VisitAttributedStmt(const AttributedStmt *AS) {
396+
// Ignore attributes.
397+
return Visit(AS->getSubStmt());
398+
}
399+
395400
bool VisitCompoundStmt(const CompoundStmt *CS) {
396401
// A compound statement is allowed as long each individual sub-statement
397402
// is trivial.

clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ class RefCounted {
376376
};
377377
void trivial68() { point pt = { 1.0 }; }
378378
unsigned trivial69() { return offsetof(RefCounted, children); }
379+
DerivedNumber* trivial70() { [[clang::suppress]] return static_cast<DerivedNumber*>(number); }
379380

380381
static RefCounted& singleton() {
381382
static RefCounted s_RefCounted;
@@ -564,6 +565,7 @@ class UnrelatedClass {
564565
getFieldTrivial().trivial67()->trivial6(); // no-warning
565566
getFieldTrivial().trivial68(); // no-warning
566567
getFieldTrivial().trivial69(); // no-warning
568+
getFieldTrivial().trivial70(); // no-warning
567569

568570
RefCounted::singleton().trivial18(); // no-warning
569571
RefCounted::singleton().someFunction(); // no-warning

0 commit comments

Comments
 (0)