commit 1d5957cf764a556fb1cd02e090a7af85ffc663c5
parent fdc0e7a42daee7ea7063916e296be015a8808420
Author: Kyle Milz <kyle@0x30.net>
Date: Thu, 12 Jan 2017 23:04:18 -0700
inst: move RewriteASTConsumer to more related header
Diffstat:
2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/inst_action.h b/inst_action.h
@@ -1,32 +1,11 @@
#include "inst_visitor.h"
#include "inst_log.h"
-#include <clang/AST/ASTConsumer.h>
#include <clang/Frontend/FrontendActions.h>
#include <clang/Rewrite/Core/Rewriter.h>
#include <clang/Tooling/Tooling.h>
-class RewriteASTConsumer : public clang::ASTConsumer {
-public:
- explicit RewriteASTConsumer(clang::Rewriter &R) : Visitor(R) {}
-
- // Override the method that gets called for each parsed top-level
- // declaration.
- virtual bool HandleTopLevelDecl(clang::DeclGroupRef DR) {
- for (auto &b : DR) {
- // Traverse the declaration using our AST visitor.
- Visitor.TraverseDecl(b);
- // b->dump();
- }
- return true;
- }
-
- RewriteASTVisitor& get_visitor() { return Visitor; };
-private:
- RewriteASTVisitor Visitor;
-};
-
// For each source file provided to the tool, a new FrontendAction is created.
class InstrumentAction : public clang::ASTFrontendAction {
public:
diff --git a/inst_visitor.h b/inst_visitor.h
@@ -1,4 +1,5 @@
#include <array>
+#include <clang/AST/ASTConsumer.h>
#include <clang/AST/RecursiveASTVisitor.h>
#include <clang/Rewrite/Core/Rewriter.h>
@@ -66,3 +67,24 @@ private:
clang::SourceManager &m_SM;
clang::LangOptions m_lopt;
};
+
+class RewriteASTConsumer : public clang::ASTConsumer
+{
+public:
+ explicit RewriteASTConsumer(clang::Rewriter &R) : Visitor(R) {}
+
+ // Override the method that gets called for each parsed top-level
+ // declaration.
+ virtual bool HandleTopLevelDecl(clang::DeclGroupRef DR) {
+ for (auto &b : DR) {
+ // Traverse the declaration using our AST visitor.
+ Visitor.TraverseDecl(b);
+ // b->dump();
+ }
+ return true;
+ }
+
+ RewriteASTVisitor& get_visitor() { return Visitor; };
+private:
+ RewriteASTVisitor Visitor;
+};