[clang] Detect a return value of Ref<T> & RefPtr<T> (PR #81580)

Ryosuke Niwa via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 19:28:51 PST 2024


================
@@ -118,6 +118,26 @@ bool isCtorOfRefCounted(const clang::FunctionDecl *F) {
          || FunctionName == "Identifier";
 }
 
+bool isReturnValueRefCounted(const clang::FunctionDecl *F) {
+  assert(F);
+  auto *type = F->getReturnType().getTypePtrOrNull();
+  while (type) {
+    if (auto *elaboratedT = dyn_cast<ElaboratedType>(type)) {
+      type = elaboratedT->desugar().getTypePtrOrNull();
+      continue;
+    }
+    if (auto *specialT = dyn_cast<TemplateSpecializationType>(type)) {
----------------
rniwa wrote:

Sounds good. Fixed.

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


More information about the cfe-commits mailing list