diff options
author | Owen Pan <owenpiano@gmail.com> | 2025-03-27 01:00:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-27 01:00:02 -0700 |
commit | 05fb8408de23c3ccb6125b6886742177755bd757 (patch) | |
tree | 3622a21760159501ac807332cd645f6065a711a4 /clang/unittests/Format/ConfigParseTest.cpp | |
parent | b8a0558dea942b40f6cdcfaf9b6ba62d4140d693 (diff) | |
download | llvm-05fb8408de23c3ccb6125b6886742177755bd757.zip llvm-05fb8408de23c3ccb6125b6886742177755bd757.tar.gz llvm-05fb8408de23c3ccb6125b6886742177755bd757.tar.bz2 |
[clang-format] Allow `Language: Cpp` for C files (#133033)
Fix #132832
Diffstat (limited to 'clang/unittests/Format/ConfigParseTest.cpp')
-rw-r--r-- | clang/unittests/Format/ConfigParseTest.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp index cc42642..287191d 100644 --- a/clang/unittests/Format/ConfigParseTest.cpp +++ b/clang/unittests/Format/ConfigParseTest.cpp @@ -1230,6 +1230,26 @@ TEST(ConfigParseTest, ParsesConfigurationWithLanguages) { IndentWidth, 56u); } +TEST(ConfigParseTest, AllowCppForC) { + FormatStyle Style = {}; + Style.Language = FormatStyle::LK_C; + EXPECT_EQ(parseConfiguration("Language: Cpp", &Style), ParseError::Success); + + CHECK_PARSE("---\n" + "IndentWidth: 4\n" + "---\n" + "Language: Cpp\n" + "IndentWidth: 8\n", + IndentWidth, 8u); + + EXPECT_EQ(parseConfiguration("---\n" + "Language: ObjC\n" + "---\n" + "Language: Cpp\n", + &Style), + ParseError::Success); +} + TEST(ConfigParseTest, UsesLanguageForBasedOnStyle) { FormatStyle Style = {}; Style.Language = FormatStyle::LK_JavaScript; |