This is an archive of the discontinued LLVM Phabricator instance.

Fix handling of -> calls for modernize-use-emplace
ClosedPublic

Authored by BigPeet on Jan 30 2023, 3:08 PM.

Details

Summary

Fix handling of -> calls for modernize-use-emplace

Fixes #55869

Diff Detail

Event Timeline

BigPeet created this revision.Jan 30 2023, 3:08 PM
Herald added a project: Restricted Project. · View Herald Transcript
BigPeet requested review of this revision.Jan 30 2023, 3:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2023, 3:08 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
BigPeet edited the summary of this revision. (Show Details)Jan 30 2023, 3:16 PM
nicovank accepted this revision.Jan 31 2023, 12:39 PM

This is becoming repetitive, but I guess that's the nature of those things. Maybe something like this would help clean it up, not sure if any better for right now.

template <typename T> // Lambda templates would have been nice.
auto onTypeOrPointerType(const T &Type) { // onUnderlyingType ?
  return on(anyOf(hasType(Type), hasType(pointerType(pointee(Type)))));
}
This revision is now accepted and ready to land.Jan 31 2023, 12:39 PM
BigPeet updated this revision to Diff 493745.EditedJan 31 2023, 3:08 PM
  • reducing code repetition + further tests
BigPeet updated this revision to Diff 493753.Jan 31 2023, 3:30 PM
  • additional deduplication of code

Refactored the code a little bit to get rid of some repetitions. Should effectively match the same code as the accepted revision.

BigPeet updated this revision to Diff 493756.Jan 31 2023, 3:42 PM
  • fix passing vector by value instead of by ref-to-const
nicovank added inline comments.Jan 31 2023, 3:45 PM
clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
100
const std::vector<StringRef> &ContainerNames

Nevermind, this was fixed as I was looking at it. LGTM.

BigPeet marked an inline comment as done.Jan 31 2023, 3:48 PM
njames93 accepted this revision.Feb 1 2023, 9:47 AM

LGTM

clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
93

Generally we use prefer llvm::ArrayRef over const std::vector &

Generally we use prefer llvm::ArrayRef over const std::vector &

I will keep this in mind. Or should this be fixed in this revision?

Anyway, if this gets merged, my username/mail are

GitHub username: BigPeet
GitHub email: pwolf2310@gmail.com

Thanks for the fast review response!

clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
93

Generally we use prefer llvm::ArrayRef over const std::vector &

This revision was automatically updated to reflect the committed changes.

Pushed, thanks for the contribution! I took the liberty of fixing the std::vector thing before pushing :)

Thank you very much.