Skip to content

Commit e7569b3

Browse files
committed
[clang] [Modules] Don't assume an overriden module file can not be out-of-date
There is an assertion in ModuleFile assumes that an overriden module file can't be out of date. But it is not seriously true in the case clangd. e.g., the source files are overriden, but clangd relies on if the files are out of date to trigger rebuilding preamble. And techniquely, overriden doesn't imply it can't be out of date. This was found during the use clangd of a large code base with modules. Although I failed to reproduce an example, I feel it is fine to land this directly for this particular case.
1 parent ae54a00 commit e7569b3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ class InputFile {
8888

8989
InputFile(FileEntryRef File, bool isOverridden = false,
9090
bool isOutOfDate = false) {
91-
assert(!(isOverridden && isOutOfDate) &&
92-
"an overridden cannot be out-of-date");
9391
unsigned intVal = 0;
94-
if (isOverridden)
95-
intVal = Overridden;
96-
else if (isOutOfDate)
92+
// Make isOutOfDate with higher priority than isOverridden.
93+
// It is possible if the recorded hash value mismatches.
94+
if (isOutOfDate)
9795
intVal = OutOfDate;
96+
else if (isOverridden)
97+
intVal = Overridden;
9898
Val.setPointerAndInt(&File.getMapEntry(), intVal);
9999
}
100100

0 commit comments

Comments
 (0)