[clang] [NFC] [dataflow] generalize smart pointer caching (PR #133350)

Florian Mayer via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 28 12:55:56 PDT 2025


================
@@ -23,12 +24,27 @@ using ast_matchers::pointerType;
 using ast_matchers::referenceType;
 using ast_matchers::returns;
 
-bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet,
-                               bool &HasValue) {
+CanQualType getLikeReturnType(QualType RT) {
+  if (!RT.isNull() && RT->isPointerType()) {
+    return RT->getPointeeType()
+        ->getCanonicalTypeUnqualified()
+        .getUnqualifiedType();
+  }
+  return {};
+}
+
+CanQualType valueLikeReturnType(QualType RT) {
+  if (!RT.isNull() && RT->isReferenceType()) {
+    return RT.getNonReferenceType()
+        ->getCanonicalTypeUnqualified()
+        .getUnqualifiedType();
+  }
+  return {};
+}
+
+CanQualType pointerLikeReturnType(const CXXRecordDecl &RD) {
   // We may want to cache this search, but in current profiles it hasn't shown
   // up as a hot spot (possibly because there aren't many hits, relatively).
-  bool HasArrow = false;
-  bool HasStar = false;
   CanQualType StarReturnType, ArrowReturnType, GetReturnType, ValueReturnType;
----------------
fmayer wrote:

oh yes, thanks

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


More information about the cfe-commits mailing list