aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-28 03:49:26 +0000
committerChris Lattner <sabre@nondot.org>2009-03-28 03:49:26 +0000
commit5f737ccd3854b55a3eb9ab3aa54f2b1c3212418f (patch)
tree5346f2f5d03bcacf829da24365a2421882fa296c
parenta9376d470ccb0eac74fe09a6b2a18a890f1d17c4 (diff)
eliminate ReadASTBitcodeFile
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67903 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/TranslationUnit.h4
-rw-r--r--lib/AST/TranslationUnit.cpp17
-rw-r--r--tools/clang-cc/SerializationTest.cpp13
-rw-r--r--tools/clang-cc/clang.cpp9
4 files changed, 21 insertions, 22 deletions
diff --git a/include/clang/AST/TranslationUnit.h b/include/clang/AST/TranslationUnit.h
index 5fff66626b..3c6344f2d9 100644
--- a/include/clang/AST/TranslationUnit.h
+++ b/include/clang/AST/TranslationUnit.h
@@ -82,10 +82,6 @@ bool EmitASTBitcodeBuffer(const TranslationUnit& TU,
bool EmitASTBitcodeBuffer(const TranslationUnit* TU,
std::vector<unsigned char>& Buffer);
-/// ReadASTBitcodeFile - Reconsitute a translation unit from a bitcode file.
-TranslationUnit* ReadASTBitcodeFile(const llvm::sys::Path& Filename,
- FileManager& FMgr);
-
/// ReadASTBitcodeBuffer - Reconsitute a translation unit from a buffer.
TranslationUnit* ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer,
FileManager& FMgr);
diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp
index 8ceada593e..a0a800c1e3 100644
--- a/lib/AST/TranslationUnit.cpp
+++ b/lib/AST/TranslationUnit.cpp
@@ -144,28 +144,13 @@ clang::ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer, FileManager& FMgr) {
return TranslationUnit::Create(Dezr,FMgr);
}
-TranslationUnit*
-clang::ReadASTBitcodeFile(const llvm::sys::Path& Filename, FileManager& FMgr) {
-
- // Create the memory buffer that contains the contents of the file.
- llvm::OwningPtr<llvm::MemoryBuffer>
- MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str()));
-
- if (!MBuffer) {
- // FIXME: Provide diagnostic.
- return NULL;
- }
-
- return ReadASTBitcodeBuffer(*MBuffer, FMgr);
-}
-
TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr,
FileManager& FMgr) {
// Create the translation unit object.
TranslationUnit* TU = new TranslationUnit();
- TU->Context = ASTContext.CreateAll(Dezr, FmMgr);
+ TU->Context = ASTContext::CreateAll(Dezr, FMgr);
return TU;
}
diff --git a/tools/clang-cc/SerializationTest.cpp b/tools/clang-cc/SerializationTest.cpp
index e489a19ff8..fcc047e015 100644
--- a/tools/clang-cc/SerializationTest.cpp
+++ b/tools/clang-cc/SerializationTest.cpp
@@ -81,7 +81,18 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename,
llvm::sys::Path& FNameDeclPrint) {
// Deserialize the translation unit.
- TranslationUnit* NewTU = ReadASTBitcodeFile(Filename, FMgr);
+ TranslationUnit* NewTU;
+
+ {
+ // Create the memory buffer that contains the contents of the file.
+ llvm::OwningPtr<llvm::MemoryBuffer>
+ MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str()));
+
+ if (!MBuffer)
+ return false;
+
+ NewTU = ReadASTBitcodeBuffer(*MBuffer, FMgr);
+ }
if (!NewTU)
return false;
diff --git a/tools/clang-cc/clang.cpp b/tools/clang-cc/clang.cpp
index 7f46f46fed..9bd6dfb805 100644
--- a/tools/clang-cc/clang.cpp
+++ b/tools/clang-cc/clang.cpp
@@ -1535,7 +1535,14 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
exit (1);
}
- llvm::OwningPtr<TranslationUnit> TU(ReadASTBitcodeFile(Filename, FileMgr));
+ llvm::OwningPtr<TranslationUnit> TU;
+
+ // Create the memory buffer that contains the contents of the file.
+ llvm::OwningPtr<llvm::MemoryBuffer>
+ MBuffer(llvm::MemoryBuffer::getFile(Filename.c_str()));
+
+ if (MBuffer)
+ TU.reset(ReadASTBitcodeBuffer(*MBuffer, FileMgr));
if (!TU) {
fprintf(stderr, "error: file '%s' could not be deserialized\n",