[PATCH] Config file support for clang-format, part 2.

Kim Gräsman kim.grasman at gmail.com
Thu May 9 00:55:26 PDT 2013


  Looks good!

  Did you try provoking a syntax error? Unless it's been short-circuited, I think the YAML parsing framework will print a diagnostic before your manual llvm::errs() output, but I don't have time to rebuild and check right now.


================
Comment at: lib/Format/Format.cpp:56-64
@@ -55,1 +55,11 @@
+    } else {
+      StringRef StylesArray[] = { "LLVM", "Google", "Chromium", "Mozilla" };
+      ArrayRef<StringRef> Styles(StylesArray);
+      for (size_t i = 0; i < Styles.size(); ++i) {
+        StringRef StyleName(Styles[i]);
+        if (Style == clang::format::getPredefinedStyle(StyleName)) {
+          IO.mapOptional("# BasedOnStyle", StyleName);
+          break;
+        }
+      }
     }
----------------
Maybe move this into clang::format::isPredefinedStyle(const FormatStyle& Style)?

That way you don't have to re-define the predefined style names here too.

================
Comment at: lib/Format/Format.cpp:61
@@ +60,3 @@
+        if (Style == clang::format::getPredefinedStyle(StyleName)) {
+          IO.mapOptional("# BasedOnStyle", StyleName);
+          break;
----------------
IIRC, the YAML parser doesn't take "#" comments, only JavaScript-style "//", but I'm not 100% sure. Did you try roundtripping a dumped configuration?


http://llvm-reviews.chandlerc.com/D758



More information about the cfe-commits mailing list