v8toolkit  0.0.1
Utility library for embedding V8 Javascript engine in a c++ program
ast_action.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <regex>
4 
5 #include "clang.h"
6 #include "wrapped_class.h"
7 
8 #include "ast_consumer.h"
9 
10 // This is the class that is registered with LLVM. PluginASTAction is-a ASTFrontEndAction
12 public:
13 
14  // open up output files
16 
17  }
18 
19  // This is called when all parsing is done
20  void EndSourceFileAction();
21 
22 
23 protected:
24  // The value returned here is used internally to run checks against
25  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
26  llvm::StringRef) {
27  return llvm::make_unique<MyASTConsumer>(CI);
28  }
29 
30  bool ParseArgs(const CompilerInstance &CI,
31  const std::vector<std::string> &args) {
32  for (unsigned i = 0, e = args.size(); i < e; ++i) {
33  llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
34 
35  std::regex declaration_count_regex("^--declaration-count=(\\d+)$");
36  std::smatch match_results;
37  if (std::regex_match(args[i], match_results, declaration_count_regex)) {
38  auto count = std::stoi(match_results[1].str());
40  }
41  }
42  if (args.size() && args[0] == "help")
43  PrintHelp(llvm::errs());
44 
45  return true;
46  }
47  void PrintHelp(llvm::raw_ostream &ros) {
48  ros << "Help for PrintFunctionNames plugin goes here\n";
49  }
50 
51 };
int MAX_DECLARATIONS_PER_FILE
std::unique_ptr< ASTConsumer > CreateASTConsumer(CompilerInstance &CI, llvm::StringRef)
Definition: ast_action.h:25
void PrintHelp(llvm::raw_ostream &ros)
Definition: ast_action.h:47
bool ParseArgs(const CompilerInstance &CI, const std::vector< std::string > &args)
Definition: ast_action.h:30