<p dir="ltr">I've tried, of course. And my message goes after YAML I/O's, but this way it's still informative enough for diagnostic purposes. And I thought we can come back to this once YAML I/O has better support for this.</p>

<div class="gmail_quote">On May 9, 2013 9:54 AM, "Kim Gräsman" <<a href="mailto:kim.grasman@gmail.com">kim.grasman@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
  Looks good!<br>
<br>
  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.<br>

<br>
<br>
================<br>
Comment at: lib/Format/Format.cpp:56-64<br>
@@ -55,1 +55,11 @@<br>
+    } else {<br>
+      StringRef StylesArray[] = { "LLVM", "Google", "Chromium", "Mozilla" };<br>
+      ArrayRef<StringRef> Styles(StylesArray);<br>
+      for (size_t i = 0; i < Styles.size(); ++i) {<br>
+        StringRef StyleName(Styles[i]);<br>
+        if (Style == clang::format::getPredefinedStyle(StyleName)) {<br>
+          IO.mapOptional("# BasedOnStyle", StyleName);<br>
+          break;<br>
+        }<br>
+      }<br>
     }<br>
----------------<br>
Maybe move this into clang::format::isPredefinedStyle(const FormatStyle& Style)?<br>
<br>
That way you don't have to re-define the predefined style names here too.<br>
<br>
================<br>
Comment at: lib/Format/Format.cpp:61<br>
@@ +60,3 @@<br>
+        if (Style == clang::format::getPredefinedStyle(StyleName)) {<br>
+          IO.mapOptional("# BasedOnStyle", StyleName);<br>
+          break;<br>
----------------<br>
IIRC, the YAML parser doesn't take "#" comments, only JavaScript-style "//", but I'm not 100% sure. Did you try roundtripping a dumped configuration?<br>
<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D758" target="_blank">http://llvm-reviews.chandlerc.com/D758</a><br>
</blockquote></div>