blob: 799ec92f016fd27f691a3a341a441d0c39860cbf [file] [log] [blame]
Douglas Gregorf78cc432010-05-07 15:41:56 +00001//===-- BoostConAction.cpp - BoostCon Workshop Action -----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#include "clang/Frontend/FrontendActions.h"
10#include "clang/AST/ASTConsumer.h"
Douglas Gregord30bf2e2010-05-07 22:11:34 +000011#include "clang/AST/RecursiveASTVisitor.h"
Douglas Gregorffb507a2010-05-07 15:59:09 +000012#include <cstdio>
Douglas Gregorb4eeaff2010-05-07 23:12:07 +000013#include <iostream>
Douglas Gregorf78cc432010-05-07 15:41:56 +000014using namespace clang;
15
16namespace {
Chandler Carruthdfc35e32010-06-09 08:17:30 +000017 class BoostConASTConsumer : public ASTConsumer,
Douglas Gregord30bf2e2010-05-07 22:11:34 +000018 public RecursiveASTVisitor<BoostConASTConsumer> {
Douglas Gregorf78cc432010-05-07 15:41:56 +000019 public:
20 /// HandleTranslationUnit - This method is called when the ASTs for entire
21 /// translation unit have been parsed.
22 virtual void HandleTranslationUnit(ASTContext &Ctx);
Chandler Carruthdfc35e32010-06-09 08:17:30 +000023
Douglas Gregorb4eeaff2010-05-07 23:12:07 +000024 bool VisitCXXRecordDecl(CXXRecordDecl *D) {
25 std::cout << D->getNameAsString() << std::endl;
26 return false;
Chandler Carruthdfc35e32010-06-09 08:17:30 +000027 }
Douglas Gregorf78cc432010-05-07 15:41:56 +000028 };
29}
30
31ASTConsumer *BoostConAction::CreateASTConsumer(CompilerInstance &CI,
32 llvm::StringRef InFile) {
33 return new BoostConASTConsumer();
34}
35
36void BoostConASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
37 fprintf(stderr, "Welcome to BoostCon!\n");
Chandler Carruthdfc35e32010-06-09 08:17:30 +000038 TraverseDecl(Ctx.getTranslationUnitDecl());
Douglas Gregorf78cc432010-05-07 15:41:56 +000039}