Skip to content

RemoveParentheses removes parentheses in macro call, resulting in , to no longer be escaped. #147780

Open
@JVApen

Description

@JVApen

Clang format with the option RemoveParentheses on MultipleParentheses removes the parentheses in the snippet below.

MOCK_METHOD((int), func, ((std::map<int, int> )), (override));

becomes:

MOCK_METHOD((int), func, (std::map<int, int> ), (override));

With the parentheses, std::map<int, int> is considered a single value for the macro. Without it, it becomes the values std::map<int and int>, both which are not a valid type.

I understand that clang-format is unable to know if this is a macro or a function call. The only thing that would give it away is fact that types are used instead of values. As such, we'll most likely need some option in the config file which indicates that a specific name maps to a macro.
Alternatively, it could detect the pattern < ... , ... >.

Metadata

Metadata

Assignees

Labels

clang-formatduplicateResolved as duplicateinvalid-code-generationTool (e.g. clang-format) produced invalid code that no longer compiles

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions