Author: Cyndy Ishida
Date: 2025-04-23T10:55:39-07:00
New Revision: 3c9027c1d7aac0c1e54af13182f1b8f58d376115

URL: 
https://github.com/llvm/llvm-project/commit/3c9027c1d7aac0c1e54af13182f1b8f58d376115
DIFF: 
https://github.com/llvm/llvm-project/commit/3c9027c1d7aac0c1e54af13182f1b8f58d376115.diff

LOG: [clang][Modules] Clarify error message when size check fails in 
lookupModuleFile

Added: 
    

Modified: 
    clang/lib/Serialization/ModuleManager.cpp
    clang/test/Modules/explicit-build.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Serialization/ModuleManager.cpp 
b/clang/lib/Serialization/ModuleManager.cpp
index 61c4e9ed88e9d..d466ea06301a6 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -110,7 +110,9 @@ ModuleManager::addModule(StringRef FileName, ModuleKind 
Type,
   // Look for the file entry. This only fails if the expected size or
   // modification time 
diff er.
   OptionalFileEntryRef Entry;
-  if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
+  const bool IgnoreModTime =
+      (Type == MK_ExplicitModule || Type == MK_PrebuiltModule);
+  if (IgnoreModTime) {
     // If we're not expecting to pull this file out of the module cache, it
     // might have a 
diff erent mtime due to being moved across filesystems in
     // a distributed build. The size must still match, though. (As must the
@@ -120,7 +122,9 @@ ModuleManager::addModule(StringRef FileName, ModuleKind 
Type,
   // Note: ExpectedSize and ExpectedModTime will be 0 for MK_ImplicitModule
   // when using an ASTFileSignature.
   if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) {
-    ErrorStr = "module file has a 
diff erent size or mtime than expected";
+    ErrorStr = IgnoreModTime
+                   ? "module file has a 
diff erent size than expected"
+                   : "module file has a 
diff erent size or mtime than expected";
     return OutOfDate;
   }
 

diff  --git a/clang/test/Modules/explicit-build.cpp 
b/clang/test/Modules/explicit-build.cpp
index fb65508ccf091..50bba0d09966a 100644
--- a/clang/test/Modules/explicit-build.cpp
+++ b/clang/test/Modules/explicit-build.cpp
@@ -199,6 +199,6 @@
 // RUN:            -fmodule-file=%t/c.pcm \
 // RUN:            %s -DHAVE_A -DHAVE_B -DHAVE_C 2>&1 | FileCheck 
--check-prefix=CHECK-MISMATCHED-B %s
 //
-// CHECK-MISMATCHED-B:      fatal error: module file '{{.*}}b.pcm' is out of 
date and needs to be rebuilt: module file has a 
diff erent size or mtime than expected
+// CHECK-MISMATCHED-B:      fatal error: module file '{{.*}}b.pcm' is out of 
date and needs to be rebuilt: module file has a 
diff erent size than expected
 // CHECK-MISMATCHED-B-NEXT: note: imported by module 'c'
 // CHECK-MISMATCHED-B-NOT:  note:


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to