Index: clang/unittests/ASTMatchers/ASTMatchersTest.h =================================================================== --- clang/unittests/ASTMatchers/ASTMatchersTest.h +++ clang/unittests/ASTMatchers/ASTMatchersTest.h @@ -372,12 +372,8 @@ ExpectedName(std::string(ExpectedName)) {} void onEndOfTranslationUnit() override { - if (ExpectedCount != -1) { - EXPECT_EQ(ExpectedCount, Count); - } - if (!ExpectedName.empty()) { - EXPECT_EQ(ExpectedName, Name); - } + EXPECT_EQ(ExpectedCount, -1); + EXPECT_TRUE(ExpectedName.empty()); Count = 0; Name.clear(); } @@ -389,25 +385,21 @@ bool run(const BoundNodes *Nodes) override { const BoundNodes::IDToNodeMap &M = Nodes->getMap(); - if (Nodes->getNodeAs(Id)) { - ++Count; - if (const NamedDecl *Named = Nodes->getNodeAs(Id)) { - Name = Named->getNameAsString(); - } else if (const NestedNameSpecifier *NNS = - Nodes->getNodeAs(Id)) { - llvm::raw_string_ostream OS(Name); - NNS->print(OS, PrintingPolicy(LangOptions())); - } - BoundNodes::IDToNodeMap::const_iterator I = M.find(Id); - EXPECT_NE(M.end(), I); - if (I != M.end()) { - EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get()); - } - return true; + EXPECT_NE(Nodes->getNodeAs(Id), nullptr); + ++Count; + if (const NamedDecl *Named = Nodes->getNodeAs(Id)) { + Name = Named->getNameAsString(); + } else if (const NestedNameSpecifier *NNS = + Nodes->getNodeAs(Id)) { + llvm::raw_string_ostream OS(Name); + NNS->print(OS, PrintingPolicy(LangOptions())); + } + BoundNodes::IDToNodeMap::const_iterator I = M.find(Id); + EXPECT_NE(M.end(), I); + if (I != M.end()) { + EXPECT_EQ(Nodes->getNodeAs(Id), I->second.get()); } - EXPECT_TRUE(M.count(Id) == 0 || - M.find(Id)->second.template get() == nullptr); - return false; + return true; } bool run(const BoundNodes *Nodes, ASTContext *Context) override {