aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-01-22 10:34:34 -0500
committerNico Weber <thakis@chromium.org>2020-01-27 22:08:37 -0500
commit49532137d087d8053789d18540c5e7916b91ef30 (patch)
tree87f560a52e330b3165f21b92a4fd564361f4e82a /clang/lib/Frontend/CompilerInvocation.cpp
parentaf80b8ccc5772c14920d4554b7ca7e15f2fad1c4 (diff)
downloadllvm-49532137d087d8053789d18540c5e7916b91ef30.zip
llvm-49532137d087d8053789d18540c5e7916b91ef30.tar.gz
llvm-49532137d087d8053789d18540c5e7916b91ef30.tar.bz2
Make AST reading work better with LLVM_APPEND_VC_REV=NO
With LLVM_APPEND_VC_REV=NO, Modules/merge-lifetime-extended-temporary.cpp would fail if it ran before a0f50d731639350c7a7 (which changed the serialization format) and then after, for these reasons: 1. With LLVM_APPEND_VC_REV=NO, the module hash before and after the change was the same. 2. Modules/merge-lifetime-extended-temporary.cpp is the only test we have that uses -fmodule-cache-path=%t that a) actually writes to the cache path b) doesn't do `rm -rf %t` at the top of the test So the old run would write a module file, and then the new run would try to load it, but the serialized format changed. Do several things to fix this: 1. Include clang::serialization::VERSION_MAJOR/VERSION_MINOR in the module hash, so that when the AST format changes (...and we remember to bump these), we use a different module cache dir. 2. Bump VERSION_MAJOR, since a0f50d731639350c7a7 changed the on-disk format in a way that a gch file written before that change can't be read after that change. 3. Add `rm -rf %t` to all tests that pass -fmodule-cache-path=%t. This is unnecessary from a correctness PoV after 1 and 2, but makes it so that we don't amass many cache dirs over time. (Arguably, it also makes it so that the test suite doesn't catch when we change the serialization format but don't bump clang::serialization::VERSION_MAJOR/VERSION_MINOR; oh well.) Differential Revision: https://reviews.llvm.org/D73202
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index eb1c50f..b3733a2 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -41,6 +41,7 @@
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Sema/CodeCompleteOptions.h"
+#include "clang/Serialization/ASTBitCodes.h"
#include "clang/Serialization/ModuleFileExtension.h"
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "llvm/ADT/APInt.h"
@@ -3635,6 +3636,11 @@ std::string CompilerInvocation::getModuleHash() const {
// CityHash, but this will do for now.
hash_code code = hash_value(getClangFullRepositoryVersion());
+ // Also include the serialization version, in case LLVM_APPEND_VC_REV is off
+ // and getClangFullRepositoryVersion() doesn't include git revision.
+ code = hash_combine(code, serialization::VERSION_MAJOR,
+ serialization::VERSION_MINOR);
+
// Extend the signature with the language options
#define LANGOPT(Name, Bits, Default, Description) \
code = hash_combine(code, LangOpts->Name);