[clang] 3b3509b - [Sema] haveSameParameterTypes - replace repeated isNull() test with assertions

Simon Pilgrim via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 18 04:36:57 PDT 2021


Author: Simon Pilgrim
Date: 2021-10-18T12:36:44+01:00
New Revision: 3b3509b3cba272c98d2235a8664ae9625ac729f8

URL: https://github.com/llvm/llvm-project/commit/3b3509b3cba272c98d2235a8664ae9625ac729f8
DIFF: https://github.com/llvm/llvm-project/commit/3b3509b3cba272c98d2235a8664ae9625ac729f8.diff

LOG: [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

Added: 
    

Modified: 
    clang/lib/Sema/SemaOverload.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d93fd9df0093e..a2af2ac6f7ee8 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;


        


More information about the cfe-commits mailing list