aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-20 08:08:23 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-06-20 08:08:23 +0000
commit0853a02c3b04d96a3c432b883e403175c954cd81 (patch)
treee41d07aca3a8b3afe45e5f29955342ccc95ed43a /include/clang/Frontend
parent9cfbe48a7a20a217fdb2920b29b67ae7941cb116 (diff)
Introduce the ASTUnit class.
ASTUnit is a helper class to allow easy loading of an ASTContext from a PCH file. No users for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73819 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTUnit.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
new file mode 100644
index 0000000000..1cbe2e2e27
--- /dev/null
+++ b/include/clang/Frontend/ASTUnit.h
@@ -0,0 +1,62 @@
+#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(); }
+
+ /// \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