[cfe-commits] r45180 - in /cfe/trunk: AST/TranslationUnit.cpp Driver/ASTConsumers.cpp Driver/SerializationTest.cpp Driver/clang.cpp include/clang/AST/TranslationUnit.h
Ted Kremenek
kremenek at apple.com
Tue Dec 18 13:44:50 PST 2007
Author: kremenek
Date: Tue Dec 18 15:44:50 2007
New Revision: 45180
URL: http://llvm.org/viewvc/llvm-project?rev=45180&view=rev
Log:
Moved ReadBitcodeFile and EmitBitcodeFile out of TranslationUnit and made them
the standalone functions ReadASTBitcodeFile and EmitASTBitcodeFile
respectively.
Modified:
cfe/trunk/AST/TranslationUnit.cpp
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/Driver/SerializationTest.cpp
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/AST/TranslationUnit.h
Modified: cfe/trunk/AST/TranslationUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/TranslationUnit.cpp?rev=45180&r1=45179&r2=45180&view=diff
==============================================================================
--- cfe/trunk/AST/TranslationUnit.cpp (original)
+++ cfe/trunk/AST/TranslationUnit.cpp Tue Dec 18 15:44:50 2007
@@ -32,7 +32,8 @@
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 @@
llvm::Serializer Sezr(Stream);
// Emit the translation unit.
- Emit(Sezr);
+ TU.Emit(Sezr);
}
// Write the bits to disk.
@@ -122,8 +123,7 @@
}
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 @@
// Create the deserializer.
llvm::Deserializer Dezr(Stream);
- return Create(Dezr,FMgr);
+ return TranslationUnit::Create(Dezr,FMgr);
}
TranslationUnit* TranslationUnit::Create(llvm::Deserializer& Dezr,
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=45180&r1=45179&r2=45180&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Tue Dec 18 15:44:50 2007
@@ -632,7 +632,7 @@
TU.AddTopLevelDecl(D);
}
- ~ASTSerializer() { TU.EmitBitcodeFile(FName); }
+ ~ASTSerializer() { EmitASTBitcodeFile(TU,FName); }
};
} // end anonymous namespace
Modified: cfe/trunk/Driver/SerializationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/SerializationTest.cpp?rev=45180&r1=45179&r2=45180&view=diff
==============================================================================
--- cfe/trunk/Driver/SerializationTest.cpp (original)
+++ cfe/trunk/Driver/SerializationTest.cpp Tue Dec 18 15:44:50 2007
@@ -76,14 +76,14 @@
}
// 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;
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=45180&r1=45179&r2=45180&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Tue Dec 18 15:44:50 2007
@@ -1048,7 +1048,7 @@
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",
Modified: cfe/trunk/include/clang/AST/TranslationUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TranslationUnit.h?rev=45180&r1=45179&r2=45180&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TranslationUnit.h (original)
+++ cfe/trunk/include/clang/AST/TranslationUnit.h Tue Dec 18 15:44:50 2007
@@ -46,19 +46,12 @@
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 @@
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
More information about the cfe-commits
mailing list