Skip to content

Commit 89d4029

Browse files
committed
Revert "[clang][modules] Timestamp PCM files when writing (#9483)"
This reverts commit 65a1746.
1 parent 67e11cb commit 89d4029

File tree

6 files changed

+17
-30
lines changed

6 files changed

+17
-30
lines changed

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#define LLVM_CLANG_SERIALIZATION_MODULEFILE_H
1616

1717
#include "clang/Basic/FileManager.h"
18-
#include "clang/Basic/LLVM.h"
1918
#include "clang/Basic/Module.h"
2019
#include "clang/Basic/SourceLocation.h"
2120
#include "clang/Serialization/ASTBitCodes.h"
@@ -156,8 +155,8 @@ class ModuleFile {
156155
/// The base directory of the module.
157156
std::string BaseDirectory;
158157

159-
static std::string getTimestampFilename(StringRef FileName) {
160-
return (FileName + ".timestamp").str();
158+
std::string getTimestampFilename() const {
159+
return FileName + ".timestamp";
161160
}
162161

163162
/// The original source file name that was used to build the

clang/lib/Serialization/ASTCommon.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
#include "clang/AST/DeclObjC.h"
1616
#include "clang/Basic/IdentifierTable.h"
1717
#include "clang/Serialization/ASTDeserializationListener.h"
18-
#include "clang/Serialization/ModuleFile.h"
1918
#include "llvm/Support/DJB.h"
20-
#include "llvm/Support/FileSystem.h"
21-
#include "llvm/Support/raw_ostream.h"
2219

2320
using namespace clang;
2421

@@ -501,15 +498,3 @@ bool serialization::needsAnonymousDeclarationNumber(const NamedDecl *D) {
501498
return false;
502499
return isa<TagDecl, FieldDecl>(D);
503500
}
504-
505-
void serialization::updateModuleTimestamp(StringRef ModuleFilename) {
506-
// Overwrite the timestamp file contents so that file's mtime changes.
507-
std::error_code EC;
508-
llvm::raw_fd_ostream OS(ModuleFile::getTimestampFilename(ModuleFilename), EC,
509-
llvm::sys::fs::OF_TextWithCRLF);
510-
if (EC)
511-
return;
512-
OS << "Timestamp file\n";
513-
OS.close();
514-
OS.clear_error(); // Avoid triggering a fatal error.
515-
}

clang/lib/Serialization/ASTCommon.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "clang/AST/ASTContext.h"
1717
#include "clang/AST/DeclFriend.h"
18-
#include "clang/Basic/LLVM.h"
1918
#include "clang/Serialization/ASTBitCodes.h"
2019

2120
namespace clang {
@@ -101,8 +100,6 @@ inline bool isPartOfPerModuleInitializer(const Decl *D) {
101100
return false;
102101
}
103102

104-
void updateModuleTimestamp(StringRef ModuleFilename);
105-
106103
} // namespace serialization
107104

108105
} // namespace clang

clang/lib/Serialization/ASTReader.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4408,6 +4408,19 @@ bool ASTReader::isGlobalIndexUnavailable() const {
44084408
!hasGlobalIndex() && TriedLoadingGlobalIndex;
44094409
}
44104410

4411+
static void updateModuleTimestamp(ModuleFile &MF) {
4412+
// Overwrite the timestamp file contents so that file's mtime changes.
4413+
std::string TimestampFilename = MF.getTimestampFilename();
4414+
std::error_code EC;
4415+
llvm::raw_fd_ostream OS(TimestampFilename, EC,
4416+
llvm::sys::fs::OF_TextWithCRLF);
4417+
if (EC)
4418+
return;
4419+
OS << "Timestamp file\n";
4420+
OS.close();
4421+
OS.clear_error(); // Avoid triggering a fatal error.
4422+
}
4423+
44114424
/// Given a cursor at the start of an AST file, scan ahead and drop the
44124425
/// cursor into the start of the given block ID, returning false on success and
44134426
/// true on failure.
@@ -4686,7 +4699,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type,
46864699
ImportedModule &M = Loaded[I];
46874700
if (M.Mod->Kind == MK_ImplicitModule &&
46884701
M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp)
4689-
updateModuleTimestamp(M.Mod->FileName);
4702+
updateModuleTimestamp(*M.Mod);
46904703
}
46914704
}
46924705

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4892,12 +4892,6 @@ ASTFileSignature ASTWriter::WriteAST(Sema &SemaRef, StringRef OutputFile,
48924892
this->BaseDirectory.clear();
48934893

48944894
WritingAST = false;
4895-
4896-
if (WritingModule && SemaRef.PP.getHeaderSearchInfo()
4897-
.getHeaderSearchOpts()
4898-
.ModulesValidateOncePerBuildSession)
4899-
updateModuleTimestamp(OutputFile);
4900-
49014895
if (ShouldCacheASTInMemory) {
49024896
// Construct MemoryBuffer and update buffer manager.
49034897
ModuleCache.addBuiltPCM(OutputFile,

clang/lib/Serialization/ModuleManager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
180180
NewModule->InputFilesValidationTimestamp = 0;
181181

182182
if (NewModule->Kind == MK_ImplicitModule) {
183-
std::string TimestampFilename =
184-
ModuleFile::getTimestampFilename(NewModule->FileName);
183+
std::string TimestampFilename = NewModule->getTimestampFilename();
185184
llvm::vfs::Status Status;
186185
// A cached stat value would be fine as well.
187186
if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))

0 commit comments

Comments
 (0)