Author: Chuanqi Xu Date: 2024-09-26T15:59:02+08:00 New Revision: e7569b30861cce7064fdc7b0e3ad1ee80fbc1fa7
URL: https://github.com/llvm/llvm-project/commit/e7569b30861cce7064fdc7b0e3ad1ee80fbc1fa7 DIFF: https://github.com/llvm/llvm-project/commit/e7569b30861cce7064fdc7b0e3ad1ee80fbc1fa7.diff LOG: [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. Added: Modified: clang/include/clang/Serialization/ModuleFile.h Removed: ################################################################################ diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h index 3e920c0f683601..30e7f6b3e57bd8 100644 --- a/clang/include/clang/Serialization/ModuleFile.h +++ b/clang/include/clang/Serialization/ModuleFile.h @@ -88,13 +88,13 @@ class InputFile { InputFile(FileEntryRef File, bool isOverridden = false, bool isOutOfDate = false) { - assert(!(isOverridden && isOutOfDate) && - "an overridden cannot be out-of-date"); unsigned intVal = 0; - if (isOverridden) - intVal = Overridden; - else if (isOutOfDate) + // Make isOutOfDate with higher priority than isOverridden. + // It is possible if the recorded hash value mismatches. + if (isOutOfDate) intVal = OutOfDate; + else if (isOverridden) + intVal = Overridden; Val.setPointerAndInt(&File.getMapEntry(), intVal); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits