Skip to content

Commit 820bab8

Browse files
authored
[alpha.webkit.UncountedCallArgsChecker] Add the support for trivial CXXInheritedCtorInitExpr. (#111198)
1 parent 0fc3e40 commit 820bab8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ class TrivialFunctionAnalysisVisitor
508508
return IsFunctionTrivial(CE->getConstructor());
509509
}
510510

511+
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E) {
512+
return IsFunctionTrivial(E->getConstructor());
513+
}
514+
511515
bool VisitCXXNewExpr(const CXXNewExpr *NE) { return VisitChildren(NE); }
512516

513517
bool VisitImplicitCastExpr(const ImplicitCastExpr *ICE) {

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,20 @@ class ObjectWithMutatingDestructor {
224224
Number n;
225225
};
226226

227+
class BaseType {
228+
public:
229+
BaseType() : n(0) { }
230+
BaseType(int v) : n(v) { }
231+
BaseType(const char*);
232+
private:
233+
Number n;
234+
};
235+
236+
class SomeType : public BaseType {
237+
public:
238+
using BaseType::BaseType;
239+
};
240+
227241
class RefCounted {
228242
public:
229243
void ref() const;
@@ -336,6 +350,8 @@ class RefCounted {
336350
unsigned trivial60() { return ObjectWithNonTrivialDestructor { 5 }.value(); }
337351
unsigned trivial61() { return DerivedNumber('7').value(); }
338352
void trivial62() { WTFReportBacktrace(); }
353+
SomeType trivial63() { return SomeType(0); }
354+
SomeType trivial64() { return SomeType(); }
339355

340356
static RefCounted& singleton() {
341357
static RefCounted s_RefCounted;
@@ -425,6 +441,7 @@ class RefCounted {
425441
unsigned nonTrivial21() { return Number("123").value(); }
426442
unsigned nonTrivial22() { return ComplexNumber(123, "456").real().value(); }
427443
unsigned nonTrivial23() { return DerivedNumber("123").value(); }
444+
SomeType nonTrivial24() { return SomeType("123"); }
428445

429446
static unsigned s_v;
430447
unsigned v { 0 };
@@ -515,6 +532,8 @@ class UnrelatedClass {
515532
getFieldTrivial().trivial60(); // no-warning
516533
getFieldTrivial().trivial61(); // no-warning
517534
getFieldTrivial().trivial62(); // no-warning
535+
getFieldTrivial().trivial63(); // no-warning
536+
getFieldTrivial().trivial64(); // no-warning
518537

519538
RefCounted::singleton().trivial18(); // no-warning
520539
RefCounted::singleton().someFunction(); // no-warning
@@ -587,6 +606,8 @@ class UnrelatedClass {
587606
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
588607
getFieldTrivial().nonTrivial23();
589608
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
609+
getFieldTrivial().nonTrivial24();
610+
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}}
590611
}
591612

592613
void setField(RefCounted*);

0 commit comments

Comments
 (0)