diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-10-18 12:36:29 +0100 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-10-18 12:36:44 +0100 |
commit | 3b3509b3cba272c98d2235a8664ae9625ac729f8 (patch) | |
tree | 3aff64f50c1ebab8ce2d017f3d73b8697b0c31eb | |
parent | b9ca73e1a8fd0c018b0b3eb313163da2b4ca4e09 (diff) | |
download | llvm-5357a98c823a.tar.gz |
[Sema] haveSameParameterTypes - replace repeated isNull() test with assertions5357a98c823a
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
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
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; |