Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Format/Format.cpp | ||
---|---|---|
2774 | Did I miss where this comes from now? |
I didn't see much difference in what this patch does compare to mine but I saw that it removes the need for instantiating multiple llvm::Regex objects from a single static pattern. But that's something I've just done in a new revision of my own patch: https://reviews.llvm.org/D134733?vs=463205&id=463786#toc . This fast clean up makes it only harder for me to get my patch in but essentially both do the same thing except that I also have a single convenience function for trimming include names from " and <>". Also I have removed the need to duplicate the knowledge of which matching group one has to pick in order to get to the include name. This knowledge is now local to a function.
clang/lib/Format/Format.cpp | ||
---|---|---|
2774 | @MyDeveloperDay clang/lib/Tooling/Inclusions/HeaderIncludes.cpp still has this: const char IncludeRegexPattern[] = R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; And in clang/lib/Tooling/Inclusions/HeaderIncludes.cpp @owenpan uses it to initialize the final regex const llvm::Regex HeaderIncludes::IncludeRegex(IncludeRegexPattern); The fact that we have two regex that are identical is an issue on its own that I tried to address with my patch as well. I didn't initialize the regex like @owenpan does here but I had a function to return it. Eventually a function makes it easier to apply the injection from a config file as you've suggested here. So I favor my solution. |
@kwk D134733 reminded me of https://reviews.llvm.org/D121370#3401173, which I realized didn't go far enough. This NFC patch is what I should have suggested to you then. If you want to do the cleanup differently, you can either make suggestions here or create another NFC patch.
clang/lib/Format/Format.cpp | ||
---|---|---|
2774 |
It should be addressed in a separate NFC patch such as this one.
Making IncludeRegex a public static const member is one of the better solutions when IncludeRegexPattern is fixed as it has been. If and when we decide to support user specified patterns, we will make any necessary changes then. |
clang/lib/Format/Format.cpp | ||
---|---|---|
2774 |
Ehm, I thought I *did* create a separate NFC patch with D134733. I prefixed it with [chore] but that is as good as NFC. I can rename it if you want.
Okay, but you could have suggested that in D134733, no? I've made the change in D134733 here: https://reviews.llvm.org/D134733?vs=463205&id=464196#toc, so the regex is static const. But I've also outsourced the function for accessing the include name so the logic is at one place not scattered over and over and the trimming is also in its own function. Having everything going through that functions is easier for maintenance IMHO. Before I wondered why we had two include regex patterns (both the same btw.) and why an include name wasn't found when I had changed the Matches[2] to Matches[3] for example. That won't happen when its going through the function. You just change it in one place and not "plenty". I hope we can agree that my change is now complete with additions from yours here. I most certainly don't want to disrupt your workflow and I apologize if I had. Unfortunately text can be misinterpreted way too much. |
clang/lib/Format/Format.cpp | ||
---|---|---|
2774 |
I didn't know by chore you meant NFC. Thanks for renaming it.
It would be too many places to point out as you can tell from this patch. When mixed with other unrelated changes in D134733, it would be more difficult for me to review and other people to follow. Making this patch allows me to focus on the best way to solve the problem without worrying about any additional "noise".
It seems that you have applied this patch in its entirety to D134733. Why not just wait for it to land and rebase D134733 afterward?
Not at all. If anything, it's probably I who have disrupted your workflow. :) |
clang/lib/Format/Format.cpp | ||
---|---|---|
2774 |
Your welcome.
I get that but I thought that my NFC patch was doing exactly that:
I feel that I introduced this cleanup myself by having only one regex and not two. The only difference from mine to your patch was that you used a static member and I made a function call and didn't avoid the instantiations of regex objects.
This seems just weird afterall. So why don't you land your patch and I submit mine? |
Did I miss where this comes from now?