-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[clang-format] Fix the indent of StartOfName after AttributeMacro #140361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) ChangesFix #139510 Full diff: https://github.com/llvm/llvm-project/pull/140361.diff 2 Files Affected:
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 55e1d1ceb55b7..b31fb29e7c4a0 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1475,6 +1475,8 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) {
(PreviousNonComment->ClosesTemplateDeclaration ||
PreviousNonComment->ClosesRequiresClause ||
(PreviousNonComment->is(TT_AttributeMacro) &&
+ !Current.endsSequence(TT_StartOfName, TT_AttributeMacro,
+ TT_PointerOrReference) &&
Current.isNot(tok::l_paren)) ||
PreviousNonComment->isOneOf(
TT_AttributeRParen, TT_AttributeSquare, TT_FunctionAnnotationRParen,
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 436beaf68bd2a..8fe57c80cbe25 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12714,6 +12714,13 @@ TEST_F(FormatTest, UnderstandsAttributes) {
verifyGoogleFormat("SomeType* absl_nullable s{InitValue};");
verifyGoogleFormat("SomeType* absl_nullability_unknown s(InitValue);");
verifyGoogleFormat("SomeType* absl_nullability_unknown s{InitValue};");
+
+ auto Style = getLLVMStyleWithColumns(60);
+ Style.AttributeMacros.push_back("my_fancy_attr");
+ Style.PointerAlignment = FormatStyle::PAS_Left;
+ verifyFormat("void foo(const MyLongTypeNameeeeeeeeeeeee* my_fancy_attr\n"
+ " testttttttttt);",
+ Style);
}
TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) {
|
|
/cherry-pick 0cac25b |
|
Failed to cherry-pick: 0cac25b https://github.com/llvm/llvm-project/actions/runs/15177822654 Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request |
…ibuteMacro (llvm#140361) Backport 0cac25b
|
This was backported in #141004 |
Fix #139510