By additional regex match, grouping of main include can be enabled in files that are not normally considered as a C/C++ source code.
For example, this might be useful in templated code, where template implementations are being held in *Impl.hpp files.
On the occassion, 'assume-filename' option description was reworded as it was misleading. It has nothing to do with style=file option and it does not influence sourced style filename.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hi, @krasimir @sylvestre.ledru , would you be able to help me with this patch? I am looking for anyone interested in reviewing this :)
I think fundamentally this seems like a reasonable idea, for those that don't need they don't need to use it.
clang/docs/ClangFormat.rst | ||
---|---|---|
32–33 | I agree this seems wrong, it's making it sound like -assume-filename is a file that will replace .clang-format .. I don't think thats true as you correctly point out | |
clang/lib/Format/Format.cpp | ||
480 | I think we are missing a change to the operator== in Format.h (I notice IncludeIsMainRegex is missing from there too) | |
clang/lib/Tooling/Inclusions/HeaderIncludes.cpp | ||
183 | whats the default value of IncludeIsMainSourceRegex?, are we making a regex even when its empty? could we not or the regex after if its defined IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") || FileName.endswith(".cpp") || FileName.endswith(".c++") || FileName.endswith(".cxx") || FileName.endswith(".m") || FileName.endswith(".mm"); if (!Style.IncludeIsMainSourceRegex.empty()){ llvm::Regex MainFileRegex(Style.IncludeIsMainSourceRegex); IsMainFile |= MainFileRegex.match(FileName); } | |
clang/tools/clang-format/ClangFormat.cpp | ||
80 | This may be a little out of date and needs rebasing as I believe this reformat has already been done, but your new wording is correct |
Hi @MyDeveloperDay, I changed the code following your advice.
Thanks for cathing the operator==(), I was not sure if this omission was intentional or not - fixed both comparisons.
Thanks for the patch,
This LGTM, just a small nit for the future, can you ensure the diff is a full context diff with something like @git diff --cached -U999999 > patch.diff (I wanted to check you got the recent changes by @sylvestre.ledru in docs/ClangFormat.rst) but I couldn't scroll that far down, so you'll need to be sure you've rebased if you haven't done so already.
@MyDeveloperDay Thanks for the review!
I did rebase it a few hours ago. I actually made sure to use the full-context diff (with -U999999 option) - I even have this as a last command in my command history, and the patch file on my disk is full-context. So either I still missed something, or the tool is playing with us ;)
BTW, I don't have rights to commit to master / merge the pull request. Can you do this for me?
I agree this seems wrong, it's making it sound like -assume-filename is a file that will replace .clang-format .. I don't think thats true as you correctly point out