[PATCH] D68569: [clang-format] Also look for .{ext}.clang-format file
Anders Waldenborg via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 7 05:01:50 PDT 2019
wanders added a comment.
The "Language" option can not distinguish between C and C++.
We have projects which contains both C and C++ code. Using different style (yes..) for C and C++. Our C++ headers are named hpp.
In our toplevel we have the following symlinks
.c.clang-format -> clang-format/c.clang-format
.h.clang-format -> clang-format/c.clang-format
.cpp.clang-format -> clang-format/cpp.clang-format
.hpp.clang-format -> clang-format/cpp.clang-format
Before this we had a horrible wrapper script that used cd into different directories depending on extension, and those directories had different .clang-format files, and then had to run clang-format from stdin.
An alternative implementation I did consider was to add some kind of path matching in the configuration file doing multiple yaml documents in the configuration file. So in my case it would be something like:
---
Language: Cpp
IndentWidth: 4
TabWidth: 4
MoreStuff...
---
PathMatch: [ *.cpp, *.hpp ]
SpaceBeforeParen: ControlStatements
---
PathMatch [ *.c, *.h ]
SpaceBeforeParen: Never
---
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68569/new/
https://reviews.llvm.org/D68569
More information about the cfe-commits
mailing list