[clang] [Webkit Checkers] Treat const member variables as a safe origin (PR #115594)

Ryosuke Niwa via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 14 17:01:43 PST 2024


================
@@ -145,25 +145,36 @@ bool isCtorOfSafePtr(const clang::FunctionDecl *F) {
   return isCtorOfRefCounted(F) || isCtorOfCheckedPtr(F);
 }
 
-bool isSafePtrType(const clang::QualType T) {
+template <typename Predicate>
+static bool isPtrOfType(const clang::QualType T, Predicate Pred) {
   QualType type = T;
   while (!type.isNull()) {
     if (auto *elaboratedT = type->getAs<ElaboratedType>()) {
       type = elaboratedT->desugar();
       continue;
     }
     if (auto *specialT = type->getAs<TemplateSpecializationType>()) {
-      if (auto *decl = specialT->getTemplateName().getAsTemplateDecl()) {
-        auto name = decl->getNameAsString();
-        return isRefType(name) || isCheckedPtr(name);
-      }
+      if (auto *decl = specialT->getTemplateName().getAsTemplateDecl())
----------------
rniwa wrote:

Changed to use early return.

https://github.com/llvm/llvm-project/pull/115594


More information about the cfe-commits mailing list