198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//===--- ASTReaderInternals.h - AST Reader Internals ------------*- C++ -*-===//
298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//
398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//                     The LLVM Compiler Infrastructure
498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//
598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor// This file is distributed under the University of Illinois Open Source
698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor// License. See LICENSE.TXT for details.
798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//
898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//===----------------------------------------------------------------------===//
998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//
1098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//  This file provides internal definitions used in the AST reader.
1198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//
1298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor//===----------------------------------------------------------------------===//
1398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_INTERNALS_H
1498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#define LLVM_CLANG_SERIALIZATION_ASTREADER_INTERNALS_H
1598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
1698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#include "clang/Basic/OnDiskHashTable.h"
1798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#include "clang/AST/DeclarationName.h"
189b8b20f7a4e2d2557fc49149ebd0df7a7b2c57ddDouglas Gregor#include "llvm/Support/Endian.h"
1998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#include <utility>
2098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#include <sys/stat.h>
2198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
2298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregornamespace clang {
2398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
2498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorclass ASTReader;
2598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorclass HeaderSearch;
2698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorstruct HeaderFileInfo;
2798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
2898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregornamespace serialization {
2998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
301a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregorclass ModuleFile;
3198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
3298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregornamespace reader {
3398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
3498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// \brief Class that performs name lookup into a DeclContext stored
3598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// in an AST file.
3698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorclass ASTDeclContextNameLookupTrait {
3798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ASTReader &Reader;
381a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  ModuleFile &F;
3998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
4098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorpublic:
4198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  /// \brief Pair of begin/end iterators for DeclIDs.
4298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ///
4398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  /// Note that these declaration IDs are local to the module that contains this
4498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  /// particular lookup t
459b8b20f7a4e2d2557fc49149ebd0df7a7b2c57ddDouglas Gregor  typedef llvm::support::ulittle32_t LE32DeclID;
469b8b20f7a4e2d2557fc49149ebd0df7a7b2c57ddDouglas Gregor  typedef std::pair<LE32DeclID *, LE32DeclID *> data_type;
4798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
4898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  /// \brief Special internal key for declaration names.
4998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  /// The hash table creates keys for comparison; we do not create
5098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  /// a DeclarationName for the internal key to avoid deserializing types.
5198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  struct DeclNameKey {
5298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    DeclarationName::NameKind Kind;
5398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    uint64_t Data;
5498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    DeclNameKey() : Kind((DeclarationName::NameKind)0), Data(0) { }
5598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  };
5698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
5798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef DeclarationName external_key_type;
5898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef DeclNameKey internal_key_type;
5998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
60b346d2f419ec7d7ce6b20780d518490338efa7deNick Lewycky  explicit ASTDeclContextNameLookupTrait(ASTReader &Reader, ModuleFile &F)
6198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    : Reader(Reader), F(F) { }
6298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
6398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static bool EqualKey(const internal_key_type& a,
6498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                       const internal_key_type& b) {
6598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    return a.Kind == b.Kind && a.Data == b.Data;
6698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  }
6798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
6898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  unsigned ComputeHash(const DeclNameKey &Key) const;
6998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  internal_key_type GetInternalKey(const external_key_type& Name) const;
7098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
71b346d2f419ec7d7ce6b20780d518490338efa7deNick Lewycky  static std::pair<unsigned, unsigned>
7298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ReadKeyDataLength(const unsigned char*& d);
7398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
7498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  internal_key_type ReadKey(const unsigned char* d, unsigned);
7598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
7698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  data_type ReadData(internal_key_type, const unsigned char* d,
7798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                     unsigned DataLen);
7898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor};
7998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
8098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// \brief Class that performs lookup for an identifier stored in an AST file.
8198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorclass ASTIdentifierLookupTrait {
8298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ASTReader &Reader;
831a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  ModuleFile &F;
8498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
8598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  // If we know the IdentifierInfo in advance, it is here and we will
8698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  // not build a new one. Used when deserializing information about an
8798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  // identifier that was constructed before the AST file was read.
8898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  IdentifierInfo *KnownII;
8998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
9098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorpublic:
9198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef IdentifierInfo * data_type;
9298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
9398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef const std::pair<const char*, unsigned> external_key_type;
9498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
9598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef external_key_type internal_key_type;
9698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
971a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  ASTIdentifierLookupTrait(ASTReader &Reader, ModuleFile &F,
9898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                           IdentifierInfo *II = 0)
9998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    : Reader(Reader), F(F), KnownII(II) { }
10098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
10198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static bool EqualKey(const internal_key_type& a,
10298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                       const internal_key_type& b) {
10398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    return (a.second == b.second) ? memcmp(a.first, b.first, a.second) == 0
10498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    : false;
10598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  }
10698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
10798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static unsigned ComputeHash(const internal_key_type& a);
10898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
10998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  // This hopefully will just get inlined and removed by the optimizer.
11098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static const internal_key_type&
11198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  GetInternalKey(const external_key_type& x) { return x; }
11298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
11398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  // This hopefully will just get inlined and removed by the optimizer.
11498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static const external_key_type&
11598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  GetExternalKey(const internal_key_type& x) { return x; }
11698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
11798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static std::pair<unsigned, unsigned>
11898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ReadKeyDataLength(const unsigned char*& d);
11998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
12098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static std::pair<const char*, unsigned>
12198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ReadKey(const unsigned char* d, unsigned n);
12298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
12398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  IdentifierInfo *ReadData(const internal_key_type& k,
12498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                           const unsigned char* d,
12598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                           unsigned DataLen);
1265d5051f3e79bf754134ccdf7a1dc7778cd80c73eDouglas Gregor
1275d5051f3e79bf754134ccdf7a1dc7778cd80c73eDouglas Gregor  ASTReader &getReader() const { return Reader; }
1285d5051f3e79bf754134ccdf7a1dc7778cd80c73eDouglas Gregor
12998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor};
13098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
13198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// \brief The on-disk hash table used to contain information about
13298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// all of the identifiers in the program.
13398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregortypedef OnDiskChainedHashTable<ASTIdentifierLookupTrait>
13498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ASTIdentifierLookupTable;
13598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
13698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// \brief Class that performs lookup for a selector's entries in the global
13798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// method pool stored in an AST file.
13898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorclass ASTSelectorLookupTrait {
13998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ASTReader &Reader;
1401a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  ModuleFile &F;
14198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
14298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorpublic:
14398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  struct data_type {
14498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    SelectorID ID;
14598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    llvm::SmallVector<ObjCMethodDecl *, 2> Instance;
14698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    llvm::SmallVector<ObjCMethodDecl *, 2> Factory;
14798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  };
14898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
14998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef Selector external_key_type;
15098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef external_key_type internal_key_type;
15198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
1521a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  ASTSelectorLookupTrait(ASTReader &Reader, ModuleFile &F)
15398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    : Reader(Reader), F(F) { }
15498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
15598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static bool EqualKey(const internal_key_type& a,
15698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                       const internal_key_type& b) {
15798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    return a == b;
15898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  }
15998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
16098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static unsigned ComputeHash(Selector Sel);
16198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
16298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static const internal_key_type&
163a2f4ae8cfa5659158e195e10b0fc934102792de6Chris Lattner  GetInternalKey(const external_key_type& x) { return x; }
16498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
16598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static std::pair<unsigned, unsigned>
16698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ReadKeyDataLength(const unsigned char*& d);
16798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
16898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  internal_key_type ReadKey(const unsigned char* d, unsigned);
16998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  data_type ReadData(Selector, const unsigned char* d, unsigned DataLen);
17098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor};
17198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
17298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// \brief The on-disk hash table used for the global method pool.
17398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregortypedef OnDiskChainedHashTable<ASTSelectorLookupTrait>
17498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ASTSelectorLookupTable;
17598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
17698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// \brief Trait class used to search the on-disk hash table containing all of
17798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// the header search information.
17898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor///
17998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// The on-disk hash table contains a mapping from each header path to
18098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// information about that header (how many times it has been included, its
18198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// controlling macro, etc.). Note that we actually hash based on the
18298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// filename, and support "deep" comparisons of file names based on current
18398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// inode numbers, so that the search can cope with non-normalized path names
18498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// and symlinks.
18598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorclass HeaderFileInfoTrait {
18698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ASTReader &Reader;
1871a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  ModuleFile &M;
18898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  HeaderSearch *HS;
18998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  const char *FrameworkStrings;
19098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  const char *SearchPath;
19198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  struct stat SearchPathStatBuf;
19298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  llvm::Optional<int> SearchPathStatResult;
19398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
19498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  int StatSimpleCache(const char *Path, struct stat *StatBuf) {
19598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    if (Path == SearchPath) {
19698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor      if (!SearchPathStatResult)
19798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor        SearchPathStatResult = stat(Path, &SearchPathStatBuf);
19898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
19998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor      *StatBuf = SearchPathStatBuf;
20098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor      return *SearchPathStatResult;
20198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    }
20298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
20398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    return stat(Path, StatBuf);
20498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  }
20598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
20698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregorpublic:
20798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef const char *external_key_type;
20898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef const char *internal_key_type;
20998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
21098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  typedef HeaderFileInfo data_type;
21198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
2121a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor  HeaderFileInfoTrait(ASTReader &Reader, ModuleFile &M, HeaderSearch *HS,
21398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                      const char *FrameworkStrings,
21498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                      const char *SearchPath = 0)
21598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  : Reader(Reader), M(M), HS(HS), FrameworkStrings(FrameworkStrings),
21698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    SearchPath(SearchPath) { }
21798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
21898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static unsigned ComputeHash(const char *path);
21998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static internal_key_type GetInternalKey(const char *path);
22098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  bool EqualKey(internal_key_type a, internal_key_type b);
22198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
22298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static std::pair<unsigned, unsigned>
22398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  ReadKeyDataLength(const unsigned char*& d);
22498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
22598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  static internal_key_type ReadKey(const unsigned char *d, unsigned) {
22698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor    return (const char *)d;
22798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  }
22898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
22998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  data_type ReadData(const internal_key_type, const unsigned char *d,
23098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor                     unsigned DataLen);
23198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor};
23298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
23398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor/// \brief The on-disk hash table used for known header files.
23498339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregortypedef OnDiskChainedHashTable<HeaderFileInfoTrait>
23598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor  HeaderFileInfoLookupTable;
23698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
23798339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor} // end namespace clang::serialization::reader
23898339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor} // end namespace clang::serialization
23998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor} // end namespace clang
24098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
24198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor
24298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#endif
243