aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM!
================
Comment at:
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:364-365
+ StringRef S2) {
+ StringRef S1Prefix = S1.take_front(S1.size() - N),
+ S2Prefix = S2.take_front(S2.size() - N);
+ return S1Prefix == S2Prefix && !S1Prefix.empty();
----------------
whisperity wrote:
> aaron.ballman wrote:
> > Should we be checking that `.size() - N` doesn't cause wraparound?
> Wraparound as in underflow? Like `2 - 8` becoming multiple millions? The
> incoming strings are padded to the common length.
>
> `take_xxx` won't let you go out of bounds, even if the parameter is greater
> than the string's length. It will just silently return the entire string.
> Wraparound as in underflow? Like 2 - 8 becoming multiple millions? The
> incoming strings are padded to the common length.
They are, but I didn't see anything checking that `Threshhold` (which gets
passed as `N`) isn't larger than the common string length.
> take_xxx won't let you go out of bounds, even if the parameter is greater
> than the string's length. It will just silently return the entire string.
Aha, that's the important bit, thanks for verifying that this is safe!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97297/new/
https://reviews.llvm.org/D97297
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits