This change adds an option AfterOverloadedOperator in SpaceBeforeParensOptions to add a space between overloaded operator and opening parentheses in clang-format.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
you need to add a unit test int clang/unittest/Format/FormatTest.cpp (we tend to not use lit tests)
Incorporated review comments.
Changelog:
- Using unit test case instead of lit test case.
- Placed the option according to alphabetical order.
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3821 | I'm not fond of the current name, exactly the "Overloading" part (but have no better suggestion right now). It seems a bit misleading to me. Maybe AfterOverloadedOperator(Name)??? At least it would match the token kind name. |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3821 | +1 here, AfterOperator? |
Does it affect calling code? a.operator++(5); Should it? But please add tests for that.
Yes, it does affect the calling code as well. However, I am not sure if we should separate the two. Sure, I'll add a test case for it.
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3821 | @MyDeveloperDay Initially, I thought about using AfterOperator but it also seems a bit misleading. However, @curdeius suggestion seems reasonable given it matches with the token kind. |
clang/unittests/Format/FormatTest.cpp | ||
---|---|---|
14539 | I'm sorry if I misunderstood it, do you mean tests using CHECK_PARSE? I am confirming this because I didn't find any such test case for existing SpaceBeforeParensOptions options. |
clang/unittests/Format/FormatTest.cpp | ||
---|---|---|
14539 | Than this has slipped through, but there should be a test for every parsing aspect. |
clang/unittests/Format/FormatTest.cpp | ||
---|---|---|
14539 | Thanks for confirming. Not an issue, I'll try to add a test case for existing options as well then. |
Incorporated review comments.
- Added Check Parse test case for SpaceBeforeParensOptions.
- Renamed the option to AfterOverloadedOperator.
- Added operator overloading instantiation scenario in the unit test as well.
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
3826 | Please add operator call as well to the example (object.operator++ (0)). |
LGTM.
If you need help landing this (if you don't have commit rights), just give your name and email that you want to be used for the contribution and someone will land it for you.
See also https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access if you think contributing more patches.
Not an issue :)
Thanks everyone for taking time to review this change.
Yes, I don't have commit rights. Please land this change for me (name : Rajat Bajpai and email: rb.macboy@gmail.com).
I will apply for commit access for future changes.
I'm not fond of the current name, exactly the "Overloading" part (but have no better suggestion right now). It seems a bit misleading to me.
Maybe AfterOverloadedOperator(Name)??? At least it would match the token kind name.