This is an archive of the discontinued LLVM Phabricator instance.

NFC: [clang] Template argument cleanups.
ClosedPublic

Authored by mizvekov on Oct 24 2022, 7:38 AM.

Details

Reviewers
shafik
davrec
erichkeane
Group Reviewers
Restricted Project
Commits
rG1acffe81ee91: NFC: [clang] Template argument cleanups.
Summary

Removes a bunch of obsolete methods in favor of a single one returning
an ArrayRef of TemplateArgument.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Diff Detail

Event Timeline

mizvekov created this revision.Oct 24 2022, 7:38 AM
mizvekov requested review of this revision.Oct 24 2022, 7:38 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 24 2022, 7:38 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
mizvekov added reviewers: Restricted Project, davrec.Oct 24 2022, 9:43 AM

I like this cleanup in general, just 2 questions.

clang/include/clang/AST/TemplateBase.h
592

Ooh, really? Are the use cases ones where others are modifying this arguments list in place? All the functions you removed seem to be 'const'.

clang/include/clang/AST/Type.h
5298

What is happening here?

mizvekov added inline comments.Oct 24 2022, 12:23 PM
clang/include/clang/AST/TemplateBase.h
592

I think there used to be something that was removed since I made these changes. Oh well, I will just remove it then.

clang/include/clang/AST/Type.h
5298

There are implementation limitations here that don't allow us to use ArrayRef very well when it's element type is only forward declared, such as in this header.

erichkeane accepted this revision.Oct 24 2022, 12:25 PM

LGTM once that one overload is removed (the non const one). I'd rather we justify at that point WHY we need that overload in a separate review.

clang/include/clang/AST/Type.h
5298

Ah! That explains it, thanks!

This revision is now accepted and ready to land.Oct 24 2022, 12:25 PM
mizvekov updated this revision to Diff 470266.Oct 24 2022, 12:47 PM
mizvekov updated this revision to Diff 470278.Oct 24 2022, 1:37 PM
mizvekov updated this revision to Diff 470289.Oct 24 2022, 2:17 PM
This revision was landed with ongoing or failed builds.Oct 24 2022, 3:31 PM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Oct 25 2022, 5:39 AM
thakis added inline comments.
clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
101

This is overall a nice change, but here (and a few other places), the RHS looks strictly uglier to me. Maybe it makes sense to keep the getNumArgs() / getArg() functions (and make them call template_arguments() internally), for the cases where the code doesn't iterate over everything?

martong removed a subscriber: martong.Oct 25 2022, 7:45 AM
mizvekov added inline comments.Oct 25 2022, 10:18 AM
clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
101

I think in those cases, it would just look better to assign the template_arguments to an Args variable or so.

I will propose another patch to improve those cases, and CC you on it.

Otherwise if that doesn't work out, we can try something else.