forked from OSchip/llvm-project
Serialization: Let ASTWriter return the signature of the written module.
NFC llvm-svn: 248344
This commit is contained in:
parent
040975472c
commit
adbd2b1f32
|
@ -505,10 +505,9 @@ private:
|
|||
llvm::DenseSet<Stmt *> &ParentStmts);
|
||||
|
||||
void WriteBlockInfoBlock();
|
||||
void WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
||||
StringRef isysroot, const std::string &OutputFile);
|
||||
void WriteInputFiles(SourceManager &SourceMgr,
|
||||
HeaderSearchOptions &HSOpts,
|
||||
uint64_t WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
||||
StringRef isysroot, const std::string &OutputFile);
|
||||
void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts,
|
||||
bool Modules);
|
||||
void WriteSourceManagerBlock(SourceManager &SourceMgr,
|
||||
const Preprocessor &PP);
|
||||
|
@ -572,9 +571,9 @@ private:
|
|||
void WriteDecl(ASTContext &Context, Decl *D);
|
||||
void AddFunctionDefinition(const FunctionDecl *FD, RecordData &Record);
|
||||
|
||||
void WriteASTCore(Sema &SemaRef,
|
||||
StringRef isysroot, const std::string &OutputFile,
|
||||
Module *WritingModule);
|
||||
uint64_t WriteASTCore(Sema &SemaRef,
|
||||
StringRef isysroot, const std::string &OutputFile,
|
||||
Module *WritingModule);
|
||||
|
||||
public:
|
||||
/// \brief Create a new precompiled header writer that outputs to
|
||||
|
@ -600,10 +599,12 @@ public:
|
|||
/// \param isysroot if non-empty, write a relocatable file whose headers
|
||||
/// are relative to the given system root. If we're writing a module, its
|
||||
/// build directory will be used in preference to this if both are available.
|
||||
void WriteAST(Sema &SemaRef,
|
||||
const std::string &OutputFile,
|
||||
Module *WritingModule, StringRef isysroot,
|
||||
bool hasErrors = false);
|
||||
///
|
||||
/// \return the module signature, which eventually will be a hash of
|
||||
/// the module but currently is merely a random 32-bit number.
|
||||
uint64_t WriteAST(Sema &SemaRef, const std::string &OutputFile,
|
||||
Module *WritingModule, StringRef isysroot,
|
||||
bool hasErrors = false);
|
||||
|
||||
/// \brief Emit a token.
|
||||
void AddToken(const Token &Tok, RecordDataImpl &Record);
|
||||
|
|
|
@ -1166,9 +1166,12 @@ static ASTFileSignature getSignature() {
|
|||
}
|
||||
|
||||
/// \brief Write the control block.
|
||||
void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
||||
StringRef isysroot,
|
||||
const std::string &OutputFile) {
|
||||
uint64_t ASTWriter::WriteControlBlock(Preprocessor &PP,
|
||||
ASTContext &Context,
|
||||
StringRef isysroot,
|
||||
const std::string &OutputFile) {
|
||||
ASTFileSignature Signature = 0;
|
||||
|
||||
using namespace llvm;
|
||||
Stream.EnterSubblock(CONTROL_BLOCK_ID, 5);
|
||||
RecordData Record;
|
||||
|
@ -1201,7 +1204,8 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
|||
// is non-deterministic.
|
||||
// FIXME: Remove this when output is deterministic.
|
||||
if (Context.getLangOpts().ImplicitModules) {
|
||||
RecordData::value_type Record[] = {getSignature()};
|
||||
Signature = getSignature();
|
||||
RecordData::value_type Record[] = {Signature};
|
||||
Stream.EmitRecord(SIGNATURE, Record);
|
||||
}
|
||||
|
||||
|
@ -1468,6 +1472,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
|
|||
PP.getHeaderSearchInfo().getHeaderSearchOpts(),
|
||||
PP.getLangOpts().Modules);
|
||||
Stream.ExitBlock();
|
||||
return Signature;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -4012,12 +4017,11 @@ time_t ASTWriter::getTimestampForOutput(const FileEntry *E) const {
|
|||
return IncludeTimestamps ? E->getModificationTime() : 0;
|
||||
}
|
||||
|
||||
void ASTWriter::WriteAST(Sema &SemaRef,
|
||||
const std::string &OutputFile,
|
||||
Module *WritingModule, StringRef isysroot,
|
||||
bool hasErrors) {
|
||||
uint64_t ASTWriter::WriteAST(Sema &SemaRef, const std::string &OutputFile,
|
||||
Module *WritingModule, StringRef isysroot,
|
||||
bool hasErrors) {
|
||||
WritingAST = true;
|
||||
|
||||
|
||||
ASTHasCompilerErrors = hasErrors;
|
||||
|
||||
// Emit the file header.
|
||||
|
@ -4031,13 +4035,15 @@ void ASTWriter::WriteAST(Sema &SemaRef,
|
|||
Context = &SemaRef.Context;
|
||||
PP = &SemaRef.PP;
|
||||
this->WritingModule = WritingModule;
|
||||
WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
|
||||
ASTFileSignature Signature =
|
||||
WriteASTCore(SemaRef, isysroot, OutputFile, WritingModule);
|
||||
Context = nullptr;
|
||||
PP = nullptr;
|
||||
this->WritingModule = nullptr;
|
||||
this->BaseDirectory.clear();
|
||||
|
||||
WritingAST = false;
|
||||
return Signature;
|
||||
}
|
||||
|
||||
template<typename Vector>
|
||||
|
@ -4049,10 +4055,9 @@ static void AddLazyVectorDecls(ASTWriter &Writer, Vector &Vec,
|
|||
}
|
||||
}
|
||||
|
||||
void ASTWriter::WriteASTCore(Sema &SemaRef,
|
||||
StringRef isysroot,
|
||||
const std::string &OutputFile,
|
||||
Module *WritingModule) {
|
||||
uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
|
||||
const std::string &OutputFile,
|
||||
Module *WritingModule) {
|
||||
using namespace llvm;
|
||||
|
||||
bool isModule = WritingModule != nullptr;
|
||||
|
@ -4197,7 +4202,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
|
|||
}
|
||||
|
||||
// Write the control block
|
||||
WriteControlBlock(PP, Context, isysroot, OutputFile);
|
||||
uint64_t Signature = WriteControlBlock(PP, Context, isysroot, OutputFile);
|
||||
|
||||
// Write the remaining AST contents.
|
||||
Stream.EnterSubblock(AST_BLOCK_ID, 5);
|
||||
|
@ -4527,6 +4532,8 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
|
|||
NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
|
||||
Stream.EmitRecord(STATISTICS, Record);
|
||||
Stream.ExitBlock();
|
||||
|
||||
return Signature;
|
||||
}
|
||||
|
||||
void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
|
||||
|
|
Loading…
Reference in New Issue