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;


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;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to