Newer
Older
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//===--- ASTStreamer.cpp - Provide streaming interface to ASTs ------------===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ASTStreamer interface.
//
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTStreamer.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/Parser.h"
using namespace llvm;
using namespace clang;
namespace {
class ASTStreamer {
EmptyAction Builder;
Parser P;
public:
ASTStreamer(Preprocessor &PP, unsigned MainFileID)
: P(PP, Builder) {
PP.EnterSourceFile(MainFileID, 0, true);
// Parsing the specified input file.
P.ParseTranslationUnit();
}
/// ReadTopLevelDecl - Parse and return the next top-level declaration.
Decl *ReadTopLevelDecl() {
return 0;
}
};
}
//===----------------------------------------------------------------------===//
// Public interface to the file
//===----------------------------------------------------------------------===//
/// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
/// and FileID.
ASTStreamerTy *llvm::clang::ASTStreamer_Init(Preprocessor &PP,
unsigned MainFileID) {
return new ASTStreamer(PP, MainFileID);
}
/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration. This
/// returns null at end of file.
Decl *llvm::clang::ASTStreamer_ReadTopLevelDecl(ASTStreamerTy *Streamer) {
return static_cast<ASTStreamer*>(Streamer)->ReadTopLevelDecl();
}
/// ASTStreamer_Terminate - Gracefully shut down the streamer.
///
void llvm::clang::ASTStreamer_Terminate(ASTStreamerTy *Streamer) {
delete static_cast<ASTStreamer*>(Streamer);
}