From 3b3509b3cba272c98d2235a8664ae9625ac729f8 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 18 Oct 2021 12:36:29 +0100 Subject: [PATCH] [Sema] haveSameParameterTypes - replace repeated isNull() test with assertions 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, and at this point neither should be null - so we're better off with an assertion. Differential Revision: https://reviews.llvm.org/D107347 --- clang/lib/Sema/SemaOverload.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index d93fd9df0093..a2af2ac6f7ee 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -9586,7 +9586,8 @@ static bool haveSameParameterTypes(ASTContext &Context, const FunctionDecl *F1, for (unsigned I = 0; I != NumParams; ++I) { QualType T1 = NextParam(F1, I1, I == 0); QualType T2 = NextParam(F2, I2, I == 0); - if (!T1.isNull() && !T1.isNull() && !Context.hasSameUnqualifiedType(T1, T2)) + assert(!T1.isNull() && !T2.isNull() && "Unexpected null param types"); + if (!Context.hasSameUnqualifiedType(T1, T2)) return false; } return true;