aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/clang14/lib/Frontend/ExtractAPIConsumer.cpp
blob: cdf67f3c327aae81846fb5b86b2de33abb1a35d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/ASTConsumers.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"

using namespace clang;

namespace {
class ExtractAPIVisitor : public RecursiveASTVisitor<ExtractAPIVisitor> {
public:
  bool VisitNamedDecl(NamedDecl *Decl) {
    llvm::outs() << Decl->getName() << "\n";
    return true;
  }
};

class ExtractAPIConsumer : public ASTConsumer {
public:
  void HandleTranslationUnit(ASTContext &Context) override {
    Visitor.TraverseDecl(Context.getTranslationUnitDecl());
  }

private:
  ExtractAPIVisitor Visitor;
};
} // namespace

std::unique_ptr<ASTConsumer>
ExtractAPIAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
  return std::make_unique<ExtractAPIConsumer>();
}