| 22 | namespace ftg { |
| 23 | |
| 24 | std::unique_ptr<Enum> createEnum(std::string TypeName, clang::ASTContext &Ctx) { |
| 25 | std::string Tag(__FUNCTION__); |
| 26 | std::unique_ptr<clang::ast_matchers::DeclarationMatcher> Matcher; |
| 27 | if (TypeName.empty()) { |
| 28 | Matcher = std::make_unique<clang::ast_matchers::DeclarationMatcher>( |
| 29 | clang::ast_matchers::enumDecl( |
| 30 | clang::ast_matchers::unless(clang::ast_matchers::hasAnyName())) |
| 31 | .bind(Tag)); |
| 32 | } else { |
| 33 | Matcher = std::make_unique<clang::ast_matchers::DeclarationMatcher>( |
| 34 | clang::ast_matchers::enumDecl(clang::ast_matchers::hasName(TypeName)) |
| 35 | .bind(Tag)); |
| 36 | } |
| 37 | if (!Matcher) |
| 38 | return nullptr; |
| 39 | |
| 40 | for (const auto &Node : clang::ast_matchers::match(*Matcher, Ctx)) { |
| 41 | auto *Record = Node.getNodeAs<clang::EnumDecl>(Tag); |
| 42 | if (!Record) |
| 43 | continue; |
| 44 | |
| 45 | return std::make_unique<Enum>(*Record); |
| 46 | } |
| 47 | return nullptr; |
| 48 | } |
| 49 | |
| 50 | std::string getBaseDirPath() { |
| 51 | |