]> granicus.if.org Git - clang/commit
Change the hashing function for DeclContext lookup within an AST file
authorDouglas Gregor <dgregor@apple.com>
Tue, 2 Aug 2011 18:32:54 +0000 (18:32 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 2 Aug 2011 18:32:54 +0000 (18:32 +0000)
commite36050111e2bdb7efc014af9dd7f0009b492ac36
tree28823d51acd1ac12fcdcf5b378fb884fb53c4920
parentff8e758c30b86628a6cdaa6f1b089fefbbdba40c
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
include/clang/Serialization/ASTBitCodes.h
include/clang/Serialization/ASTReader.h
include/clang/Serialization/ASTWriter.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp
test/PCH/chain-conversion-lookup.cpp [new file with mode: 0644]