diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-03-06 18:12:47 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-03-06 18:12:47 +0000 |
commit | ed3802e5da6e7d41975b1cb3d7ae3a3b9e855d10 (patch) | |
tree | 71690b8e28318bae5160be0f3b7f2cd765638e61 /lib/Serialization/ASTReaderInternals.h | |
parent | 36592b1fa381a978b1b6d4b97c66fb274915fe50 (diff) | |
download | clang-ed3802e5da6e7d41975b1cb3d7ae3a3b9e855d10.tar.gz |
[PCH] For HeaderFileInfoTrait, hash the key using size & time of the file.
Previously the hash would be the filename portion of the path, which could be
different for a filename with different case or a symbolic link with a different
name completely.
This did not actually create any issue so far because by validating all headers
in the PCH we created uniqued FileEntries based on inodes, so an #include of
a symbolic link (refering to a file from the PCH) would end up with a FileEntry
with filename same as the one recorded in the PCH.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176566 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTReaderInternals.h')
-rw-r--r-- | lib/Serialization/ASTReaderInternals.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/Serialization/ASTReaderInternals.h b/lib/Serialization/ASTReaderInternals.h index ceae0f82b1..327da4403a 100644 --- a/lib/Serialization/ASTReaderInternals.h +++ b/lib/Serialization/ASTReaderInternals.h @@ -25,6 +25,7 @@ namespace clang { class ASTReader; class HeaderSearch; struct HeaderFileInfo; +class FileEntry; namespace serialization { @@ -198,8 +199,14 @@ class HeaderFileInfoTrait { const char *FrameworkStrings; public: - typedef const char *external_key_type; - typedef const char *internal_key_type; + typedef const FileEntry *external_key_type; + + struct internal_key_type { + off_t Size; + time_t ModTime; + const char *Filename; + }; + typedef const internal_key_type &internal_key_ref; typedef HeaderFileInfo data_type; @@ -207,19 +214,16 @@ public: const char *FrameworkStrings) : Reader(Reader), M(M), HS(HS), FrameworkStrings(FrameworkStrings) { } - static unsigned ComputeHash(const char *path); - static internal_key_type GetInternalKey(const char *path); - bool EqualKey(internal_key_type a, internal_key_type b); + static unsigned ComputeHash(internal_key_ref ikey); + static internal_key_type GetInternalKey(const FileEntry *FE); + bool EqualKey(internal_key_ref a, internal_key_ref b); static std::pair<unsigned, unsigned> ReadKeyDataLength(const unsigned char*& d); - static internal_key_type ReadKey(const unsigned char *d, unsigned) { - return (const char *)d; - } + static internal_key_type ReadKey(const unsigned char *d, unsigned); - data_type ReadData(const internal_key_type, const unsigned char *d, - unsigned DataLen); + data_type ReadData(internal_key_ref,const unsigned char *d, unsigned DataLen); }; /// \brief The on-disk hash table used for known header files. |