forked from OSchip/llvm-project
[clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess
clang-format see the `disable:` in __pragma(warning(disable:)) as ObjectiveC method call Remove any line starting with `#` or __pragma line from being part of the ObjectiveC guess https://bugs.llvm.org/show_bug.cgi?id=42434 Reviewed By: curdeius, krasimir Differential Revision: https://reviews.llvm.org/D92922
This commit is contained in:
parent
254677e9ed
commit
7b2d62fd7f
|
@ -2032,6 +2032,10 @@ private:
|
|||
};
|
||||
|
||||
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) &&
|
||||
|
|
|
@ -16713,6 +16713,15 @@ TEST_F(FormatTest, GuessLanguageWithCaret) {
|
|||
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:
|
||||
|
|
Loading…
Reference in New Issue