Change the hashing function for DeclContext lookup within an AST file
by eliminating the type ID from constructor, destructor, and
conversion function names. There are several reasons for this change:
- A given type (say, int*) isn't guaranteed to have a single, unique
type ID within a chain of PCH files. Hence, we could end up hashing
based on the wrong type ID, causing name lookup to fail.
- The mapping from types back to type IDs required one DenseMap
entry for every type that was ever deserialized, which was an
unacceptable cost to support just the name lookup of constructors,
destructors, and conversion functions. Plus, this mapping could
never actually work with chained or multiple PCH, based on the first
bullet.
Once we have eliminated the type from the hash function, these
problems go away, as does my horrible "reverse type remap" hack, which
was doomed from the start (see bullet #1 above) and far too
complicated.
However, note that removing the type from the hash function means that
all constructors, destructors, and conversion functions have the same
hash key, so I've updated the caller to double-check that the
declarations found have the appropriate name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136708 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/PCH/chain-conversion-lookup.cpp b/test/PCH/chain-conversion-lookup.cpp
new file mode 100644
index 0000000..db9d8fc
--- /dev/null
+++ b/test/PCH/chain-conversion-lookup.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -chain-include %s -chain-include %s
+
+#if !defined(PASS1)
+#define PASS1
+struct X {
+ operator int*();
+};
+
+struct Z {
+ operator int*();
+};
+#elif !defined(PASS2)
+#define PASS2
+struct Y {
+ operator int *();
+};
+#else
+int main() {
+ X x;
+ int *ip = x.operator int*();
+ Y y;
+ int *ip2 = y.operator int*();
+ Z z;
+ int *ip3 = z.operator int*();
+}
+#endif