commit f0db8270dd0305ecaf64e2f94fa0010188b898fa
parent 48fe7372e4349ebe590e4ce9a428bf5baf3a114d
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Fri, 25 Mar 2016 12:09:29 -0600
instrument: denamespace instrument action
Diffstat:
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/instrument/instrument_action.cc b/instrument/instrument_action.cc
@@ -15,11 +15,11 @@
#include "runtime_h.h"
-ASTConsumer *
-InstrumentAction::CreateASTConsumer(CompilerInstance &CI, StringRef file)
+clang::ASTConsumer *
+InstrumentAction::CreateASTConsumer(clang::CompilerInstance &CI, StringRef file)
{
// llvm::errs() << "** Creating AST consumer for: " << file << "\n";
- SourceManager &sm = CI.getSourceManager();
+ clang::SourceManager &sm = CI.getSourceManager();
TheRewriter.setSourceMgr(sm, CI.getLangOpts());
return new MyASTConsumer(TheRewriter);
@@ -71,15 +71,14 @@ write_src_number(int src_num)
void
InstrumentAction::EndSourceFileAction()
{
- SourceManager &sm = TheRewriter.getSourceMgr();
- const FileID main_fid = sm.getMainFileID();
+ clang::SourceManager &sm = TheRewriter.getSourceMgr();
+ const clang::FileID main_fid = sm.getMainFileID();
// llvm::errs() << "** EndSourceFileAction for: "
// << sm.getFileEntryForID(main_fid)->getName()
// << "\n";
- SourceLocation start = sm.getLocForStartOfFile(main_fid);
-
- SourceLocation end = sm.getLocForEndOfFile(main_fid);
+ clang::SourceLocation start = sm.getLocForStartOfFile(main_fid);
+ clang::SourceLocation end = sm.getLocForEndOfFile(main_fid);
unsigned int num_lines = sm.getPresumedLineNumber(end);
std::string file_name = getCurrentFile();
diff --git a/instrument/instrument_action.h b/instrument/instrument_action.h
@@ -4,34 +4,32 @@
#include "rewrite_ast_visitor.h"
-using namespace clang;
-
// For each source file provided to the tool, a new FrontendAction is created.
-class InstrumentAction : public ASTFrontendAction {
+class InstrumentAction : public clang::ASTFrontendAction {
public:
InstrumentAction() {};
void EndSourceFileAction() override;
- ASTConsumer *CreateASTConsumer(CompilerInstance &, StringRef) override;
+ clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance &, StringRef) override;
private:
- Rewriter TheRewriter;
+ clang::Rewriter TheRewriter;
};
// Implementation of the ASTConsumer interface for reading an AST produced
// by the Clang parser.
-class MyASTConsumer : public ASTConsumer {
+class MyASTConsumer : public clang::ASTConsumer {
public:
- MyASTConsumer(Rewriter &R) : Visitor(R) {}
+ MyASTConsumer(clang::Rewriter &R) : Visitor(R) {}
// Override the method that gets called for each parsed top-level
// declaration.
- bool HandleTopLevelDecl(DeclGroupRef DR) override {
- for (DeclGroupRef::iterator b = DR.begin(), e = DR.end(); b != e; ++b) {
+ bool HandleTopLevelDecl(clang::DeclGroupRef DR) override {
+ for (auto &b : DR) {
// Traverse the declaration using our AST visitor.
- Visitor.TraverseDecl(*b);
- // (*b)->dump();
+ Visitor.TraverseDecl(b);
+ // b->dump();
}
return true;
}