summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-07-17 01:19:54 +0000
committerAdrian Prantl <aprantl@apple.com>2015-07-17 01:19:54 +0000
commitfb2398d0c43405a6b654c80560e38fb3ccd134b9 (patch)
treee1a0f288169e920a3ac6d9f2aaece67eb7796bf1 /clang/lib/Serialization
parentcabe02e14110526189a0935d172f8547f0232572 (diff)
downloadbcm5719-llvm-fb2398d0c43405a6b654c80560e38fb3ccd134b9.tar.gz
bcm5719-llvm-fb2398d0c43405a6b654c80560e38fb3ccd134b9.zip
Make the clang module container format selectable from the command line.
- introduces a new cc1 option -fmodule-format=[raw,obj] with 'raw' being the default - supports arbitrary module container formats that libclang is agnostic to - adds the format to the module hash to avoid collisions - splits the old PCHContainerOperations into PCHContainerWriter and a PCHContainerReader. Thanks to Richard Smith for reviewing this patch! llvm-svn: 242499
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp20
-rw-r--r--clang/lib/Serialization/GlobalModuleIndex.cpp12
-rw-r--r--clang/lib/Serialization/ModuleManager.cpp6
3 files changed, 19 insertions, 19 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 3045629a333..9fbf55bf15d 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3601,7 +3601,7 @@ ASTReader::ReadASTCore(StringRef FileName,
ModuleFile &F = *M;
BitstreamCursor &Stream = F.Stream;
- PCHContainerOps.ExtractPCH(F.Buffer->getMemBufferRef(), F.StreamFile);
+ PCHContainerRdr.ExtractPCH(F.Buffer->getMemBufferRef(), F.StreamFile);
Stream.init(&F.StreamFile);
F.SizeInBits = F.Buffer->getBufferSize() * 8;
@@ -3872,7 +3872,7 @@ static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile){
/// file.
std::string ASTReader::getOriginalSourceFile(
const std::string &ASTFileName, FileManager &FileMgr,
- const PCHContainerOperations &PCHContainerOps, DiagnosticsEngine &Diags) {
+ const PCHContainerReader &PCHContainerRdr, DiagnosticsEngine &Diags) {
// Open the AST file.
auto Buffer = FileMgr.getBufferForFile(ASTFileName);
if (!Buffer) {
@@ -3883,7 +3883,7 @@ std::string ASTReader::getOriginalSourceFile(
// Initialize the stream
llvm::BitstreamReader StreamFile;
- PCHContainerOps.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
+ PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
BitstreamCursor Stream(StreamFile);
// Sniff for the signature.
@@ -3967,7 +3967,7 @@ namespace {
bool ASTReader::readASTFileControlBlock(
StringRef Filename, FileManager &FileMgr,
- const PCHContainerOperations &PCHContainerOps,
+ const PCHContainerReader &PCHContainerRdr,
ASTReaderListener &Listener) {
// Open the AST file.
// FIXME: This allows use of the VFS; we do not allow use of the
@@ -3979,7 +3979,7 @@ bool ASTReader::readASTFileControlBlock(
// Initialize the stream
llvm::BitstreamReader StreamFile;
- PCHContainerOps.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
+ PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
BitstreamCursor Stream(StreamFile);
// Sniff for the signature.
@@ -4160,12 +4160,12 @@ bool ASTReader::readASTFileControlBlock(
bool ASTReader::isAcceptableASTFile(
StringRef Filename, FileManager &FileMgr,
- const PCHContainerOperations &PCHContainerOps, const LangOptions &LangOpts,
+ const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts,
const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts,
std::string ExistingModuleCachePath) {
SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
ExistingModuleCachePath, FileMgr);
- return !readASTFileControlBlock(Filename, FileMgr, PCHContainerOps,
+ return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
validator);
}
@@ -8472,7 +8472,7 @@ void ASTReader::pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name) {
}
ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context,
- const PCHContainerOperations &PCHContainerOps,
+ const PCHContainerReader &PCHContainerRdr,
StringRef isysroot, bool DisableValidation,
bool AllowASTWithCompilerErrors,
bool AllowConfigurationMismatch, bool ValidateSystemInputs,
@@ -8480,9 +8480,9 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context,
std::unique_ptr<llvm::Timer> ReadTimer)
: Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr),
OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()),
- FileMgr(PP.getFileManager()), PCHContainerOps(PCHContainerOps),
+ FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
- Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerOps),
+ Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
ReadTimer(std::move(ReadTimer)),
isysroot(isysroot), DisableValidation(DisableValidation),
AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp
index 2c7da3e82a4..17c7914243e 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -385,7 +385,7 @@ namespace {
/// \brief Builder that generates the global module index file.
class GlobalModuleIndexBuilder {
FileManager &FileMgr;
- const PCHContainerOperations &PCHContainerOps;
+ const PCHContainerReader &PCHContainerRdr;
/// \brief Mapping from files to module file information.
typedef llvm::MapVector<const FileEntry *, ModuleFileInfo> ModuleFilesMap;
@@ -419,8 +419,8 @@ namespace {
public:
explicit GlobalModuleIndexBuilder(
- FileManager &FileMgr, const PCHContainerOperations &PCHContainerOps)
- : FileMgr(FileMgr), PCHContainerOps(PCHContainerOps) {}
+ FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr)
+ : FileMgr(FileMgr), PCHContainerRdr(PCHContainerRdr) {}
/// \brief Load the contents of the given module file into the builder.
///
@@ -505,7 +505,7 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {
// Initialize the input stream
llvm::BitstreamReader InStreamFile;
- PCHContainerOps.ExtractPCH((*Buffer)->getMemBufferRef(), InStreamFile);
+ PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), InStreamFile);
llvm::BitstreamCursor InStream(InStreamFile);
// Sniff for the signature.
@@ -768,7 +768,7 @@ void GlobalModuleIndexBuilder::writeIndex(llvm::BitstreamWriter &Stream) {
GlobalModuleIndex::ErrorCode
GlobalModuleIndex::writeIndex(FileManager &FileMgr,
- const PCHContainerOperations &PCHContainerOps,
+ const PCHContainerReader &PCHContainerRdr,
StringRef Path) {
llvm::SmallString<128> IndexPath;
IndexPath += Path;
@@ -792,7 +792,7 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr,
}
// The module index builder.
- GlobalModuleIndexBuilder Builder(FileMgr, PCHContainerOps);
+ GlobalModuleIndexBuilder Builder(FileMgr, PCHContainerRdr);
// Load each of the module files.
std::error_code EC;
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index 03d8ed0e246..271619404d2 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -139,7 +139,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
}
// Initialize the stream.
- PCHContainerOps.ExtractPCH(New->Buffer->getMemBufferRef(), New->StreamFile);
+ PCHContainerRdr.ExtractPCH(New->Buffer->getMemBufferRef(), New->StreamFile);
}
if (ExpectedSignature) {
@@ -290,8 +290,8 @@ void ModuleManager::moduleFileAccepted(ModuleFile *MF) {
}
ModuleManager::ModuleManager(FileManager &FileMgr,
- const PCHContainerOperations &PCHContainerOps)
- : FileMgr(FileMgr), PCHContainerOps(PCHContainerOps), GlobalIndex(),
+ const PCHContainerReader &PCHContainerRdr)
+ : FileMgr(FileMgr), PCHContainerRdr(PCHContainerRdr), GlobalIndex(),
FirstVisitState(nullptr) {}
ModuleManager::~ModuleManager() {
OpenPOWER on IntegriCloud