|
@@ -1148,6 +1148,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang maj.
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang maj.
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min.
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang min.
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Relocatable
|
|
|
|
+ MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Timestamps
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Errors
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Errors
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag
|
|
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag
|
|
unsigned MetadataAbbrevCode = Stream.EmitAbbrev(MetadataAbbrev);
|
|
unsigned MetadataAbbrevCode = Stream.EmitAbbrev(MetadataAbbrev);
|
|
@@ -1159,6 +1160,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
|
assert((!WritingModule || isysroot.empty()) &&
|
|
assert((!WritingModule || isysroot.empty()) &&
|
|
"writing module as a relocatable PCH?");
|
|
"writing module as a relocatable PCH?");
|
|
Record.push_back(!isysroot.empty());
|
|
Record.push_back(!isysroot.empty());
|
|
|
|
+ Record.push_back(IncludeTimestamps);
|
|
Record.push_back(ASTHasCompilerErrors);
|
|
Record.push_back(ASTHasCompilerErrors);
|
|
Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
|
|
Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
|
|
getClangFullRepositoryVersion());
|
|
getClangFullRepositoryVersion());
|
|
@@ -1248,7 +1250,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
|
Record.push_back((unsigned)M->Kind); // FIXME: Stable encoding
|
|
Record.push_back((unsigned)M->Kind); // FIXME: Stable encoding
|
|
AddSourceLocation(M->ImportLoc, Record);
|
|
AddSourceLocation(M->ImportLoc, Record);
|
|
Record.push_back(M->File->getSize());
|
|
Record.push_back(M->File->getSize());
|
|
- Record.push_back(M->File->getModificationTime());
|
|
|
|
|
|
+ Record.push_back(getTimestampForOutput(M->File));
|
|
Record.push_back(M->Signature);
|
|
Record.push_back(M->Signature);
|
|
AddPath(M->FileName, Record);
|
|
AddPath(M->FileName, Record);
|
|
}
|
|
}
|
|
@@ -1512,7 +1514,7 @@ void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
|
|
|
|
|
|
// Emit size/modification time for this file.
|
|
// Emit size/modification time for this file.
|
|
Record.push_back(Entry.File->getSize());
|
|
Record.push_back(Entry.File->getSize());
|
|
- Record.push_back(Entry.File->getModificationTime());
|
|
|
|
|
|
+ Record.push_back(getTimestampForOutput(Entry.File));
|
|
|
|
|
|
// Whether this file was overridden.
|
|
// Whether this file was overridden.
|
|
Record.push_back(Entry.BufferOverridden);
|
|
Record.push_back(Entry.BufferOverridden);
|
|
@@ -1624,15 +1626,12 @@ namespace {
|
|
typedef unsigned hash_value_type;
|
|
typedef unsigned hash_value_type;
|
|
typedef unsigned offset_type;
|
|
typedef unsigned offset_type;
|
|
|
|
|
|
- static hash_value_type ComputeHash(key_type_ref key) {
|
|
|
|
|
|
+ hash_value_type ComputeHash(key_type_ref key) {
|
|
// The hash is based only on size/time of the file, so that the reader can
|
|
// The hash is based only on size/time of the file, so that the reader can
|
|
// match even when symlinking or excess path elements ("foo/../", "../")
|
|
// match even when symlinking or excess path elements ("foo/../", "../")
|
|
// change the form of the name. However, complete path is still the key.
|
|
// change the form of the name. However, complete path is still the key.
|
|
- //
|
|
|
|
- // FIXME: Using the mtime here will cause problems for explicit module
|
|
|
|
- // imports.
|
|
|
|
return llvm::hash_combine(key.FE->getSize(),
|
|
return llvm::hash_combine(key.FE->getSize(),
|
|
- key.FE->getModificationTime());
|
|
|
|
|
|
+ Writer.getTimestampForOutput(key.FE));
|
|
}
|
|
}
|
|
|
|
|
|
std::pair<unsigned,unsigned>
|
|
std::pair<unsigned,unsigned>
|
|
@@ -1653,7 +1652,7 @@ namespace {
|
|
endian::Writer<little> LE(Out);
|
|
endian::Writer<little> LE(Out);
|
|
LE.write<uint64_t>(key.FE->getSize());
|
|
LE.write<uint64_t>(key.FE->getSize());
|
|
KeyLen -= 8;
|
|
KeyLen -= 8;
|
|
- LE.write<uint64_t>(key.FE->getModificationTime());
|
|
|
|
|
|
+ LE.write<uint64_t>(Writer.getTimestampForOutput(key.FE));
|
|
KeyLen -= 8;
|
|
KeyLen -= 8;
|
|
Out.write(key.Filename, KeyLen);
|
|
Out.write(key.Filename, KeyLen);
|
|
}
|
|
}
|
|
@@ -4058,22 +4057,21 @@ void ASTWriter::SetSelectorOffset(Selector Sel, uint32_t Offset) {
|
|
SelectorOffsets[ID - FirstSelectorID] = Offset;
|
|
SelectorOffsets[ID - FirstSelectorID] = Offset;
|
|
}
|
|
}
|
|
|
|
|
|
-ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream)
|
|
|
|
|
|
+ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream, bool IncludeTimestamps)
|
|
: Stream(Stream), Context(nullptr), PP(nullptr), Chain(nullptr),
|
|
: Stream(Stream), Context(nullptr), PP(nullptr), Chain(nullptr),
|
|
- WritingModule(nullptr), WritingAST(false),
|
|
|
|
- DoneWritingDeclsAndTypes(false), ASTHasCompilerErrors(false),
|
|
|
|
- FirstDeclID(NUM_PREDEF_DECL_IDS), NextDeclID(FirstDeclID),
|
|
|
|
- FirstTypeID(NUM_PREDEF_TYPE_IDS), NextTypeID(FirstTypeID),
|
|
|
|
- FirstIdentID(NUM_PREDEF_IDENT_IDS), NextIdentID(FirstIdentID),
|
|
|
|
- FirstMacroID(NUM_PREDEF_MACRO_IDS), NextMacroID(FirstMacroID),
|
|
|
|
- FirstSubmoduleID(NUM_PREDEF_SUBMODULE_IDS),
|
|
|
|
|
|
+ WritingModule(nullptr), IncludeTimestamps(IncludeTimestamps),
|
|
|
|
+ WritingAST(false), DoneWritingDeclsAndTypes(false),
|
|
|
|
+ ASTHasCompilerErrors(false), FirstDeclID(NUM_PREDEF_DECL_IDS),
|
|
|
|
+ NextDeclID(FirstDeclID), FirstTypeID(NUM_PREDEF_TYPE_IDS),
|
|
|
|
+ NextTypeID(FirstTypeID), FirstIdentID(NUM_PREDEF_IDENT_IDS),
|
|
|
|
+ NextIdentID(FirstIdentID), FirstMacroID(NUM_PREDEF_MACRO_IDS),
|
|
|
|
+ NextMacroID(FirstMacroID), FirstSubmoduleID(NUM_PREDEF_SUBMODULE_IDS),
|
|
NextSubmoduleID(FirstSubmoduleID),
|
|
NextSubmoduleID(FirstSubmoduleID),
|
|
FirstSelectorID(NUM_PREDEF_SELECTOR_IDS), NextSelectorID(FirstSelectorID),
|
|
FirstSelectorID(NUM_PREDEF_SELECTOR_IDS), NextSelectorID(FirstSelectorID),
|
|
CollectedStmts(&StmtsToEmit), NumStatements(0), NumMacros(0),
|
|
CollectedStmts(&StmtsToEmit), NumStatements(0), NumMacros(0),
|
|
NumLexicalDeclContexts(0), NumVisibleDeclContexts(0),
|
|
NumLexicalDeclContexts(0), NumVisibleDeclContexts(0),
|
|
NextCXXBaseSpecifiersID(1), NextCXXCtorInitializersID(1),
|
|
NextCXXBaseSpecifiersID(1), NextCXXCtorInitializersID(1),
|
|
- TypeExtQualAbbrev(0),
|
|
|
|
- TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0),
|
|
|
|
|
|
+ TypeExtQualAbbrev(0), TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0),
|
|
DeclContextLexicalAbbrev(0), DeclContextVisibleLookupAbbrev(0),
|
|
DeclContextLexicalAbbrev(0), DeclContextVisibleLookupAbbrev(0),
|
|
UpdateVisibleAbbrev(0), DeclRecordAbbrev(0), DeclTypedefAbbrev(0),
|
|
UpdateVisibleAbbrev(0), DeclRecordAbbrev(0), DeclTypedefAbbrev(0),
|
|
DeclVarAbbrev(0), DeclFieldAbbrev(0), DeclEnumAbbrev(0),
|
|
DeclVarAbbrev(0), DeclFieldAbbrev(0), DeclEnumAbbrev(0),
|
|
@@ -4090,6 +4088,10 @@ const LangOptions &ASTWriter::getLangOpts() const {
|
|
return Context->getLangOpts();
|
|
return Context->getLangOpts();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+time_t ASTWriter::getTimestampForOutput(const FileEntry *E) const {
|
|
|
|
+ return IncludeTimestamps ? E->getModificationTime() : 0;
|
|
|
|
+}
|
|
|
|
+
|
|
void ASTWriter::WriteAST(Sema &SemaRef,
|
|
void ASTWriter::WriteAST(Sema &SemaRef,
|
|
const std::string &OutputFile,
|
|
const std::string &OutputFile,
|
|
Module *WritingModule, StringRef isysroot,
|
|
Module *WritingModule, StringRef isysroot,
|