diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-05-17 23:10:59 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-05-17 23:10:59 +0000 |
commit | da176c6d6aee673ade66dbaa5065a035331e30db (patch) | |
tree | 3a74bd0383b6db6b2a5e58b163fd56f77020851a /lib/Lex/PTHLexer.cpp | |
parent | 9d83a9315e54ebb56a49819b77c8597f3aff1d08 (diff) |
[C++11] Use 'nullptr'. Lex edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209083 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r-- | lib/Lex/PTHLexer.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index b888f2ed9b..42629d41ab 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -37,7 +37,7 @@ using namespace clang; PTHLexer::PTHLexer(Preprocessor &PP, FileID FID, const unsigned char *D, const unsigned char *ppcond, PTHManager &PM) - : PreprocessorLexer(&PP, FID), TokBuf(D), CurPtr(D), LastHashTokPtr(0), + : PreprocessorLexer(&PP, FID), TokBuf(D), CurPtr(D), LastHashTokPtr(nullptr), PPCond(ppcond), CurPPCondPtr(ppcond), PTHMgr(PM) { FileStartLoc = PP.getSourceManager().getLocForStartOfFile(FID); @@ -191,7 +191,7 @@ bool PTHLexer::SkipBlock() { assert(CurPPCondPtr && "No cached PP conditional information."); assert(LastHashTokPtr && "No known '#' token."); - const unsigned char* HashEntryI = 0; + const unsigned char *HashEntryI = nullptr; uint32_t TableIdx; do { @@ -423,7 +423,7 @@ PTHManager::PTHManager(const llvm::MemoryBuffer* buf, void* fileLookup, const char* originalSourceFile) : Buf(buf), PerIDCache(perIDCache), FileLookup(fileLookup), IdDataTable(idDataTable), StringIdLookup(stringIdLookup), - NumIds(numIds), PP(0), SpellingBase(spellingBase), + NumIds(numIds), PP(nullptr), SpellingBase(spellingBase), OriginalSourceFile(originalSourceFile) {} PTHManager::~PTHManager() { @@ -445,7 +445,7 @@ PTHManager *PTHManager::Create(const std::string &file, if (llvm::MemoryBuffer::getFile(file, File)) { // FIXME: Add ec.message() to this diag. Diags.Report(diag::err_invalid_pth_file) << file; - return 0; + return nullptr; } using namespace llvm::support; @@ -459,7 +459,7 @@ PTHManager *PTHManager::Create(const std::string &file, if ((BufEnd - BufBeg) < (signed)(sizeof("cfe-pth") + 4 + 4) || memcmp(BufBeg, "cfe-pth", sizeof("cfe-pth")) != 0) { Diags.Report(diag::err_invalid_pth_file) << file; - return 0; + return nullptr; } // Read the PTH version. @@ -471,7 +471,7 @@ PTHManager *PTHManager::Create(const std::string &file, Version < PTHManager::Version ? "PTH file uses an older PTH format that is no longer supported" : "PTH file uses a newer PTH format that cannot be read"); - return 0; + return nullptr; } // Compute the address of the index table at the end of the PTH file. @@ -479,7 +479,7 @@ PTHManager *PTHManager::Create(const std::string &file, if (PrologueOffset >= BufEnd) { Diags.Report(diag::err_invalid_pth_file) << file; - return 0; + return nullptr; } // Construct the file lookup table. This will be used for mapping from @@ -490,7 +490,7 @@ PTHManager *PTHManager::Create(const std::string &file, if (!(FileTable > BufBeg && FileTable < BufEnd)) { Diags.Report(diag::err_invalid_pth_file) << file; - return 0; // FIXME: Proper error diagnostic? + return nullptr; // FIXME: Proper error diagnostic? } std::unique_ptr<PTHFileLookup> FL(PTHFileLookup::Create(FileTable, BufBeg)); @@ -508,7 +508,7 @@ PTHManager *PTHManager::Create(const std::string &file, if (!(IData >= BufBeg && IData < BufEnd)) { Diags.Report(diag::err_invalid_pth_file) << file; - return 0; + return nullptr; } // Get the location of the hashtable mapping between strings and @@ -518,7 +518,7 @@ PTHManager *PTHManager::Create(const std::string &file, BufBeg + endian::readNext<uint32_t, little, aligned>(StringIdTableOffset); if (!(StringIdTable >= BufBeg && StringIdTable < BufEnd)) { Diags.Report(diag::err_invalid_pth_file) << file; - return 0; + return nullptr; } std::unique_ptr<PTHStringIdLookup> SL( @@ -530,7 +530,7 @@ PTHManager *PTHManager::Create(const std::string &file, BufBeg + endian::readNext<uint32_t, little, aligned>(spellingBaseOffset); if (!(spellingBase >= BufBeg && spellingBase < BufEnd)) { Diags.Report(diag::err_invalid_pth_file) << file; - return 0; + return nullptr; } // Get the number of IdentifierInfos and pre-allocate the identifier cache. @@ -539,13 +539,13 @@ PTHManager *PTHManager::Create(const std::string &file, // Pre-allocate the persistent ID -> IdentifierInfo* cache. We use calloc() // so that we in the best case only zero out memory once when the OS returns // us new pages. - IdentifierInfo** PerIDCache = 0; + IdentifierInfo **PerIDCache = nullptr; if (NumIds) { PerIDCache = (IdentifierInfo**)calloc(NumIds, sizeof(*PerIDCache)); if (!PerIDCache) { InvalidPTH(Diags, "Could not allocate memory for processing PTH file"); - return 0; + return nullptr; } } @@ -553,7 +553,7 @@ PTHManager *PTHManager::Create(const std::string &file, const unsigned char* originalSourceBase = PrologueOffset + sizeof(uint32_t)*4; unsigned len = endian::readNext<uint16_t, little, unaligned>(originalSourceBase); - if (!len) originalSourceBase = 0; + if (!len) originalSourceBase = nullptr; // Create the new PTHManager. return new PTHManager(File.release(), FL.release(), IData, PerIDCache, @@ -591,7 +591,7 @@ IdentifierInfo* PTHManager::get(StringRef Name) { PTHStringIdLookup::iterator I = SL.find(std::make_pair(Name.data(), Name.size())); if (I == SL.end()) // No identifier found? - return 0; + return nullptr; // Match found. Return the identifier! assert(*I > 0); @@ -601,7 +601,7 @@ IdentifierInfo* PTHManager::get(StringRef Name) { PTHLexer *PTHManager::CreateLexer(FileID FID) { const FileEntry *FE = PP->getSourceManager().getFileEntryForID(FID); if (!FE) - return 0; + return nullptr; using namespace llvm::support; @@ -612,7 +612,7 @@ PTHLexer *PTHManager::CreateLexer(FileID FID) { PTHFileLookup::iterator I = PFL.find(FE); if (I == PFL.end()) // No tokens available? - return 0; + return nullptr; const PTHFileData& FileData = *I; @@ -623,7 +623,7 @@ PTHLexer *PTHManager::CreateLexer(FileID FID) { // Get the location of pp-conditional table. const unsigned char* ppcond = BufStart + FileData.getPPCondOffset(); uint32_t Len = endian::readNext<uint32_t, little, aligned>(ppcond); - if (Len == 0) ppcond = 0; + if (Len == 0) ppcond = nullptr; assert(PP && "No preprocessor set yet!"); return new PTHLexer(*PP, FID, data, ppcond, *this); |