This allows the define BasedOnStyle: InheritParentConfig and then clang-format looks into the parent directories for their .clang-format and takes that as a basis.
My use case is to remove the column limit for my tests.
HazardyKnusperkeks on Sun, Dec 27, 1:38 PM.Authored by
I'm a little confused why this is needed as clang-format always read up the directory tree until it see a .clang-format file, perhaps I don't quite understand the use case. Can't you just have a different .clang-format in the subdirectory?
Yes of course I can, but I don't want to copy everything except the one thing I want to change.
I have one .clang-format in my main directory and since I only want to change the column limit for my tests I want to write a .clang-format in the test directory with the content:
BasedOnStyle: File ColumnLimit: 0
So when I change (or better add) a value in my main .clang-format it will also apply to my tests, without touching their file.
It's my understanding this is akin to the InheritParentConfig option found in .clang-tidy.
We have it quite lucky here at LLVM where for tests we can just use:
BasedOnStyle: LLVM ColumnLimit: 0
However for other projects with their own style they could then use:
# Copy the root directory clang.format config BasedOnStyle: file ColumnLimit: 0
This would also make modifying the formatting style of a project much easier as you would only need to touch the root directory .clang-format file in most cases.
With this implementation I'm not too sure on the specifics though. .clang-format files are more complex to parse than .clang-tidy files so there's more edge cases to consider.
Initially I thought it shouldn't. But now I think maybe it should.
I like what you are suggesting, do you think BasedOnStyle: File is the best terminology as the term File is used elsewhere to mean read from the .clang_format file, how about
or why not just
to match clang-tidy?
Okay after rechecking the code (it is a bit ago that I wrote it), what more do you need? I compare the parsed style against a base style (Google, to show that it’s not the default LLVM) modified with the values from the overwrite. Only for the last checks where I basically check the same over and over again, just trough different means I use a stored style.