iterator end() const { return Context->getTranslationUnitDecl()->decls_end(); }
};
-/// EmitASTBitcodeFile - Emit a translation unit to a bitcode file.
-bool EmitASTBitcodeFile(const TranslationUnit& TU,
- const llvm::sys::Path& Filename);
-
-bool EmitASTBitcodeFile(const TranslationUnit* TU,
- const llvm::sys::Path& Filename);
-
-/// EmitASTBitcodeStream - Emit a translation unit to a std::ostream.
-bool EmitASTBitcodeStream(const TranslationUnit& TU,
- std::ostream& Stream);
-
-bool EmitASTBitcodeStream(const TranslationUnit* TU,
- std::ostream& Stream);
-
/// EmitASTBitcodeBuffer - Emit a translation unit to a buffer.
bool EmitASTBitcodeBuffer(const TranslationUnit& TU,
std::vector<unsigned char>& Buffer);
-bool EmitASTBitcodeBuffer(const TranslationUnit* TU,
- std::vector<unsigned char>& Buffer);
-
/// ReadASTBitcodeBuffer - Reconsitute a translation unit from a buffer.
TranslationUnit* ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer,
FileManager& FMgr);
}
}
-bool clang::EmitASTBitcodeFile(const TranslationUnit* TU,
- const llvm::sys::Path& Filename) {
-
- return TU ? EmitASTBitcodeFile(*TU, Filename) : false;
-}
-
-bool clang::EmitASTBitcodeBuffer(const TranslationUnit* TU,
- std::vector<unsigned char>& Buffer) {
-
- return TU ? EmitASTBitcodeBuffer(*TU, Buffer) : false;
-}
-
-bool clang::EmitASTBitcodeStream(const TranslationUnit* TU,
- std::ostream& Stream) {
-
- return TU ? EmitASTBitcodeStream(*TU, Stream) : false;
-}
-
bool clang::EmitASTBitcodeBuffer(const TranslationUnit& TU,
std::vector<unsigned char>& Buffer) {
// Create bitstream.
return true;
}
-bool clang::EmitASTBitcodeStream(const TranslationUnit& TU,
- std::ostream& Stream) {
-
- // Reserve 256K for bitstream buffer.
- std::vector<unsigned char> Buffer;
- Buffer.reserve(256*1024);
-
- EmitASTBitcodeBuffer(TU,Buffer);
-
- // Write the bits to disk.
- Stream.write((char*)&Buffer.front(), Buffer.size());
- return true;
-}
-
-bool clang::EmitASTBitcodeFile(const TranslationUnit& TU,
- const llvm::sys::Path& Filename) {
-
- // Reserve 256K for bitstream buffer.
- std::vector<unsigned char> Buffer;
- Buffer.reserve(256*1024);
-
- EmitASTBitcodeBuffer(TU,Buffer);
-
- // Write the bits to disk.
- if (FILE* fp = fopen(Filename.c_str(),"wb")) {
- fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
- fclose(fp);
- return true;
- }
-
- return false;
-}
-
TranslationUnit*
clang::ReadASTBitcodeBuffer(llvm::MemoryBuffer& MBuffer, FileManager& FMgr) {
virtual void HandleTranslationUnit(TranslationUnit& TU) {
if (Diags.hasErrorOccurred())
return;
- EmitASTBitcodeFile(&TU, FName);
+
+ // Reserve 256K for bitstream buffer.
+ std::vector<unsigned char> Buffer;
+ Buffer.reserve(256*1024);
+
+ EmitASTBitcodeBuffer(TU,Buffer);
+
+ // Write the bits to disk.
+ if (FILE* fp = fopen(FName.c_str(),"wb")) {
+ fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
+ fclose(fp);
+ }
}
};
sprintf(&buf[0], "%s-%llX.ast", FE->getName(),
(unsigned long long) FE->getInode());
FName.appendComponent(&buf[0]);
- EmitASTBitcodeFile(&TU, FName);
+
+
+ // Reserve 256K for bitstream buffer.
+ std::vector<unsigned char> Buffer;
+ Buffer.reserve(256*1024);
+
+ EmitASTBitcodeBuffer(TU,Buffer);
+
+ // Write the bits to disk.
+ if (FILE* fp = fopen(FName.c_str(),"wb")) {
+ fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
+ fclose(fp);
+ }
// Now emit the sources.
}
// Serialize the translation unit.
- return EmitASTBitcodeFile(TU,Filename);
+
+ // Reserve 256K for bitstream buffer.
+ std::vector<unsigned char> Buffer;
+ Buffer.reserve(256*1024);
+
+ EmitASTBitcodeBuffer(TU,Buffer);
+
+ // Write the bits to disk.
+ if (FILE* fp = fopen(Filename.c_str(),"wb")) {
+ fwrite((char*)&Buffer.front(), sizeof(char), Buffer.size(), fp);
+ fclose(fp);
+ return true;
+ }
+
+ return false;
}
bool SerializationTest::Deserialize(llvm::sys::Path& Filename,