[PATCH] D76120: Refactor SourceLocationTest to `using namespace`
Marcel Hlopko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 13 02:58:45 PDT 2020
hlopko updated this revision to Diff 250158.
hlopko added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76120/new/
https://reviews.llvm.org/D76120
Files:
clang/unittests/AST/DeclTest.cpp
Index: clang/unittests/AST/DeclTest.cpp
===================================================================
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -13,6 +13,7 @@
#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/Basic/TargetInfo.h"
#include "clang/Tooling/Tooling.h"
@@ -77,14 +78,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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76120.250158.patch
Type: text/x-patch
Size: 1177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200313/1922db00/attachment-0001.bin>
More information about the cfe-commits
mailing list