[PATCH] D109752: [clang-format] Top-level unwrapped lines don't follow a left brace

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 14 03:00:30 PDT 2021


owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks.
owenpan added a project: clang-format.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch makes characterizing top-level unwrapped lines more precise. There are no test cases to add unless we want to include invalid ones, e.g.:

  {
    int f(i)
    int i;
    {
      return i + 1;
    }
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109752

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -431,7 +431,7 @@
       }
       LLVM_FALLTHROUGH;
     default:
-      parseStructuralElement(/*IsTopLevel=*/true);
+      parseStructuralElement(!HasOpeningBrace);
       break;
     }
   } while (!eof());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109752.372444.patch
Type: text/x-patch
Size: 417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210914/7cec2bce/attachment.bin>


More information about the cfe-commits mailing list