[PATCH] D92922: [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 9 07:12:49 PST 2020
MyDeveloperDay updated this revision to Diff 310524.
MyDeveloperDay added a comment.
add support for additional _Pragma
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92922/new/
https://reviews.llvm.org/D92922
Files:
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,15 @@
guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
}
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+ EXPECT_EQ(FormatStyle::LK_Cpp,
+ guessLanguage("foo.h", "__pragma(warning(disable:))"));
+ EXPECT_EQ(FormatStyle::LK_Cpp,
+ guessLanguage("foo.h", "#pragma(warning(disable:))"));
+ EXPECT_EQ(FormatStyle::LK_Cpp,
+ guessLanguage("foo.h", "_Pragma(warning(disable:))"));
+}
+
TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
// ASM symbolic names are identifiers that must be surrounded by [] without
// space in between:
Index: clang/lib/Format/Format.cpp
===================================================================
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2032,6 +2032,10 @@
};
for (auto Line : AnnotatedLines) {
+ if (Line->First && (Line->First->TokenText.startswith("#") ||
+ Line->First->TokenText == "__pragma" ||
+ Line->First->TokenText == "_Pragma"))
+ continue;
for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92922.310524.patch
Type: text/x-patch
Size: 1465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201209/d661ad2a/attachment.bin>
More information about the cfe-commits
mailing list