From f52442d598d72a092a6840b45faa439d179caf77 Mon Sep 17 00:00:00 2001 From: Michael Spencer Date: Tue, 7 Jul 2020 17:13:02 -0600 Subject: [PATCH] [clang] Include missing LangOpts in `getModuleHash`. `ObjCRuntime` and `CommentOpts.BlockCommandNames` are checked by `ASTReader::checkLanguageOptions`, but are not part of the module context hash. This can lead to errors when using implicit modules if different TUs have different values for these options when using the same module cache. This was not hit very often due to the rare usage of `-fblock-command-names=` and that `ObjCRuntime` is by default set by the target triple, which is part of the existing context hash. --- include/llvm/Support/VersionTuple.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/llvm/Support/VersionTuple.h b/include/llvm/Support/VersionTuple.h index ad89e40f0f1..6f3711f06f1 100644 --- a/include/llvm/Support/VersionTuple.h +++ b/include/llvm/Support/VersionTuple.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_VERSIONTUPLE_H #define LLVM_SUPPORT_VERSIONTUPLE_H +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/Optional.h" #include #include @@ -144,6 +145,10 @@ public: return !(X < Y); } + friend llvm::hash_code hash_value(const VersionTuple &VT) { + return llvm::hash_combine(VT.Major, VT.Minor, VT.Subminor, VT.Build); + } + /// Retrieve a string representation of the version number. std::string getAsString() const;