================
@@ -491,11 +491,19 @@ void UnwrappedLineParser::calculateBraceTypes(bool 
ExpectClassBody) {
   SmallVector<StackEntry, 8> LBraceStack;
   assert(Tok->is(tok::l_brace));
   do {
-    // Get next non-comment token.
-    FormatToken *NextTok;
-    do {
-      NextTok = Tokens->getNextToken();
-    } while (NextTok->is(tok::comment));
+    // Get next non-comment, non-preprocessor token.
+    FormatToken *NextTok = Tokens->getNextToken();
+    while (NextTok->is(tok::comment) ||
+           (NextTok->is(tok::hash) && isOnNewLine(*NextTok))) {
+      while (NextTok->is(tok::comment))
+        NextTok = Tokens->getNextToken();
+      while (NextTok->is(tok::hash) && isOnNewLine(*NextTok)) {
+        ScopedMacroState MacroState(*Line, Tokens, NextTok);
+        do {
+          NextTok = Tokens->getNextToken();
+        } while (NextTok->isNot(tok::eof));
+      }
+    }
----------------
owenca wrote:

```suggestion
    while (NextTok->is(tok::hash)) {
      NextTok = Tokens->getNextToken();
      do {
        NextTok = Tokens->getNextToken();
      } while (NextTok->is(tok::comment) || (NextTok->NewlinesBefore == 0 &&
                                             NextTok->isNot(tok::eof)));
    } while(NextTok->is(tok::hash));
```
And keep the deleted lines (494-498).

I don't think we need to (or should) use `isOnNewLine()` as it might miss 
PPDirective lines started with block comments.

https://github.com/llvm/llvm-project/pull/69473
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to