If the approach is not right, I'll try to rework the fix with your feedback.
Problem:
FormatStyle Spaces = getLLVMStyle();
verifyFormat("Deleted &operator=(const Deleted &)& = default;");
Spaces.SpacesInParentheses= true;
verifyFormat("Deleted( const Deleted & )& = default;", Spaces); // Fail "Deleted(const Deleted &)& = default;"
Spaces.SpacesInCStyleCastParentheses = true;
Spaces.SpacesInParentheses= false;
verifyFormat("Deleted(const Deleted &)& = default;", Spaces); // Fail "Deleted( const Deleted & )& = default;"
Solution:
The cast seemed too eager: There does not seem to be a reason for a binary operator to follow a C-cast.
The type of the function reference qualification seems to make sense as TT_PointerOrReference:
-Extend in the case of to handle the '&&' case "Deleted(const Deleted &)&& = default;"
-Extend to handle the case without '=' for '*', '&' and '&&' case "Deleted(const Deleted &)&;"
Ensure no spaces between parenthesis and the reference qualification:
"Deleted &operator=(const Deleted &)&;" can be detected with TT_OverloadedOperatorLParen
"SomeType MemberFunction(const Deleted &)&;" can be detected with TT_FunctionDeclarationName
"Deleted(const Deleted &)&;" does not exist as ref-qualification does not make sense for constructors
Tests:
The set of unit tests is not quite minimal, it needs:
- To cover LLVM, Google, SpacesInCStyleCastParentheses, SpacesInParentheses.
- Both ref-qualifications : '&' and '&&'
- Operator, function, and constructor.
Additional test:
Verify clang-format output is unchanged for the 3 modified files FormatToken.h, TokenAnnotator.cpp, FormatTest.cpp
I think, this is wrong. "<identifier>(" can be different things.