forked from OSchip/llvm-project
Implemented serialization of FileEntry and DirectoryEntry.
llvm-svn: 44573
This commit is contained in:
parent
0c2bea2909
commit
f7260b191c
|
@ -19,6 +19,8 @@
|
|||
|
||||
#include "clang/Basic/FileManager.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Bitcode/Serialize.h"
|
||||
#include "llvm/Bitcode/Deserialize.h"
|
||||
#include <iostream>
|
||||
using namespace clang;
|
||||
|
||||
|
@ -170,3 +172,34 @@ void FileManager::PrintStats() const {
|
|||
|
||||
//std::cerr << PagesMapped << BytesOfPagesMapped << FSLookups;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Serialization.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void DirectoryEntry::Emit(llvm::Serializer& S) const {
|
||||
S.EmitCStr(Name);
|
||||
}
|
||||
|
||||
void DirectoryEntry::Read(llvm::Deserializer& D) {
|
||||
Name = D.ReadCStr();
|
||||
}
|
||||
|
||||
void FileEntry::Emit(llvm::Serializer& S) const {
|
||||
S.FlushRecord();
|
||||
S.EmitInt(Size);
|
||||
S.EmitInt(ModTime);
|
||||
S.EmitInt(UID);
|
||||
S.EmitPtr(Dir);
|
||||
S.EmitCStr(Name);
|
||||
}
|
||||
|
||||
void FileEntry::Read(llvm::Deserializer& D) {
|
||||
Size = (off_t) D.ReadInt();
|
||||
ModTime = (time_t) D.ReadInt();
|
||||
D.ReadPtr<DirectoryEntry>(const_cast<DirectoryEntry*&>(Dir));
|
||||
Name = D.ReadCStr();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#define LLVM_CLANG_FILEMANAGER_H
|
||||
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/Bitcode/SerializationFwd.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
// FIXME: Enhance libsystem to support inode and other fields in stat.
|
||||
|
@ -31,6 +32,12 @@ class DirectoryEntry {
|
|||
public:
|
||||
DirectoryEntry() : Name(0) {}
|
||||
const char *getName() const { return Name; }
|
||||
|
||||
/// Emit - Emit this DirectoryEntry to Bitcode.
|
||||
void Emit(llvm::Serializer& S) const;
|
||||
|
||||
/// Create - Reconsitute a DirectoryEntry object from Bitcode.
|
||||
void Read(llvm::Deserializer& D);
|
||||
};
|
||||
|
||||
/// FileEntry - Cached information about one file on the disk.
|
||||
|
@ -53,6 +60,13 @@ public:
|
|||
/// getDir - Return the directory the file lives in.
|
||||
///
|
||||
const DirectoryEntry *getDir() const { return Dir; }
|
||||
|
||||
|
||||
/// Emit - Emit this FileEntry to Bitcode.
|
||||
void Emit(llvm::Serializer& S) const;
|
||||
|
||||
/// Read - Reconsitute a FileEntry object from Bitcode.
|
||||
void Read(llvm::Deserializer& D);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue