@@ -2380,46 +2380,55 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
2380
2380
}
2381
2381
}
2382
2382
2383
- enum ModificationType {
2384
- Size,
2385
- ModTime,
2386
- Content,
2387
- None,
2383
+ struct Change {
2384
+ enum ModificationKind {
2385
+ Size,
2386
+ ModTime,
2387
+ Content,
2388
+ None,
2389
+ } Kind;
2390
+ llvm::Optional<int64_t > Old = llvm::None;
2391
+ llvm::Optional<int64_t > New = llvm::None;
2388
2392
};
2389
2393
auto HasInputFileChanged = [&]() {
2390
2394
if (StoredSize != File->getSize ())
2391
- return ModificationType ::Size;
2395
+ return Change{Change ::Size, StoredSize, File-> getSize ()} ;
2392
2396
if (!shouldDisableValidationForFile (F) && StoredTime &&
2393
2397
StoredTime != File->getModificationTime ()) {
2398
+ Change MTimeChange = {Change::ModTime, StoredTime,
2399
+ File->getModificationTime ()};
2400
+
2394
2401
// In case the modification time changes but not the content,
2395
2402
// accept the cached file as legit.
2396
2403
if (ValidateASTInputFilesContent &&
2397
2404
StoredContentHash != static_cast <uint64_t >(llvm::hash_code (-1 ))) {
2398
2405
auto MemBuffOrError = FileMgr.getBufferForFile (File);
2399
2406
if (!MemBuffOrError) {
2400
2407
if (!Complain)
2401
- return ModificationType::ModTime ;
2408
+ return MTimeChange ;
2402
2409
std::string ErrorStr = " could not get buffer for file '" ;
2403
2410
ErrorStr += File->getName ();
2404
2411
ErrorStr += " '" ;
2405
2412
Error (ErrorStr);
2406
- return ModificationType::ModTime ;
2413
+ return MTimeChange ;
2407
2414
}
2408
2415
2416
+ // FIXME: hash_value is not guaranteed to be stable!
2409
2417
auto ContentHash = hash_value (MemBuffOrError.get ()->getBuffer ());
2410
2418
if (StoredContentHash == static_cast <uint64_t >(ContentHash))
2411
- return ModificationType::None;
2412
- return ModificationType::Content;
2419
+ return Change{Change::None};
2420
+
2421
+ return Change{Change::Content};
2413
2422
}
2414
- return ModificationType::ModTime ;
2423
+ return MTimeChange ;
2415
2424
}
2416
- return ModificationType ::None;
2425
+ return Change{Change ::None} ;
2417
2426
};
2418
2427
2419
2428
bool IsOutOfDate = false ;
2420
2429
auto FileChange = HasInputFileChanged ();
2421
2430
// For an overridden file, there is nothing to validate.
2422
- if (!Overridden && FileChange != ModificationType ::None) {
2431
+ if (!Overridden && FileChange. Kind != Change ::None) {
2423
2432
if (Complain && !Diags.isDiagnosticInFlight ()) {
2424
2433
// Build a list of the PCH imports that got us here (in reverse).
2425
2434
SmallVector<ModuleFile *, 4 > ImportStack (1 , &F);
@@ -2430,7 +2439,10 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
2430
2439
StringRef TopLevelPCHName (ImportStack.back ()->FileName );
2431
2440
Diag (diag::err_fe_ast_file_modified)
2432
2441
<< Filename << moduleKindForDiagnostic (ImportStack.back ()->Kind )
2433
- << TopLevelPCHName << FileChange;
2442
+ << TopLevelPCHName << FileChange.Kind
2443
+ << (FileChange.Old && FileChange.New )
2444
+ << llvm::itostr (FileChange.Old .getValueOr (0 ))
2445
+ << llvm::itostr (FileChange.New .getValueOr (0 ));
2434
2446
2435
2447
// Print the import stack.
2436
2448
if (ImportStack.size () > 1 ) {
0 commit comments