2010-05-07 23:41:56 +08:00
|
|
|
//===-- BoostConAction.cpp - BoostCon Workshop Action -----------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Frontend/FrontendActions.h"
|
|
|
|
#include "clang/AST/ASTConsumer.h"
|
2010-05-08 06:11:34 +08:00
|
|
|
#include "clang/AST/RecursiveASTVisitor.h"
|
2010-05-07 23:59:09 +08:00
|
|
|
#include <cstdio>
|
2010-05-08 07:12:07 +08:00
|
|
|
#include <iostream>
|
2010-05-07 23:41:56 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
|
|
|
namespace {
|
2010-06-09 16:17:30 +08:00
|
|
|
class BoostConASTConsumer : public ASTConsumer,
|
2010-05-08 06:11:34 +08:00
|
|
|
public RecursiveASTVisitor<BoostConASTConsumer> {
|
2010-05-07 23:41:56 +08:00
|
|
|
public:
|
|
|
|
/// HandleTranslationUnit - This method is called when the ASTs for entire
|
|
|
|
/// translation unit have been parsed.
|
|
|
|
virtual void HandleTranslationUnit(ASTContext &Ctx);
|
2010-06-09 16:17:30 +08:00
|
|
|
|
2010-05-08 07:12:07 +08:00
|
|
|
bool VisitCXXRecordDecl(CXXRecordDecl *D) {
|
|
|
|
std::cout << D->getNameAsString() << std::endl;
|
2010-06-10 18:31:57 +08:00
|
|
|
return true;
|
2010-06-09 16:17:30 +08:00
|
|
|
}
|
2010-05-07 23:41:56 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
ASTConsumer *BoostConAction::CreateASTConsumer(CompilerInstance &CI,
|
|
|
|
llvm::StringRef InFile) {
|
|
|
|
return new BoostConASTConsumer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoostConASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
|
|
|
|
fprintf(stderr, "Welcome to BoostCon!\n");
|
2010-06-09 16:17:30 +08:00
|
|
|
TraverseDecl(Ctx.getTranslationUnitDecl());
|
2010-05-07 23:41:56 +08:00
|
|
|
}
|