[clang] [alpha.webkit.UncountedCallArgsChecker] Add the support for trivial CXXInheritedCtorInitExpr. (PR #111198)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 11:58:28 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Ryosuke Niwa (rniwa)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/111198.diff
2 Files Affected:
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp (+4)
- (modified) clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp (+21)
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 4d145be808f6d8..317642c5b9ca20 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -508,6 +508,10 @@ class TrivialFunctionAnalysisVisitor
return IsFunctionTrivial(CE->getConstructor());
}
+ bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E) {
+ return IsFunctionTrivial(E->getConstructor());
+ }
+
bool VisitCXXNewExpr(const CXXNewExpr *NE) { return VisitChildren(NE); }
bool VisitImplicitCastExpr(const ImplicitCastExpr *ICE) {
diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
index 97efb354f0371d..75efc397abcc12 100644
--- a/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
@@ -224,6 +224,20 @@ class ObjectWithMutatingDestructor {
Number n;
};
+class BaseType {
+public:
+ BaseType() : n(0) { }
+ BaseType(int v) : n(v) { }
+ BaseType(const char*);
+private:
+ Number n;
+};
+
+class SomeType : public BaseType {
+public:
+ using BaseType::BaseType;
+};
+
class RefCounted {
public:
void ref() const;
@@ -336,6 +350,8 @@ class RefCounted {
unsigned trivial60() { return ObjectWithNonTrivialDestructor { 5 }.value(); }
unsigned trivial61() { return DerivedNumber('7').value(); }
void trivial62() { WTFReportBacktrace(); }
+ SomeType trivial63() { return SomeType(0); }
+ SomeType trivial64() { return SomeType(); }
static RefCounted& singleton() {
static RefCounted s_RefCounted;
@@ -425,6 +441,7 @@ class RefCounted {
unsigned nonTrivial21() { return Number("123").value(); }
unsigned nonTrivial22() { return ComplexNumber(123, "456").real().value(); }
unsigned nonTrivial23() { return DerivedNumber("123").value(); }
+ SomeType nonTrivial24() { return SomeType("123"); }
static unsigned s_v;
unsigned v { 0 };
@@ -515,6 +532,8 @@ class UnrelatedClass {
getFieldTrivial().trivial60(); // no-warning
getFieldTrivial().trivial61(); // no-warning
getFieldTrivial().trivial62(); // no-warning
+ getFieldTrivial().trivial63(); // no-warning
+ getFieldTrivial().trivial64(); // no-warning
RefCounted::singleton().trivial18(); // no-warning
RefCounted::singleton().someFunction(); // no-warning
@@ -587,6 +606,8 @@ class UnrelatedClass {
// expected-warning at -1{{Call argument for 'this' parameter is uncounted and unsafe}}
getFieldTrivial().nonTrivial23();
// expected-warning at -1{{Call argument for 'this' parameter is uncounted and unsafe}}
+ getFieldTrivial().nonTrivial24();
+ // expected-warning at -1{{Call argument for 'this' parameter is uncounted and unsafe}}
}
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/111198
More information about the cfe-commits
mailing list