diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2019-10-21 22:51:13 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2019-10-21 22:51:13 +0000 |
commit | 8896d073b1900d34dda4cade101409d08dc0f7dd (patch) | |
tree | 371a29d1bc7df9e9526ef06948dbe4154b6b3af1 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | e57fe85a599a8cc4990d6f4605f86b89dcb952b3 (diff) | |
download | bcm5719-llvm-8896d073b1900d34dda4cade101409d08dc0f7dd.tar.gz bcm5719-llvm-8896d073b1900d34dda4cade101409d08dc0f7dd.zip |
[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.
llvm-svn: 375466
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 0aa44252c6c..665695ec3b1 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/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); |