Skip to content

[clang] Improve module out of date error message #128103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

Bigcheese
Copy link
Contributor

When a pcm file has a different size or modification time than it had when it was written to another module's IMPORT table Clang emits:

<pcm> is out of date and needs to be rebuilt: module file out of date

This is difficult to understand what's happening because there are a lot of reasons that a module file can be out of date. This changes the latter part of that message to:

module file has a different size or mtime than expected

Which makes it clearer what the issue is. For future work it would be nice if a more detailed explanation of the issue could be emitted as a note instead.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:modules C++20 modules and Clang Header Modules labels Feb 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 21, 2025

@llvm/pr-subscribers-clang-modules

Author: Michael Spencer (Bigcheese)

Changes

When a pcm file has a different size or modification time than it had when it was written to another module's IMPORT table Clang emits:

&lt;pcm&gt; is out of date and needs to be rebuilt: module file out of date

This is difficult to understand what's happening because there are a lot of reasons that a module file can be out of date. This changes the latter part of that message to:

module file has a different size or mtime than expected

Which makes it clearer what the issue is. For future work it would be nice if a more detailed explanation of the issue could be emitted as a note instead.


Full diff: https://github.com/llvm/llvm-project/pull/128103.diff

1 Files Affected:

  • (modified) clang/lib/Serialization/ModuleManager.cpp (+1-1)
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index ba78c9ef5af67..4ecb776513d6f 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -119,7 +119,7 @@ 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 out of date";
+    ErrorStr = "module file has a different size or mtime than expected";
     return OutOfDate;
   }
 

@llvmbot
Copy link
Member

llvmbot commented Feb 21, 2025

@llvm/pr-subscribers-clang

Author: Michael Spencer (Bigcheese)

Changes

When a pcm file has a different size or modification time than it had when it was written to another module's IMPORT table Clang emits:

&lt;pcm&gt; is out of date and needs to be rebuilt: module file out of date

This is difficult to understand what's happening because there are a lot of reasons that a module file can be out of date. This changes the latter part of that message to:

module file has a different size or mtime than expected

Which makes it clearer what the issue is. For future work it would be nice if a more detailed explanation of the issue could be emitted as a note instead.


Full diff: https://github.com/llvm/llvm-project/pull/128103.diff

1 Files Affected:

  • (modified) clang/lib/Serialization/ModuleManager.cpp (+1-1)
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index ba78c9ef5af67..4ecb776513d6f 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -119,7 +119,7 @@ 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 out of date";
+    ErrorStr = "module file has a different size or mtime than expected";
     return OutOfDate;
   }
 

Copy link
Member

@ChuanqiXu9 ChuanqiXu9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you like to add a test?

When a pcm file has a different size or modification time than it had
when it was written to another module's IMPORT table Clang emits:

`<pcm> is out of date and needs to be rebuilt: module file out of date`

This is difficult to understand what's happening because there are a
lot of reasons that a module file can be out of date. This changes
the latter part of that message to:

`module file has a different size or mtime than expected`

Which makes it clearer what the issue is. For future work it would be
nice if a more detailed explanation of the issue could be emitted as a
note instead.
@Bigcheese Bigcheese force-pushed the dev/module-out-of-date branch from a0a129c to d33995d Compare February 21, 2025 19:09
@Bigcheese Bigcheese requested a review from ChuanqiXu9 February 21, 2025 19:09
@Bigcheese
Copy link
Contributor Author

Fixed the missing test change.

@Bigcheese Bigcheese merged commit be5c66d into llvm:main Feb 24, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants