summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/Format.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp5
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index ce67b82e10b..e73bcba7951 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -961,7 +961,7 @@ FormatStyle getNoStyle() {
bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
FormatStyle *Style) {
if (Name.equals_lower("llvm")) {
- *Style = getLLVMStyle();
+ *Style = getLLVMStyle(Language);
} else if (Name.equals_lower("chromium")) {
*Style = getChromiumStyle(Language);
} else if (Name.equals_lower("mozilla")) {
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 7fcff46f581..09c49b4408e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12714,6 +12714,11 @@ TEST(FormatStyle, GetStyleOfFile) {
auto Style7 = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
ASSERT_FALSE((bool)Style7);
llvm::consumeError(Style7.takeError());
+
+ // Test 8: inferred per-language defaults apply.
+ auto StyleTd = getStyle("file", "x.td", "llvm", "", &FS);
+ ASSERT_TRUE((bool)StyleTd);
+ ASSERT_EQ(*StyleTd, getLLVMStyle(FormatStyle::LK_TableGen));
}
TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
OpenPOWER on IntegriCloud