diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Lex/PTHLexer.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Lex/PTHLexer.cpp | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/contrib/llvm/tools/clang/lib/Lex/PTHLexer.cpp b/contrib/llvm/tools/clang/lib/Lex/PTHLexer.cpp index e8f43f7..e2629a3 100644 --- a/contrib/llvm/tools/clang/lib/Lex/PTHLexer.cpp +++ b/contrib/llvm/tools/clang/lib/Lex/PTHLexer.cpp @@ -43,9 +43,7 @@ PTHLexer::PTHLexer(Preprocessor &PP, FileID FID, const unsigned char *D, FileStartLoc = PP.getSourceManager().getLocForStartOfFile(FID); } -void PTHLexer::Lex(Token& Tok) { -LexNextToken: - +bool PTHLexer::Lex(Token& Tok) { //===--------------------------------------==// // Read the raw token data. //===--------------------------------------==// @@ -90,8 +88,9 @@ LexNextToken: Tok.setKind(II->getTokenID()); if (II->isHandleIdentifierCase()) - PP->HandleIdentifier(Tok); - return; + return PP->HandleIdentifier(Tok); + + return true; } //===--------------------------------------==// @@ -101,16 +100,10 @@ LexNextToken: // Save the end-of-file token. EofToken = Tok; - // Save 'PP' to 'PPCache' as LexEndOfFile can delete 'this'. - Preprocessor *PPCache = PP; - assert(!ParsingPreprocessorDirective); assert(!LexingRawMode); - - if (LexEndOfFile(Tok)) - return; - return PPCache->Lex(Tok); + return LexEndOfFile(Tok); } if (TKind == tok::hash && Tok.isAtStartOfLine()) { @@ -118,19 +111,17 @@ LexNextToken: assert(!LexingRawMode); PP->HandleDirective(Tok); - if (PP->isCurrentLexer(this)) - goto LexNextToken; - - return PP->Lex(Tok); + return false; } if (TKind == tok::eod) { assert(ParsingPreprocessorDirective); ParsingPreprocessorDirective = false; - return; + return true; } MIOpt.ReadToken(); + return true; } bool PTHLexer::LexEndOfFile(Token &Result) { @@ -619,18 +610,18 @@ PTHLexer *PTHManager::CreateLexer(FileID FID) { namespace { class PTHStatData { public: - const bool hasStat; - const ino_t ino; - const dev_t dev; - const mode_t mode; - const time_t mtime; - const off_t size; - - PTHStatData(ino_t i, dev_t d, mode_t mo, time_t m, off_t s) - : hasStat(true), ino(i), dev(d), mode(mo), mtime(m), size(s) {} - - PTHStatData() - : hasStat(false), ino(0), dev(0), mode(0), mtime(0), size(0) {} + const bool HasData; + uint64_t Size; + time_t ModTime; + llvm::sys::fs::UniqueID UniqueID; + bool IsDirectory; + + PTHStatData(uint64_t Size, time_t ModTime, llvm::sys::fs::UniqueID UniqueID, + bool IsDirectory) + : HasData(true), Size(Size), ModTime(ModTime), UniqueID(UniqueID), + IsDirectory(IsDirectory) {} + + PTHStatData() : HasData(false) {} }; class PTHStatLookupTrait : public PTHFileLookupCommonTrait { @@ -653,12 +644,18 @@ public: unsigned) { if (k.first /* File or Directory */) { - if (k.first == 0x1 /* File */) d += 4 * 2; // Skip the first 2 words. - ino_t ino = (ino_t) ReadUnalignedLE32(d); - dev_t dev = (dev_t) ReadUnalignedLE32(d); - mode_t mode = (mode_t) ReadUnalignedLE16(d); - time_t mtime = (time_t) ReadUnalignedLE64(d); - return data_type(ino, dev, mode, mtime, (off_t) ReadUnalignedLE64(d)); + bool IsDirectory = true; + if (k.first == 0x1 /* File */) { + IsDirectory = false; + d += 4 * 2; // Skip the first 2 words. + } + + uint64_t File = ReadUnalignedLE64(d); + uint64_t Device = ReadUnalignedLE64(d); + llvm::sys::fs::UniqueID UniqueID(File, Device); + time_t ModTime = ReadUnalignedLE64(d); + uint64_t Size = ReadUnalignedLE64(d); + return data_type(Size, ModTime, UniqueID, IsDirectory); } // Negative stat. Don't read anything. @@ -677,25 +674,27 @@ public: ~PTHStatCache() {} - LookupResult getStat(const char *Path, struct stat &StatBuf, - bool isFile, int *FileDescriptor) { + LookupResult getStat(const char *Path, FileData &Data, bool isFile, + int *FileDescriptor) { // Do the lookup for the file's data in the PTH file. CacheTy::iterator I = Cache.find(Path); // If we don't get a hit in the PTH file just forward to 'stat'. if (I == Cache.end()) - return statChained(Path, StatBuf, isFile, FileDescriptor); + return statChained(Path, Data, isFile, FileDescriptor); - const PTHStatData &Data = *I; + const PTHStatData &D = *I; - if (!Data.hasStat) + if (!D.HasData) return CacheMissing; - StatBuf.st_ino = Data.ino; - StatBuf.st_dev = Data.dev; - StatBuf.st_mtime = Data.mtime; - StatBuf.st_mode = Data.mode; - StatBuf.st_size = Data.size; + Data.Size = D.Size; + Data.ModTime = D.ModTime; + Data.UniqueID = D.UniqueID; + Data.IsDirectory = D.IsDirectory; + Data.IsNamedPipe = false; + Data.InPCH = true; + return CacheExists; } }; |