Is it possible to instruct clang-format not to change
z = sqrt(x*x + y*y);
into
z = sqrt(x * x + y * y);
That is, to leave whitespaces between binary operators up to the programmer.
clang-tidy is a clang-based C++ “linter” tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis.
clang-format supports two ways to provide custom style options: directly specify style configuration in the -style= command line option or use -style=file and put style configuration in the . clang-format or _clang-format file in the project directory.
Standalone Tool. clang-format is located in clang/tools/clang-format and can be used to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
You can install clang-format and git-clang-format via npm install -g clang-format . To automatically format a file according to Electron C++ code style, run clang-format -i path/to/electron/file.cc . It should work on macOS/Linux/Windows.
Unfortunately, clang-format does not directly support this feature (most recent release is clang 7 but this might change in the future). The closest feature it currently supports is to not insert spaces before the assignment operator [SpaceBeforeAssignmentOperators]. Based on that, I believe that it might not be too complicated to extend clang-format to support other binary operators as well but I am not familiar with the clang-format code base so I might as well be wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With