1 //===--- ASTUnit.h - ASTUnit utility ----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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"
24 class DiagnosticClient
;
32 /// \brief Utility class for loading a ASTContext from a PCH file.
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
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.
61 /// \param Filename PCH filename
63 /// \param FileMgr The FileManager to use
65 /// \param ErrMsg Error message to report if the PCH file could not be loaded
67 /// \returns the initialized ASTUnit or NULL if the PCH failed to load
68 static ASTUnit
*LoadFromPCHFile(const std::string
&Filename
,
70 std::string
*ErrMsg
= 0);