Skip to content

Commit d17090c

Browse files
committed
Use the input files block instead
1 parent af6254f commit d17090c

File tree

3 files changed

+19
-43
lines changed

3 files changed

+19
-43
lines changed

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const unsigned VERSION_MAJOR = 34;
5454
/// for the previous version could still support reading the new
5555
/// version by ignoring new kinds of subblocks), this number
5656
/// should be increased.
57-
const unsigned VERSION_MINOR = 1;
57+
const unsigned VERSION_MINOR = 0;
5858

5959
/// An ID number that refers to an identifier in an AST file.
6060
///
@@ -386,10 +386,6 @@ enum ControlRecordTypes {
386386
/// Record code for the (optional) include-tree ID for implicit modules
387387
/// built with the dependency scanner.
388388
CAS_INCLUDE_TREE_ID,
389-
390-
/// Record code for the (optional) modification timestamp of the
391-
/// SDKSettings.json file.
392-
SDK_SETTINGS_JSON_TIMESTAMP,
393389
};
394390

395391
/// Record types that occur within the options block inside

clang/lib/Serialization/ASTReader.cpp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,6 +3134,8 @@ ASTReader::ReadControlBlock(ModuleFile &F,
31343134
for (unsigned I = 0; I < N; ++I) {
31353135
bool IsSystem = I >= NumUserInputs;
31363136
InputFileInfo FI = getInputFileInfo(F, I + 1);
3137+
if (FI.UnresolvedImportedFilename.ends_with("SDKSettings.json"))
3138+
continue;
31373139
auto FilenameAsRequested = ResolveImportedPath(
31383140
PathBuf, FI.UnresolvedImportedFilenameAsRequested, F);
31393141
Listener->visitInputFile(
@@ -3507,29 +3509,6 @@ ASTReader::ReadControlBlock(ModuleFile &F,
35073509
return OutOfDate;
35083510
}
35093511
break;
3510-
3511-
case SDK_SETTINGS_JSON_TIMESTAMP: {
3512-
time_t ExpectedModTime = Record[0];
3513-
time_t ActualModTime = 0;
3514-
StringRef Sysroot =
3515-
PP.getHeaderSearchInfo().getHeaderSearchOpts().Sysroot;
3516-
if (!Sysroot.empty()) {
3517-
SmallString<128> SDKSettingsJSON = Sysroot;
3518-
llvm::sys::path::append(SDKSettingsJSON, "SDKSettings.json");
3519-
if (auto FE = PP.getFileManager().getOptionalFileRef(SDKSettingsJSON))
3520-
ActualModTime = FE->getModificationTime();
3521-
}
3522-
if (ActualModTime && ExpectedModTime &&
3523-
ActualModTime != ExpectedModTime) {
3524-
if (!canRecoverFromOutOfDate(F.FileName, ClientLoadCapabilities))
3525-
Diag(diag::err_fe_ast_file_modified)
3526-
<< "SDKSettings.json" << moduleKindForDiagnostic(F.Kind)
3527-
<< F.FileName << 1 << 1 << llvm::itostr(ExpectedModTime)
3528-
<< llvm::itostr(ActualModTime);
3529-
return OutOfDate;
3530-
}
3531-
break;
3532-
}
35333512
}
35343513
}
35353514
}
@@ -10369,6 +10348,8 @@ void ASTReader::visitInputFileInfos(
1036910348
for (unsigned I = 0; I < N; ++I) {
1037010349
bool IsSystem = I >= NumUserInputs;
1037110350
InputFileInfo IFI = getInputFileInfo(MF, I+1);
10351+
if (IFI.UnresolvedImportedFilename.ends_with("SDKSettings.json"))
10352+
continue;
1037210353
Visitor(IFI, IsSystem);
1037310354
}
1037410355
}
@@ -10384,6 +10365,8 @@ void ASTReader::visitInputFiles(serialization::ModuleFile &MF,
1038410365
for (unsigned I = 0; I < N; ++I) {
1038510366
bool IsSystem = I >= NumUserInputs;
1038610367
InputFile IF = getInputFile(MF, I+1, Complain);
10368+
if (IF.getFile() && IF.getFile()->getName().ends_with("SDKSettings.json"))
10369+
continue;
1038710370
Visitor(IF, IsSystem);
1038810371
}
1038910372
}

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ void ASTWriter::WriteBlockInfoBlock() {
917917
RECORD(MODULE_CACHE_KEY);
918918
RECORD(CASFS_ROOT_ID);
919919
RECORD(CAS_INCLUDE_TREE_ID);
920-
RECORD(SDK_SETTINGS_JSON_TIMESTAMP);
921920

922921
BLOCK(OPTIONS_BLOCK);
923922
RECORD(LANGUAGE_OPTIONS);
@@ -1616,20 +1615,6 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, StringRef isysroot) {
16161615
Stream.EmitRecordWithBlob(AbbrevCode, Record, *ID);
16171616
}
16181617

1619-
time_t SDKSettingsModTime = 0;
1620-
StringRef Sysroot = PP.getHeaderSearchInfo().getHeaderSearchOpts().Sysroot;
1621-
if (!Sysroot.empty()) {
1622-
SmallString<128> SDKSettingsJSON = Sysroot;
1623-
llvm::sys::path::append(SDKSettingsJSON, "SDKSettings.json");
1624-
if (auto FE = PP.getFileManager().getOptionalFileRef(SDKSettingsJSON))
1625-
SDKSettingsModTime = FE->getModificationTime();
1626-
}
1627-
if (SDKSettingsModTime) {
1628-
Record.clear();
1629-
Record.push_back(SDKSettingsModTime);
1630-
Stream.EmitRecord(SDK_SETTINGS_JSON_TIMESTAMP, Record);
1631-
}
1632-
16331618
// Imports
16341619
if (Chain) {
16351620
auto Abbrev = std::make_shared<BitCodeAbbrev>();
@@ -5965,6 +5950,18 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,
59655950
if (Chain)
59665951
Chain->finalizeForWriting();
59675952

5953+
// FIXME: This is here because the include-tree file list refers to this file
5954+
// and we need to validate it's up-to-date when reading the AST file. Make
5955+
// this more generic and include the remaining files.
5956+
StringRef Sysroot = PP->getHeaderSearchInfo().getHeaderSearchOpts().Sysroot;
5957+
if (!Sysroot.empty()) {
5958+
SmallString<128> SDKSettingsJSON = Sysroot;
5959+
llvm::sys::path::append(SDKSettingsJSON, "SDKSettings.json");
5960+
if (auto FE = PP->getFileManager().getOptionalFileRef(SDKSettingsJSON))
5961+
PP->getSourceManager().createFileID(*FE, SourceLocation(),
5962+
SrcMgr::C_System);
5963+
}
5964+
59685965
// This needs to be done very early, since everything that writes
59695966
// SourceLocations or FileIDs depends on it.
59705967
computeNonAffectingInputFiles();

0 commit comments

Comments
 (0)