QCORASTConsumer.cpp 1.18 KB
Newer Older
1
#include "QCORASTConsumer.hpp"
2
#include "LambdaVisitor.hpp"
3
4
5
6
7
8
#include <chrono>

// #include "clang/ASTMatchers/ASTMatchFinder.h"
// #include "clang/ASTMatchers/ASTMatchers.h"

// using namespace clang::ast_matchers;
9
10
11
12
13

using namespace clang;

namespace qcor {
namespace compiler {
14
QCORASTConsumer::QCORASTConsumer(CompilerInstance &c, Rewriter &rw)
15
    : ci(c), fuzzyParser(std::make_shared<FuzzyParsingExternalSemaSource>(
16
17
                 c.getASTContext())),
      rewriter(rw) {}
18
19

bool QCORASTConsumer::HandleTopLevelDecl(DeclGroupRef DR) {
20

21
22
  using namespace std::chrono;
  auto start = std::chrono::high_resolution_clock::now();
23
  LambdaVisitor visitor(ci, rewriter);
24
  for (DeclGroupRef::iterator b = DR.begin(), e = DR.end(); b != e; ++b) {
25
26
27
28
29
    // if (std::string((*b)->getDeclKindName()) == "Function") {
    //   std::cout << (*b)->getDeclKindName() << "\n";
    //   (*b)->dumpColor();
      visitor.TraverseDecl(*b);
    // }
30
  }
31
32
  auto stop = std::chrono::high_resolution_clock::now();
  auto duration = std::chrono::duration_cast<microseconds>(stop - start);
33

34
//   std::cout << "Visitor time: " << duration.count() << ", " << std::endl;
35
36
37
38
  return true;
}
} // namespace compiler
} // namespace qcor