diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index d2b6634105800..0fd8afedc0b0f 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -84,6 +84,7 @@ std::optional isRefCountable(const CXXRecordDecl* R) if (AnyInconclusiveBase) return std::nullopt; + Paths.clear(); const auto hasPublicDerefInBase = [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) { auto hasDerefInBase = clang::hasPublicMethodInBase(Base, "deref"); diff --git a/clang/test/Analysis/Checkers/WebKit/implicit-cast-to-base-class-with-deref-in-superclass.cpp b/clang/test/Analysis/Checkers/WebKit/implicit-cast-to-base-class-with-deref-in-superclass.cpp new file mode 100644 index 0000000000000..176238f31bd2e --- /dev/null +++ b/clang/test/Analysis/Checkers/WebKit/implicit-cast-to-base-class-with-deref-in-superclass.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s +// expected-no-diagnostics + +#include "mock-types.h" + +class Base { +public: + virtual ~Base(); + void ref() const; + void deref() const; +}; + +class Event : public Base { +protected: + explicit Event(); +}; + +class SubEvent : public Event { +public: + static Ref create(); +private: + SubEvent() = default; +}; + +void someFunction(Base&); + +static void test() +{ + someFunction(SubEvent::create()); +}