[clang] [clang-format] Fix requires misannotation with comma (PR #65908)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 10 13:18:30 PDT 2023


================
@@ -3369,9 +3369,13 @@ bool clang::format::UnwrappedLineParser::parseRequires() {
     case tok::kw_volatile:
     case tok::kw_const:
     case tok::comma:
-      FormatTok = Tokens->setPosition(StoredPosition);
-      parseRequiresExpression(RequiresToken);
-      return false;
+      if (OpenAngles == 0) {
+        FormatTok = Tokens->setPosition(StoredPosition);
+        parseRequiresExpression(RequiresToken);
+        return false;
+      } else {
+        break;
+      }
----------------
owenca wrote:

The former is more consistent with the rest of the `switch` statement, except that there should be no `else` after the `return`. So I would prefer:
```
      if (OpenAngles == 0) {
        FormatTok = Tokens->setPosition(StoredPosition);
        parseRequiresExpression(RequiresToken);
        return false;
      }
      break;
```

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


More information about the cfe-commits mailing list