Author: geoffreygaren Date: 2026-09-17T01:14:50-07:00 New Revision: de199ddad27f332fd6235fa7b5fc059c798811ff
URL: https://github.com/llvm/llvm-project/commit/de199ddad27f332fd6235fa7b5fc059c798811ff DIFF: https://github.com/llvm/llvm-project/commit/de199ddad27f332fd6235fa7b5fc059c798811ff.diff LOG: [WebKit Checkers] Honor using declarations when looking up protocol conformance (#223902) Added: Modified: clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index bdf6358f1ca15..d8a62db4daee1 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -30,6 +30,15 @@ bool hasPublicMethodInBaseClass(const CXXRecordDecl *R, StringRef NameToMatch) { if (MethodName == NameToMatch && MD->getAccess() == AS_public) return true; } + + for (const Decl *D : R->decls()) { + const auto *Shadow = dyn_cast<UsingShadowDecl>(D); + if (!Shadow || Shadow->getAccess() != AS_public) + continue; + const auto *MD = dyn_cast<CXXMethodDecl>(Shadow->getTargetDecl()); + if (MD && safeGetName(MD) == NameToMatch) + return true; + } return false; } diff --git a/clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp b/clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp index 2d3b5a5fef261..c6c75968ae924 100644 --- a/clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp +++ b/clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp @@ -759,3 +759,43 @@ namespace lambda_capture { } } // namespace lambda_capture + +namespace using_reexported_ref_deref { + class ProtectedRefBase { + protected: + void ref() const; + void deref() const; + }; + + class PublicUsing : private ProtectedRefBase { + public: + using ProtectedRefBase::ref; + using ProtectedRefBase::deref; + void method(); + }; + + PublicUsing* provide_public_using(); + + void public_using() { + PublicUsing* a = provide_public_using(); + // expected-warning@-1{{Local variable 'a' is a raw pointer to RefPtr-capable type 'using_reexported_ref_deref::PublicUsing' [alpha.webkit.UncountedLocalVarsChecker]}} + someFunction(); + a->method(); + } + + class PrivateUsing : private ProtectedRefBase { + using ProtectedRefBase::ref; + using ProtectedRefBase::deref; + public: + void method(); + }; + + PrivateUsing* provide_private_using(); + + void private_using() { + PrivateUsing* a = provide_private_using(); // no-warning + someFunction(); + a->method(); + } + +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
