diff options
Diffstat (limited to 'lib/Frontend/CacheTokens.cpp')
-rw-r--r-- | lib/Frontend/CacheTokens.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp index 15b0adab7c5e..72e8f68dc051 100644 --- a/lib/Frontend/CacheTokens.cpp +++ b/lib/Frontend/CacheTokens.cpp @@ -12,12 +12,12 @@ // //===----------------------------------------------------------------------===// -#include "clang/Frontend/Utils.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemStatCache.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceManager.h" +#include "clang/Frontend/Utils.h" #include "clang/Lex/Lexer.h" #include "clang/Lex/PTHManager.h" #include "clang/Lex/Preprocessor.h" @@ -28,7 +28,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/OnDiskHashTable.h" #include "llvm/Support/Path.h" -#include "llvm/Support/raw_ostream.h" // FIXME: put this somewhere else? #ifndef S_ISDIR @@ -59,23 +58,30 @@ public: class PTHEntryKeyVariant { - union { const FileEntry* FE; const char* Path; }; + union { + const FileEntry *FE; + // FIXME: Use "StringRef Path;" when MSVC 2013 is dropped. + const char *PathPtr; + }; + size_t PathSize; enum { IsFE = 0x1, IsDE = 0x2, IsNoExist = 0x0 } Kind; FileData *Data; public: PTHEntryKeyVariant(const FileEntry *fe) : FE(fe), Kind(IsFE), Data(nullptr) {} - PTHEntryKeyVariant(FileData *Data, const char *path) - : Path(path), Kind(IsDE), Data(new FileData(*Data)) {} + PTHEntryKeyVariant(FileData *Data, StringRef Path) + : PathPtr(Path.data()), PathSize(Path.size()), Kind(IsDE), + Data(new FileData(*Data)) {} - explicit PTHEntryKeyVariant(const char *path) - : Path(path), Kind(IsNoExist), Data(nullptr) {} + explicit PTHEntryKeyVariant(StringRef Path) + : PathPtr(Path.data()), PathSize(Path.size()), Kind(IsNoExist), + Data(nullptr) {} bool isFile() const { return Kind == IsFE; } StringRef getString() const { - return Kind == IsFE ? FE->getName() : Path; + return Kind == IsFE ? FE->getName() : StringRef(PathPtr, PathSize); } unsigned getKind() const { return (unsigned) Kind; } @@ -183,14 +189,14 @@ class PTHWriter { typedef llvm::DenseMap<const IdentifierInfo*,uint32_t> IDMap; typedef llvm::StringMap<OffsetOpt, llvm::BumpPtrAllocator> CachedStrsTy; - IDMap IM; raw_pwrite_stream &Out; Preprocessor& PP; - uint32_t idcount; + IDMap IM; + std::vector<llvm::StringMapEntry<OffsetOpt>*> StrEntries; PTHMap PM; CachedStrsTy CachedStrs; + uint32_t idcount; Offset CurStrOffset; - std::vector<llvm::StringMapEntry<OffsetOpt>*> StrEntries; //// Get the persistent id for the given IdentifierInfo*. uint32_t ResolveID(const IdentifierInfo* II); @@ -550,7 +556,7 @@ public: StatListener(PTHMap &pm) : PM(pm) {} ~StatListener() override {} - LookupResult getStat(const char *Path, FileData &Data, bool isFile, + LookupResult getStat(StringRef Path, FileData &Data, bool isFile, std::unique_ptr<vfs::File> *F, vfs::FileSystem &FS) override { LookupResult Result = statChained(Path, Data, isFile, F, FS); |