[PATCH] Allow predefined styles to define different options for different languages.

Daniel Jasper djasper at google.com
Tue Dec 10 00:51:05 PST 2013



================
Comment at: lib/Format/Format.cpp:415-416
@@ -406,1 +414,4 @@
+        DEBUG(llvm::dbgs()
+              << "Duplicate languages in the config file on positions " << j
+              << " and " << i << "\n");
         return llvm::make_error_code(llvm::errc::invalid_argument);
----------------
Interesting indentation. I think we should fix clang-format here. (Completely unrelated to this patch).

================
Comment at: include/clang/Format/Format.h:356
@@ -350,2 +355,3 @@
 /// Returns \c true if the Style has been set.
-bool getPredefinedStyle(StringRef Name, FormatStyle *Style);
+bool getPredefinedStyle(FormatStyle::LanguageKind Language, StringRef Name,
+                        FormatStyle *Style);
----------------
I'd reverse the order of the first two parameters. Intuitively, I would always think that I want "this specific style for this specific language".

================
Comment at: lib/Format/Format.cpp:87
@@ +86,3 @@
+    // When reading, read the language first, we need it for getPredefinedStyle.
+    IO.mapOptional("Language", Style.Language);
+
----------------
So, I don't understand the full flow of how the YAML parsing now works. Does this work correctly if "Language" is not the first field in a config file?


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

BRANCH
  svn

ARCANIST PROJECT
  clang



More information about the cfe-commits mailing list