jediry wrote:

> I am not sure if it's best to push a new command line flag to all other tools 
> that use clang-format as a library.
> 
> Have you considered any other alternatives that can self-contain this in 
> clang-format? e.g can we just treat paths as relative to current 
> `.clang-format` file ?
@kadircet @mydeveloperday @HazardyKnusperkeks I would love to make this more 
self-contained, as this certainly does hit a lot of layers of code. I 
specifically selected this approach because of its similarity to the familiar 
```-I``` mechanism for specifying include paths for C/C++. Two other ideas I 
did consider are:
1. Allow the use of environment variables in the path (e.g., ```BasedOnStyle: 
$(FORMATDIR)\team1.clang-format```). Not sure if this is better or worse than 
the current approach, though it's certainly a smaller code change. (That said, 
I find that most command-line tools that find things via environment variable 
also support command-line overrides for this, since it's sometimes cumbersome 
to have to set the environment variable in order to use the tool.)
2. As you say, do this relative to the current .clang-format file. This is also 
more self-contained, though it has the downside of being easily broken by code 
moves (e.g., if I "git mv" a directory to a different path, expressions like 
```BasedOnStyle: ../../../format/team1.clang-format``` become invalid).

I'm happy to go a different way with this if that is preferred.

https://github.com/llvm/llvm-project/pull/107312
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to