[NFC][Clang][ASTTests] Use ASSERT instead of EXPECT for nullptr checks
authorMichael Spencer <bigcheesegs@gmail.com>
Thu, 5 Jan 2023 01:32:12 +0000 (17:32 -0800)
committerMichael Spencer <bigcheesegs@gmail.com>
Thu, 5 Jan 2023 01:33:12 +0000 (17:33 -0800)
This avoids basically guaranteed crashes when the check fails.

clang/unittests/AST/DeclTest.cpp

index 6d525dc..940ff17 100644 (file)
@@ -404,7 +404,7 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                          hasParameter(0, hasType(isUnsignedInteger())))
                 .bind("operator new"),
             Ctx));
-  EXPECT_TRUE(SizedOperatorNew->getOwningModule());
+  ASSERT_TRUE(SizedOperatorNew->getOwningModule());
   EXPECT_TRUE(SizedOperatorNew->getOwningModule()->isGlobalModule());
 
   // void* operator new(std::size_t, std::align_val_t);
@@ -416,7 +416,7 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                 hasParameter(1, hasType(enumDecl(hasName("std::align_val_t")))))
                 .bind("operator new"),
             Ctx));
-  EXPECT_TRUE(SizedAlignedOperatorNew->getOwningModule());
+  ASSERT_TRUE(SizedAlignedOperatorNew->getOwningModule());
   EXPECT_TRUE(SizedAlignedOperatorNew->getOwningModule()->isGlobalModule());
 
   // void* operator new[](std::size_t);
@@ -426,7 +426,7 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                          hasParameter(0, hasType(isUnsignedInteger())))
                 .bind("operator new[]"),
             Ctx));
-  EXPECT_TRUE(SizedArrayOperatorNew->getOwningModule());
+  ASSERT_TRUE(SizedArrayOperatorNew->getOwningModule());
   EXPECT_TRUE(SizedArrayOperatorNew->getOwningModule()->isGlobalModule());
 
   // void* operator new[](std::size_t, std::align_val_t);
@@ -438,7 +438,7 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                 hasParameter(1, hasType(enumDecl(hasName("std::align_val_t")))))
                 .bind("operator new[]"),
             Ctx));
-  EXPECT_TRUE(SizedAlignedArrayOperatorNew->getOwningModule());
+  ASSERT_TRUE(SizedAlignedArrayOperatorNew->getOwningModule());
   EXPECT_TRUE(
       SizedAlignedArrayOperatorNew->getOwningModule()->isGlobalModule());
 
@@ -450,7 +450,7 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                 hasParameter(0, hasType(pointerType(pointee(voidType())))))
                 .bind("operator delete"),
             Ctx));
-  EXPECT_TRUE(Delete->getOwningModule());
+  ASSERT_TRUE(Delete->getOwningModule());
   EXPECT_TRUE(Delete->getOwningModule()->isGlobalModule());
 
   // void operator delete(void*, std::align_val_t) noexcept;
@@ -462,7 +462,7 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                 hasParameter(1, hasType(enumDecl(hasName("std::align_val_t")))))
                 .bind("operator delete"),
             Ctx));
-  EXPECT_TRUE(AlignedDelete->getOwningModule());
+  ASSERT_TRUE(AlignedDelete->getOwningModule());
   EXPECT_TRUE(AlignedDelete->getOwningModule()->isGlobalModule());
 
   // Sized deallocation is not enabled by default. So we skip it here.
@@ -475,7 +475,7 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                 hasParameter(0, hasType(pointerType(pointee(voidType())))))
                 .bind("operator delete[]"),
             Ctx));
-  EXPECT_TRUE(ArrayDelete->getOwningModule());
+  ASSERT_TRUE(ArrayDelete->getOwningModule());
   EXPECT_TRUE(ArrayDelete->getOwningModule()->isGlobalModule());
 
   // void operator delete[](void*, std::align_val_t) noexcept;
@@ -487,6 +487,6 @@ TEST(Decl, ImplicitlyDeclaredAllocationFunctionsInModules) {
                 hasParameter(1, hasType(enumDecl(hasName("std::align_val_t")))))
                 .bind("operator delete[]"),
             Ctx));
-  EXPECT_TRUE(AlignedArrayDelete->getOwningModule());
+  ASSERT_TRUE(AlignedArrayDelete->getOwningModule());
   EXPECT_TRUE(AlignedArrayDelete->getOwningModule()->isGlobalModule());
 }