aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-10-17 14:55:37 +0000
committerDouglas Gregor <dgregor@apple.com>2011-10-17 14:55:37 +0000
commit05edf668f0984bfa2994ddc8bb7b78d9fb24cf11 (patch)
tree518a104278cc89a71032ba303596fe885ab0f0ed /lib/Frontend/CompilerInvocation.cpp
parentc35cba4a54106117a52b267c7040b3bea9a4d18e (diff)
When building a module, use the macro definitions on the command line
as part of the hash rather than ignoring them. This means we'll end up building more module variants (overall), but it allows configuration macros such as NDEBUG to work so long as they're specified via command line. More to come in this space. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142187 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--lib/Frontend/CompilerInvocation.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 5358106144..1debf3b353 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -2026,6 +2026,23 @@ std::string CompilerInvocation::getModuleHash() const {
Signature.add(getPreprocessorOpts().UsePredefines, 1);
Signature.add(getPreprocessorOpts().DetailedRecord, 1);
+ // Hash the preprocessor defines.
+ // FIXME: This is terrible. Use an MD5 sum of the preprocessor defines.
+ std::vector<StringRef> MacroDefs;
+ for (std::vector<std::pair<std::string, bool/*isUndef*/> >::const_iterator
+ I = getPreprocessorOpts().Macros.begin(),
+ IEnd = getPreprocessorOpts().Macros.end();
+ I != IEnd; ++I) {
+ if (!I->second)
+ MacroDefs.push_back(I->first);
+ }
+ llvm::array_pod_sort(MacroDefs.begin(), MacroDefs.end());
+
+ unsigned PPHashResult = 0;
+ for (unsigned I = 0, N = MacroDefs.size(); I != N; ++I)
+ PPHashResult = llvm::HashString(MacroDefs[I], PPHashResult);
+ Signature.add(PPHashResult, 32);
+
// We've generated the signature. Treat it as one large APInt that we'll
// encode in base-36 and return.
Signature.flush();