Moved ReadBitcodeFile and EmitBitcodeFile out of TranslationUnit and made them
the standalone functions ReadASTBitcodeFile and EmitASTBitcodeFile respectively. llvm-svn: 45180
This commit is contained in:
parent
824a9d8d4b
commit
f70d24d2ae
|
|
@ -32,7 +32,8 @@ namespace {
|
|||
|
||||
using namespace clang;
|
||||
|
||||
bool TranslationUnit::EmitBitcodeFile(const llvm::sys::Path& Filename) const {
|
||||
bool clang::EmitASTBitcodeFile(const TranslationUnit& TU,
|
||||
const llvm::sys::Path& Filename) {
|
||||
|
||||
// Reserve 256K for bitstream buffer.
|
||||
std::vector<unsigned char> Buffer;
|
||||
|
|
@ -55,7 +56,7 @@ bool TranslationUnit::EmitBitcodeFile(const llvm::sys::Path& Filename) const {
|
|||
llvm::Serializer Sezr(Stream);
|
||||
|
||||
// Emit the translation unit.
|
||||
Emit(Sezr);
|
||||
TU.Emit(Sezr);
|
||||
}
|
||||
|
||||
// Write the bits to disk.
|
||||
|
|
@ -122,8 +123,7 @@ void TranslationUnit::Emit(llvm::Serializer& Sezr) const {
|
|||
}
|
||||
|
||||
TranslationUnit*
|
||||
TranslationUnit::ReadBitcodeFile(const llvm::sys::Path& Filename,
|
||||
FileManager& FMgr) {
|
||||
clang::ReadASTBitcodeFile(const llvm::sys::Path& Filename, FileManager& FMgr) {
|
||||
|
||||
// Create the memory buffer that contains the contents of the file.
|
||||
llvm::scoped_ptr<llvm::MemoryBuffer>
|
||||
|
|
@ -158,7 +158,7 @@ TranslationUnit::ReadBitcodeFile(const llvm::sys::Path& Filename,
|
|||
// Create the deserializer.
|
||||
llvm::Deserializer Dezr(Stream);
|
||||
|
||||
return Create(Dezr,FMgr);
|
||||
return TranslationUnit::Create(Dezr,FMgr);
|
||||
}
|
||||
|
||||
TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr,
|
||||
|
|
|
|||
|
|
@ -632,7 +632,7 @@ namespace {
|
|||
TU.AddTopLevelDecl(D);
|
||||
}
|
||||
|
||||
~ASTSerializer() { TU.EmitBitcodeFile(FName); }
|
||||
~ASTSerializer() { EmitASTBitcodeFile(TU,FName); }
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
|
|
|
|||
|
|
@ -76,14 +76,14 @@ bool SerializationTest::Serialize(llvm::sys::Path& Filename,
|
|||
}
|
||||
|
||||
// Serialize the translation unit.
|
||||
return TU.EmitBitcodeFile(Filename);
|
||||
return EmitASTBitcodeFile(TU,Filename);
|
||||
}
|
||||
|
||||
bool SerializationTest::Deserialize(llvm::sys::Path& Filename,
|
||||
llvm::sys::Path& FNameDeclPrint) {
|
||||
|
||||
// Deserialize the translation unit.
|
||||
TranslationUnit* NewTU = TranslationUnit::ReadBitcodeFile(Filename,FMgr);
|
||||
TranslationUnit* NewTU = ReadASTBitcodeFile(Filename,FMgr);
|
||||
|
||||
if (!NewTU)
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1048,7 +1048,7 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
|
|||
exit (1);
|
||||
}
|
||||
|
||||
TranslationUnit* TU = TranslationUnit::ReadBitcodeFile(Filename,FileMgr);
|
||||
TranslationUnit* TU = ReadASTBitcodeFile(Filename,FileMgr);
|
||||
|
||||
if (!TU) {
|
||||
fprintf(stderr, "error: file '%s' could not be deserialized\n",
|
||||
|
|
|
|||
|
|
@ -46,19 +46,12 @@ public:
|
|||
ASTContext* getContext() const { return Context; }
|
||||
const LangOptions& getLangOpts() const { return LangOpts; }
|
||||
|
||||
/// EmitBitcodeFile - Emit the translation unit to a bitcode file.
|
||||
bool EmitBitcodeFile(const llvm::sys::Path& Filename) const;
|
||||
|
||||
/// Emit - Emit the translation unit to an arbitray bitcode stream.
|
||||
void Emit(llvm::Serializer& S) const;
|
||||
|
||||
/// Create - Reconsititute a translation unit from a bitcode stream.
|
||||
static TranslationUnit* Create(llvm::Deserializer& D, FileManager& FMgr);
|
||||
|
||||
/// ReadBitcodeFile - Reconsitute a translation unit from a bitcode file.
|
||||
static TranslationUnit* ReadBitcodeFile(const llvm::sys::Path& Filename,
|
||||
FileManager& FMgr);
|
||||
|
||||
// Accessors
|
||||
const LangOptions& getLangOptions() const { return LangOpts; }
|
||||
ASTContext* getASTContext() { return Context; }
|
||||
|
|
@ -77,6 +70,15 @@ public:
|
|||
const_iterator end() const { return TopLevelDecls.end(); }
|
||||
};
|
||||
|
||||
/// EmitASTBitcodeFile - Emit a translation unit to a bitcode file.
|
||||
bool EmitASTBitcodeFile(const TranslationUnit& TU,
|
||||
const llvm::sys::Path& Filename);
|
||||
|
||||
/// ReadASTBitcodeFile - Reconsitute a translation unit from a bitcode file.
|
||||
TranslationUnit* ReadASTBitcodeFile(const llvm::sys::Path& Filename,
|
||||
FileManager& FMgr);
|
||||
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue