Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/include-cleaner/lib/Record.cpp | ||
---|---|---|
377 | as we already do a dyn_cast inside the isImplicitTemplateInstantiation, we can get rid of this NamedDecl cast by changing the isImplicitTemplateInstantiation to accept a Decl*. | |
387 | we can move it to the above anonymous namespace as well (it is fine to have two functions with same name because of C++ overloads). In this case, I'd probably inline it in HandleTopLevelDecl. | |
clang-tools-extra/include-cleaner/unittests/RecordTest.cpp | ||
105 | maybe DropImplicitTemplateTopDecl? | |
120 | this example is a nice example to show the original bug (where we inserted unexpected additional headers) in include-cleaner. The scope of this patch is to filter out the implicit template instantiation, a simple testcase like below could work. (the current testcase is fine as well, up to you) template<typename T> int func(T) { return 0; } auto s = func<int>(1); | |
123 | nit: instead doing a negative verification, I'd check the captured root decl, which is (a MyGetter CXXRecordDecl, and a v var decl), and with a comment saying the implicitly-instantiated method decl is filtered out. |
Address review comments.
clang-tools-extra/include-cleaner/lib/Record.cpp | ||
---|---|---|
377 | Oh right, I didn't notice. Thanks. | |
387 | I am not sure I fully understand this comment, since I cannot both move this method to the anonymous namespace above and inline it at the same time. I have inlined it now, hopefully it looks fine to you. | |
clang-tools-extra/include-cleaner/unittests/RecordTest.cpp | ||
105 | Not sure, since the rest of tests above only use nouns, e.g., "Macros", "Inclusion", "Namespace", etc. I've called it "ImplicitTemplates" now, hopefully it's fine. | |
120 | You're right, but IMHO I would rather keep the current example. The current example, although simplified, still highly resembles the pattern we've found it real code. The snippet above does not anymore. Since it's a bug fix for a real pattern, I'd rather keep it as is. Let me know if you disagree. | |
123 | Sure, I have no preference. |
thanks looks good!
Please remember to add a FIX: <link to github issue> to the commit message.
clang-tools-extra/include-cleaner/lib/Record.cpp | ||
---|---|---|
387 | the current code looks good. (I meant either, not both, sorry for the confusion) |
as we already do a dyn_cast inside the isImplicitTemplateInstantiation, we can get rid of this NamedDecl cast by changing the isImplicitTemplateInstantiation to accept a Decl*.