[clang] [clang-repl] Allow private type aliases in out-of-line member function return types (PR #178842)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 9 01:34:03 PST 2026


================
@@ -78,7 +79,23 @@ bool Parser::isCXXDeclarationStatement(
     [[fallthrough]];
     // simple-declaration
   default:
-    return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false);
+
+    if (DisambiguatingWithExpression) {
+      TentativeParsingAction TPA(*this, true);
+      // We will do not check access checks here, because we want to allow
+      // parsing of declarations. Access will be checked later.
+      SuppressAccessChecks AccessExporter(*this, true);
+      if (isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false)) {
+        // Do not annotate the tokens, otherwise access will be neglected later.
+        TPA.Revert();
+        return true;
+      }
+      TPA.Commit();
+      return false;
+
+    } else {
+      return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false);
+    }
----------------
vgvassilev wrote:

```suggestion
    if (DisambiguatingWithExpression) {
      TentativeParsingAction TPA(*this, true);
      // We will do not check access checks here, because we want to allow
      // parsing of declarations. Access will be checked later.
      SuppressAccessChecks AccessExporter(*this, true);
      if (isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false)) {
        // Do not annotate the tokens, otherwise access will be neglected later.
        TPA.Revert();
        return true;
      }
      TPA.Commit();
      return false;

    }
    return isCXXSimpleDeclaration(/*AllowForRangeDecl=*/false);
    }
```

We don't need an else-after-return

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


More information about the cfe-commits mailing list