blob: 5eb7f494d736989c854825164f3c2a7a2310b5c7 (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
|
//===--- ASTUnit.h - ASTUnit utility ----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// ASTUnit utility class.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H
#define LLVM_CLANG_FRONTEND_ASTUNIT_H
#include "llvm/ADT/OwningPtr.h"
#include <string>
namespace clang {
class FileManager;
class FileEntry;
class SourceManager;
class DiagnosticClient;
class Diagnostic;
class HeaderSearch;
class TargetInfo;
class Preprocessor;
class ASTContext;
class Decl;
/// \brief Utility class for loading a ASTContext from a PCH file.
///
class ASTUnit {
llvm::OwningPtr<SourceManager> SourceMgr;
llvm::OwningPtr<DiagnosticClient> DiagClient;
llvm::OwningPtr<Diagnostic> Diags;
llvm::OwningPtr<HeaderSearch> HeaderInfo;
llvm::OwningPtr<TargetInfo> Target;
llvm::OwningPtr<Preprocessor> PP;
llvm::OwningPtr<ASTContext> Ctx;
ASTUnit(const ASTUnit&); // do not implement
ASTUnit &operator=(const ASTUnit &); // do not implement
ASTUnit();
public:
~ASTUnit();
const SourceManager &getSourceManager() const { return *SourceMgr.get(); }
SourceManager &getSourceManager() { return *SourceMgr.get(); }
const Preprocessor &getPreprocessor() const { return *PP.get(); }
Preprocessor &getPreprocessor() { return *PP.get(); }
const ASTContext &getASTContext() const { return *Ctx.get(); }
ASTContext &getASTContext() { return *Ctx.get(); }
const Diagnostic &getDiagnostic() const { return *Diags.get(); }
Diagnostic &getDiagnostic() { return *Diags.get(); }
/// \brief Create a ASTUnit from a PCH file.
///
/// \param Filename PCH filename
///
/// \param FileMgr The FileManager to use
///
/// \param ErrMsg Error message to report if the PCH file could not be loaded
///
/// \returns the initialized ASTUnit or NULL if the PCH failed to load
static ASTUnit *LoadFromPCHFile(const std::string &Filename,
FileManager &FileMgr,
std::string *ErrMsg = 0);
};
} // namespace clang
#endif
|