r248344 - Serialization: Let ASTWriter return the signature of the written module.
Adrian Prantl via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 22 16:26:32 PDT 2015
Author: adrian
Date: Tue Sep 22 18:26:31 2015
New Revision: 248344
URL: http://llvm.org/viewvc/llvm-project?rev=248344&view=rev
Log:
Serialization: Let ASTWriter return the signature of the written module.
NFC
Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=248344&r1=248343&r2=248344&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Sep 22 18:26:31 2015
@@ -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);
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=248344&r1=248343&r2=248344&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Sep 22 18:26:31 2015
@@ -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(Prepro
// 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(Prepro
PP.getHeaderSearchInfo().getHeaderSearchOpts(),
PP.getLangOpts().Modules);
Stream.ExitBlock();
+ return Signature;
}
namespace {
@@ -4012,12 +4017,11 @@ time_t ASTWriter::getTimestampForOutput(
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
}
}
-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 &SemaR
}
// 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 &SemaR
NumStatements, NumMacros, NumLexicalDeclContexts, NumVisibleDeclContexts};
Stream.EmitRecord(STATISTICS, Record);
Stream.ExitBlock();
+
+ return Signature;
}
void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
More information about the cfe-commits
mailing list