Skip to content

Commit 3c9027c

Browse files
authored
[clang][Modules] Clarify error message when size check fails in lookupModuleFile
1 parent 0f5965f commit 3c9027c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clang/lib/Serialization/ModuleManager.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
110110
// Look for the file entry. This only fails if the expected size or
111111
// modification time differ.
112112
OptionalFileEntryRef Entry;
113-
if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
113+
const bool IgnoreModTime =
114+
(Type == MK_ExplicitModule || Type == MK_PrebuiltModule);
115+
if (IgnoreModTime) {
114116
// If we're not expecting to pull this file out of the module cache, it
115117
// might have a different mtime due to being moved across filesystems in
116118
// a distributed build. The size must still match, though. (As must the
@@ -120,7 +122,9 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
120122
// Note: ExpectedSize and ExpectedModTime will be 0 for MK_ImplicitModule
121123
// when using an ASTFileSignature.
122124
if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) {
123-
ErrorStr = "module file has a different size or mtime than expected";
125+
ErrorStr = IgnoreModTime
126+
? "module file has a different size than expected"
127+
: "module file has a different size or mtime than expected";
124128
return OutOfDate;
125129
}
126130

clang/test/Modules/explicit-build.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,6 @@
199199
// RUN: -fmodule-file=%t/c.pcm \
200200
// RUN: %s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck --check-prefix=CHECK-MISMATCHED-B %s
201201
//
202-
// CHECK-MISMATCHED-B: fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: module file has a different size or mtime than expected
202+
// CHECK-MISMATCHED-B: fatal error: module file '{{.*}}b.pcm' is out of date and needs to be rebuilt: module file has a different size than expected
203203
// CHECK-MISMATCHED-B-NEXT: note: imported by module 'c'
204204
// CHECK-MISMATCHED-B-NOT: note:

0 commit comments

Comments
 (0)