[clang] 32dede6 - [AST] Fix QualTypeNamesTest, which was spuriously passing

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 15 12:55:31 PST 2021


Author: Sam McCall
Date: 2021-12-15T21:55:25+01:00
New Revision: 32dede65ae98703855d90b55d0b4ec0ebf88a385

URL: https://github.com/llvm/llvm-project/commit/32dede65ae98703855d90b55d0b4ec0ebf88a385
DIFF: https://github.com/llvm/llvm-project/commit/32dede65ae98703855d90b55d0b4ec0ebf88a385.diff

LOG: [AST] Fix QualTypeNamesTest, which was spuriously passing

The empty VisitDecl() meant all assertions were skipped.
Meanwhile the assertions have rotted as some type printing has changed.

The test is still in the wrong directory, because it requires TestVisitor.h
which uses Tooling APIs.

Added: 
    

Modified: 
    clang/unittests/Tooling/QualTypeNamesTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp
index 8272edb28c21..4ae6861751b8 100644
--- a/clang/unittests/Tooling/QualTypeNamesTest.cpp
+++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp
@@ -15,12 +15,7 @@ struct TypeNameVisitor : TestVisitor<TypeNameVisitor> {
   llvm::StringMap<std::string> ExpectedQualTypeNames;
   bool WithGlobalNsPrefix = false;
 
-  // ValueDecls are the least-derived decl with both a qualtype and a
-  // name.
-  bool TraverseDecl(Decl *D) {
-    return true;  // Always continue
-  }
-
+  // ValueDecls are the least-derived decl with both a qualtype and a name.
   bool VisitValueDecl(const ValueDecl *VD) {
     std::string ExpectedName =
         ExpectedQualTypeNames.lookup(VD->getNameAsString());
@@ -35,10 +30,10 @@ struct TypeNameVisitor : TestVisitor<TypeNameVisitor> {
       if (ExpectedName != ActualName) {
         // A custom message makes it much easier to see what declaration
         // failed compared to EXPECT_EQ.
-        EXPECT_TRUE(false) << "Typename::getFullyQualifiedName failed for "
-                           << VD->getQualifiedNameAsString() << std::endl
-                           << "   Actual: " << ActualName << std::endl
-                           << " Exepcted: " << ExpectedName;
+        ADD_FAILURE() << "Typename::getFullyQualifiedName failed for "
+                      << VD->getQualifiedNameAsString() << std::endl
+                      << "   Actual: " << ActualName << std::endl
+                      << " Exepcted: " << ExpectedName;
       }
     }
     return true;
@@ -69,7 +64,7 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
   // Recursive template parameter expansion.
   Visitor.ExpectedQualTypeNames["CheckD"] =
       "A::B::Template0<A::B::Template1<A::B::C::MyInt, A::B::AnotherClass>, "
-      "A::B::Template0<int, long> >";
+      "A::B::Template0<int, long>>";
   // Variadic Template expansion.
   Visitor.ExpectedQualTypeNames["CheckE"] =
       "A::Variadic<int, A::B::Template0<int, char>, "
@@ -239,14 +234,14 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
   TypeNameVisitor AnonStrucs;
   AnonStrucs.ExpectedQualTypeNames["a"] = "short";
   AnonStrucs.ExpectedQualTypeNames["un_in_st_1"] =
-      "union (anonymous struct at input.cc:1:1)::(anonymous union at "
+      "union (unnamed struct at input.cc:1:1)::(unnamed union at "
       "input.cc:2:27)";
   AnonStrucs.ExpectedQualTypeNames["b"] = "short";
   AnonStrucs.ExpectedQualTypeNames["un_in_st_2"] =
-      "union (anonymous struct at input.cc:1:1)::(anonymous union at "
+      "union (unnamed struct at input.cc:1:1)::(unnamed union at "
       "input.cc:5:27)";
   AnonStrucs.ExpectedQualTypeNames["anon_st"] =
-      "struct (anonymous struct at input.cc:1:1)";
+      "struct (unnamed struct at input.cc:1:1)";
   AnonStrucs.runOver(R"(struct {
                           union {
                             short a;


        


More information about the cfe-commits mailing list