This is an archive of the discontinued LLVM Phabricator instance.

[Sema] haveSameParameterTypes - replace repeated isNull() test with assertions
ClosedPublic

Authored by RKSimon on Aug 3 2021, 6:30 AM.

Details

Summary

As reported on https://pvs-studio.com/en/blog/posts/cpp/0771/ (Snippet 2) - (and mentioned on rGdc4259d5a38409) we are repeating the T1.isNull() check instead of checking T2.isNull() as well.

Diff Detail

Event Timeline

RKSimon requested review of this revision.Aug 3 2021, 6:30 AM
RKSimon created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2021, 6:30 AM
RKSimon added inline comments.Aug 5 2021, 2:50 AM
clang/lib/Sema/SemaOverload.cpp
9589–9590

@rsmith Can these isNull checks ever fail? Or would we be better off changing them into an assert?

QualType T1 = NextParam(F1, I1, I == 0);
QualType T2 = NextParam(F2, I2, I == 0);
assert(!T1.isNull() && !T2.isNull() && "Unknown types");
if (!Context.hasSameUnqualifiedType(T1, T2))

ping - any comments?

xbolva00 accepted this revision.Oct 17 2021, 9:26 AM
xbolva00 added a subscriber: xbolva00.

LG. Could be changed to the assert in the future….

This revision is now accepted and ready to land.Oct 17 2021, 9:26 AM
urnathan added inline comments.Oct 18 2021, 3:34 AM
clang/lib/Sema/SemaOverload.cpp
9589–9590

that it's never ICED without checking T2's nullness suggests to me that they're never null. A null type here would seem to be from bad parsing, in which case why are we even checking further? IMHO assert now, there's plenty of time before C14 to revert that.

RKSimon added inline comments.Oct 18 2021, 4:12 AM
clang/lib/Sema/SemaOverload.cpp
9589–9590

OK - I'll change this to an assertion

RKSimon updated this revision to Diff 380338.Oct 18 2021, 4:15 AM
RKSimon retitled this revision from [Sema] haveSameParameterTypes - fix repeated isNull() test to [Sema] haveSameParameterTypes - replace repeated isNull() test with assertions.
RKSimon edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Oct 18 2021, 4:37 AM
This revision was automatically updated to reflect the committed changes.

FYI, it seems like a branch containing this patch was accidentally pushed to GitHub: https://github.com/llvm/llvm-project/tree/5357a98c823a