[PATCH] D116299: [clang-format] Apply multiple children configs on fallback style

Zhao Wei Liew via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 26 21:37:30 PST 2021


zwliew created this revision.
zwliew requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allow multiple children configs to be applied on top of the fallback style.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116299

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===================================================================
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3390,17 +3390,16 @@
                              UnsuitableConfigFiles);
 
   if (!ChildFormatTextToApply.empty()) {
-    assert(ChildFormatTextToApply.size() == 1);
-
     LLVM_DEBUG(llvm::dbgs()
-               << "Applying child configuration on fallback style\n");
-
-    auto Ec =
-        parseConfiguration(*ChildFormatTextToApply.front(), &FallbackStyle,
-                           AllowUnknownOptions, dropDiagnosticHandler);
-    // It was already correctly parsed.
-    assert(!Ec);
-    static_cast<void>(Ec);
+               << "Applying child configurations on fallback style\n");
+
+    for (const auto &MemBuf : llvm::reverse(ChildFormatTextToApply)) {
+      auto Ec = parseConfiguration(*MemBuf, &FallbackStyle, AllowUnknownOptions,
+                                   dropDiagnosticHandler);
+      // It was already correctly parsed.
+      assert(!Ec);
+      static_cast<void>(Ec);
+    }
   }
 
   return FallbackStyle;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116299.396265.patch
Type: text/x-patch
Size: 1116 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211227/ffe0216c/attachment.bin>


More information about the cfe-commits mailing list