Add the license part to the new source files.
[clang.git] / include / clang / Frontend / ASTUnit.h
blob68c06f5dcee613c0c3d10ad1372bf48827f84548
1 //===--- ASTUnit.h - ASTUnit utility ----------------------------*- 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 //
10 // ASTUnit utility class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H
15 #define LLVM_CLANG_FRONTEND_ASTUNIT_H
17 #include "llvm/ADT/OwningPtr.h"
18 #include <string>
20 namespace clang {
21 class FileManager;
22 class FileEntry;
23 class SourceManager;
24 class DiagnosticClient;
25 class Diagnostic;
26 class HeaderSearch;
27 class TargetInfo;
28 class Preprocessor;
29 class ASTContext;
30 class Decl;
32 /// \brief Utility class for loading a ASTContext from a PCH file.
33 ///
34 class ASTUnit {
35 llvm::OwningPtr<SourceManager> SourceMgr;
36 llvm::OwningPtr<DiagnosticClient> DiagClient;
37 llvm::OwningPtr<Diagnostic> Diags;
38 llvm::OwningPtr<HeaderSearch> HeaderInfo;
39 llvm::OwningPtr<TargetInfo> Target;
40 llvm::OwningPtr<Preprocessor> PP;
41 llvm::OwningPtr<ASTContext> Ctx;
43 ASTUnit(const ASTUnit&); // do not implement
44 ASTUnit &operator=(const ASTUnit &); // do not implement
45 ASTUnit();
47 public:
48 ~ASTUnit();
50 const SourceManager &getSourceManager() const { return *SourceMgr.get(); }
51 SourceManager &getSourceManager() { return *SourceMgr.get(); }
53 const Preprocessor &getPreprocessor() const { return *PP.get(); }
54 Preprocessor &getPreprocessor() { return *PP.get(); }
56 const ASTContext &getASTContext() const { return *Ctx.get(); }
57 ASTContext &getASTContext() { return *Ctx.get(); }
59 /// \brief Create a ASTUnit from a PCH file.
60 ///
61 /// \param Filename PCH filename
62 ///
63 /// \param FileMgr The FileManager to use
64 ///
65 /// \param ErrMsg Error message to report if the PCH file could not be loaded
66 ///
67 /// \returns the initialized ASTUnit or NULL if the PCH failed to load
68 static ASTUnit *LoadFromPCHFile(const std::string &Filename,
69 FileManager &FileMgr,
70 std::string *ErrMsg = 0);
73 } // namespace clang
75 #endif