hlopko created this revision. hlopko added a reviewer: gribozavr. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This patch removes a call to the old ASTUnit::findFileRegionDecls and replaces it with ast matchers. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D76121 Files: clang/unittests/AST/DeclTest.cpp Index: clang/unittests/AST/DeclTest.cpp =================================================================== --- clang/unittests/AST/DeclTest.cpp +++ clang/unittests/AST/DeclTest.cpp @@ -13,10 +13,11 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Mangle.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Basic/LLVM.h" #include "clang/Tooling/Tooling.h" -#include "gtest/gtest.h" #include "llvm/IR/DataLayout.h" +#include "gtest/gtest.h" using namespace clang::ast_matchers; using namespace clang::tooling; @@ -76,14 +77,9 @@ assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() && "Expected target to have a global prefix"); DiagnosticsEngine &Diags = AST->getDiagnostics(); - SourceManager &SM = AST->getSourceManager(); - FileID MainFileID = SM.getMainFileID(); - // Find the method decls within the AST. - SmallVector<Decl *, 1> Decls; - AST->findFileRegionDecls(MainFileID, Code.find('{'), 0, Decls); - ASSERT_TRUE(Decls.size() == 1); - CXXRecordDecl *DeclS = cast<CXXRecordDecl>(Decls[0]); + auto *DeclS = + selectFirst<CXXRecordDecl>("d", match(cxxRecordDecl().bind("d"), Ctx)); NamedDecl *DeclF = *DeclS->method_begin(); NamedDecl *DeclG = *(++DeclS->method_begin());
Index: clang/unittests/AST/DeclTest.cpp =================================================================== --- clang/unittests/AST/DeclTest.cpp +++ clang/unittests/AST/DeclTest.cpp @@ -13,10 +13,11 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Mangle.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Basic/LLVM.h" #include "clang/Tooling/Tooling.h" -#include "gtest/gtest.h" #include "llvm/IR/DataLayout.h" +#include "gtest/gtest.h" using namespace clang::ast_matchers; using namespace clang::tooling; @@ -76,14 +77,9 @@ assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() && "Expected target to have a global prefix"); DiagnosticsEngine &Diags = AST->getDiagnostics(); - SourceManager &SM = AST->getSourceManager(); - FileID MainFileID = SM.getMainFileID(); - // Find the method decls within the AST. - SmallVector<Decl *, 1> Decls; - AST->findFileRegionDecls(MainFileID, Code.find('{'), 0, Decls); - ASSERT_TRUE(Decls.size() == 1); - CXXRecordDecl *DeclS = cast<CXXRecordDecl>(Decls[0]); + auto *DeclS = + selectFirst<CXXRecordDecl>("d", match(cxxRecordDecl().bind("d"), Ctx)); NamedDecl *DeclF = *DeclS->method_begin(); NamedDecl *DeclG = *(++DeclS->method_begin());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits