mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-15 12:39:19 +00:00
[clan-format] detect function definitions more conservatively
https://reviews.llvm.org/D105964 updated the detection of function definitions. It had the unfortunate effect to start marking object definitions with attribute-like macros as function definitions. This addresses this issue. Reviewed By: owenpan Differential Revision: https://reviews.llvm.org/D107269
This commit is contained in:
parent
ac2bc4e0fc
commit
f6bc614546
@ -2482,7 +2482,7 @@ static bool isFunctionDeclarationName(const FormatToken &Current,
|
||||
// return i + 1;
|
||||
// }
|
||||
if (Next->Next && Next->Next->is(tok::identifier) &&
|
||||
!(Next->MatchingParen->Next && Next->MatchingParen->Next->is(tok::semi)))
|
||||
Line.Last->isNot(tok::semi))
|
||||
return true;
|
||||
for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
|
||||
Tok = Tok->Next) {
|
||||
|
@ -8224,7 +8224,12 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
|
||||
"f(i)\n"
|
||||
"{\n"
|
||||
" return i + 1;\n"
|
||||
"}",
|
||||
"}\n"
|
||||
"int\n" // Break here.
|
||||
"f(i)\n"
|
||||
"{\n"
|
||||
" return i + 1;\n"
|
||||
"};",
|
||||
Style);
|
||||
verifyFormat("int f(a, b, c);\n" // No break here.
|
||||
"int\n" // Break here.
|
||||
@ -8233,8 +8238,20 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
|
||||
"float c;\n"
|
||||
"{\n"
|
||||
" return a + b < c;\n"
|
||||
"}",
|
||||
"}\n"
|
||||
"int\n" // Break here.
|
||||
"f(a, b, c)\n" // Break here.
|
||||
"short a, b;\n"
|
||||
"float c;\n"
|
||||
"{\n"
|
||||
" return a + b < c;\n"
|
||||
"};",
|
||||
Style);
|
||||
// The return breaking style doesn't affect object definitions with
|
||||
// attribute-like macros.
|
||||
verifyFormat("Tttttttttttttttttttttttt ppppppppppppppp\n"
|
||||
" ABSL_GUARDED_BY(mutex) = {};",
|
||||
getGoogleStyleWithColumns(40));
|
||||
|
||||
Style = getGNUStyle();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user