[prev in list] [next in list] [prev in thread] [next in thread]
List: cfe-commits
Subject: [PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses
From: Joseph Huber via Phabricator via cfe-commits <cfe-commits () lists ! llvm ! org>
Date: 2023-02-28 21:16:08
Message-ID: LhXZ_pVVShWpSqW0Ap8Oiw () geopod-ismtpd-7
[Download RAW message or body]
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG466b4327f8fc: [clang-format] Only add pragma continuation \
indentation for 'omp' clauses (authored by jhuber6).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144884/new/
https://reviews.llvm.org/D144884
Files:
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20560,6 +20560,21 @@
"(including parentheses).",
format("#pragma mark Any non-hyphenated or hyphenated string "
"(including parentheses)."));
+
+ EXPECT_EQ("#pragma mark Any non-hyphenated or hyphenated string "
+ "(including parentheses).",
+ format("#pragma mark Any non-hyphenated or hyphenated string "
+ "(including parentheses)."));
+
+ EXPECT_EQ(
+ "#pragma comment(linker, \\\n"
+ " \"argument\" \\\n"
+ " \"argument\"",
+ format("#pragma comment(linker, \\\n"
+ " \"argument\" \\\n"
+ " \"argument\"",
+ getStyleWithColumns(
+ getChromiumStyle(FormatStyle::LanguageKind::LK_Cpp), 32)));
}
TEST_F(FormatTest, UnderstandsPragmaOmpTarget) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1273,8 +1273,13 @@
return ContinuationIndent;
}
- if (State.Line->InPragmaDirective)
- return CurrentState.Indent + Style.ContinuationIndentWidth;
+ // OpenMP clauses want to get additional indentation when they are pushed onto
+ // the next line.
+ if (State.Line->InPragmaDirective) {
+ FormatToken *PragmaType = State.Line->First->Next->Next;
+ if (PragmaType && PragmaType->TokenText.equals("omp"))
+ return CurrentState.Indent + Style.ContinuationIndentWidth;
+ }
// This ensure that we correctly format ObjC methods calls without inputs,
// i.e. where the last element isn't selector like: [callee method];
["D144884.501275.patch" (D144884.501275.patch)]
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20560,6 +20560,21 @@
"(including parentheses).",
format("#pragma mark Any non-hyphenated or hyphenated string "
"(including parentheses)."));
+
+ EXPECT_EQ("#pragma mark Any non-hyphenated or hyphenated string "
+ "(including parentheses).",
+ format("#pragma mark Any non-hyphenated or hyphenated string "
+ "(including parentheses)."));
+
+ EXPECT_EQ(
+ "#pragma comment(linker, \\\n"
+ " \"argument\" \\\n"
+ " \"argument\"",
+ format("#pragma comment(linker, \\\n"
+ " \"argument\" \\\n"
+ " \"argument\"",
+ getStyleWithColumns(
+ getChromiumStyle(FormatStyle::LanguageKind::LK_Cpp), 32)));
}
TEST_F(FormatTest, UnderstandsPragmaOmpTarget) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===================================================================
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1273,8 +1273,13 @@
return ContinuationIndent;
}
- if (State.Line->InPragmaDirective)
- return CurrentState.Indent + Style.ContinuationIndentWidth;
+ // OpenMP clauses want to get additional indentation when they are pushed onto
+ // the next line.
+ if (State.Line->InPragmaDirective) {
+ FormatToken *PragmaType = State.Line->First->Next->Next;
+ if (PragmaType && PragmaType->TokenText.equals("omp"))
+ return CurrentState.Indent + Style.ContinuationIndentWidth;
+ }
// This ensure that we correctly format ObjC methods calls without inputs,
// i.e. where the last element isn't selector like: [callee method];
[Attachment #4 (text/plain)]
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic