systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
FindMemberFieldMatcher.h
Go to the documentation of this file.
1#ifndef _FIND_MEMBER_FIELD_MATCHER_H_
2#define _FIND_MEMBER_FIELD_MATCHER_H_
3
4#include <vector>
5
6#include "clang/ASTMatchers/ASTMatchFinder.h"
7#include "clang/ASTMatchers/ASTMatchers.h"
8#include "clang/ASTMatchers/ASTMatchersInternal.h"
9#include "clang/ASTMatchers/ASTMatchersMacros.h"
10
11using namespace clang::ast_matchers;
12using namespace clang;
13
14namespace clang {
15class Type;
16}
17
18namespace sc_ast_matchers {
19
20class FindMemberFieldMatcher : public MatchFinder::MatchCallback {
21 private:
22 std::vector<clang::FieldDecl *> found_fields_;
23
24 public:
25 const std::vector<clang::FieldDecl *> &getFieldDecls() {
26 return found_fields_;
27 }
28
29 void registerMatchers(MatchFinder &finder) {
30 auto member_fields_match =
31 recordDecl(forEach(fieldDecl().bind("field_decl")));
32
33 finder.addMatcher(member_fields_match, this);
34 }
35
36 virtual void run(const MatchFinder::MatchResult &result) {
37 auto fd = const_cast<FieldDecl *>(
38 result.Nodes.getNodeAs<FieldDecl>("field_decl"));
39
40 found_fields_.push_back(fd);
41 }
42
43 void dump() {
44 for (auto const &field : found_fields_) {
45 field->dump();
46 }
47 }
48};
49
50}; // namespace sc_ast_matchers
51
52#endif
const std::vector< clang::FieldDecl * > & getFieldDecls()
std::vector< clang::FieldDecl * > found_fields_
virtual void run(const MatchFinder::MatchResult &result)
Clang forward declarations.
Definition FindArgument.h:6