aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2019-10-21 22:51:13 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2019-10-21 22:51:13 +0000
commit5d899f7d95c13ea08fae3aba3280a902f2834e23 (patch)
tree991b2e149e78f6d36830c475cb99e4f4f9acea7c /lib
parent73e476646bdaeb2ad2d40254ce64c2dfe8c78873 (diff)
[Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics.
This is a recommit of r375322 and r375327 with a fix for the Windows test breakage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@375466 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Frontend/CompilerInvocation.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 0aa44252c6..665695ec3b 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -2067,6 +2067,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
Opts.AddPrebuiltModulePath(A->getValue());
Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
Opts.ModulesHashContent = Args.hasArg(OPT_fmodules_hash_content);
+ Opts.ModulesStrictContextHash = Args.hasArg(OPT_fmodules_strict_context_hash);
Opts.ModulesValidateDiagnosticOptions =
!Args.hasArg(OPT_fmodules_disable_diagnostic_validation);
Opts.ImplicitModuleMaps = Args.hasArg(OPT_fimplicit_module_maps);
@@ -3546,6 +3547,7 @@ std::string CompilerInvocation::getModuleHash() const {
using llvm::hash_code;
using llvm::hash_value;
using llvm::hash_combine;
+ using llvm::hash_combine_range;
// Start the signature with the compiler version.
// FIXME: We'd rather use something more cryptographically sound than
@@ -3600,6 +3602,24 @@ std::string CompilerInvocation::getModuleHash() const {
hsOpts.ModulesValidateDiagnosticOptions);
code = hash_combine(code, hsOpts.ResourceDir);
+ if (hsOpts.ModulesStrictContextHash) {
+ hash_code SHPC = hash_combine_range(hsOpts.SystemHeaderPrefixes.begin(),
+ hsOpts.SystemHeaderPrefixes.end());
+ hash_code UEC = hash_combine_range(hsOpts.UserEntries.begin(),
+ hsOpts.UserEntries.end());
+ code = hash_combine(code, hsOpts.SystemHeaderPrefixes.size(), SHPC,
+ hsOpts.UserEntries.size(), UEC);
+
+ const DiagnosticOptions &diagOpts = getDiagnosticOpts();
+ #define DIAGOPT(Name, Bits, Default) \
+ code = hash_combine(code, diagOpts.Name);
+ #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+ code = hash_combine(code, diagOpts.get##Name());
+ #include "clang/Basic/DiagnosticOptions.def"
+ #undef DIAGOPT
+ #undef ENUM_DIAGOPT
+ }
+
// Extend the signature with the user build path.
code = hash_combine(code, hsOpts.ModuleUserBuildPath);