mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-18 08:26:07 +00:00

new design discussed on cfe-dev, with further steps in that direction to come. It is already much more complete than the previous visitor. Patch by Zhanyong and Craig with 80 column wraps and one missing declaration added by me. llvm-svn: 105709
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
//===-- 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"
|
|
#include "clang/AST/RecursiveASTVisitor.h"
|
|
#include <cstdio>
|
|
#include <iostream>
|
|
using namespace clang;
|
|
|
|
namespace {
|
|
class BoostConASTConsumer : public ASTConsumer,
|
|
public RecursiveASTVisitor<BoostConASTConsumer> {
|
|
public:
|
|
/// HandleTranslationUnit - This method is called when the ASTs for entire
|
|
/// translation unit have been parsed.
|
|
virtual void HandleTranslationUnit(ASTContext &Ctx);
|
|
|
|
bool VisitCXXRecordDecl(CXXRecordDecl *D) {
|
|
std::cout << D->getNameAsString() << std::endl;
|
|
return false;
|
|
}
|
|
};
|
|
}
|
|
|
|
ASTConsumer *BoostConAction::CreateASTConsumer(CompilerInstance &CI,
|
|
llvm::StringRef InFile) {
|
|
return new BoostConASTConsumer();
|
|
}
|
|
|
|
void BoostConASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
|
|
fprintf(stderr, "Welcome to BoostCon!\n");
|
|
TraverseDecl(Ctx.getTranslationUnitDecl());
|
|
}
|