[PATCH] D25939: PP: Replace some uses of unsigned with size_t
This revision was automatically updated to reflect the committed changes. Closed by commit rL285182: [PP] Replace some uses of unsigned with size_t (authored by erikjv). Changed prior to commit: https://reviews.llvm.org/D25939?vs=75836=75841#toc Repository: rL LLVM https://reviews.llvm.org/D25939 Files: cfe/trunk/lib/Lex/PPDirectives.cpp Index: cfe/trunk/lib/Lex/PPDirectives.cpp === --- cfe/trunk/lib/Lex/PPDirectives.cpp +++ cfe/trunk/lib/Lex/PPDirectives.cpp @@ -471,7 +471,7 @@ Directive = RI; } else { std::string DirectiveStr = getSpelling(Tok); - unsigned IdLen = DirectiveStr.size(); + size_t IdLen = DirectiveStr.size(); if (IdLen >= 20) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. @@ -801,8 +801,7 @@ // headers included by quoted include directives. // See: http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx if (LangOpts.MSVCCompat && !isAngled) { - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e - i - 1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) if ((FileEnt = ISEntry.ThePPLexer->getFileEntry())) Includers.push_back(std::make_pair(FileEnt, FileEnt->getDir())); @@ -865,8 +864,7 @@ } } - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e-i-1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) { if ((CurFileEnt = ISEntry.ThePPLexer->getFileEntry())) { if ((FE = HeaderInfo.LookupSubframeworkHeader( @@ -1567,7 +1565,7 @@ FilenameBuffer.push_back(' '); // Get the spelling of the token, directly into FilenameBuffer if possible. -unsigned PreAppendSize = FilenameBuffer.size(); +size_t PreAppendSize = FilenameBuffer.size(); FilenameBuffer.resize(PreAppendSize+CurTok.getLength()); const char *BufPtr = [PreAppendSize]; @@ -1618,7 +1616,7 @@ assert(PP.getLangOpts().ObjC2 && "no import syntax available"); SmallString<128> PathString; - for (unsigned I = 0, N = Path.size(); I != N; ++I) { + for (size_t I = 0, N = Path.size(); I != N; ++I) { if (I) PathString += '.'; PathString += Path[I].first->getName(); Index: cfe/trunk/lib/Lex/PPDirectives.cpp === --- cfe/trunk/lib/Lex/PPDirectives.cpp +++ cfe/trunk/lib/Lex/PPDirectives.cpp @@ -471,7 +471,7 @@ Directive = RI; } else { std::string DirectiveStr = getSpelling(Tok); - unsigned IdLen = DirectiveStr.size(); + size_t IdLen = DirectiveStr.size(); if (IdLen >= 20) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. @@ -801,8 +801,7 @@ // headers included by quoted include directives. // See: http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx if (LangOpts.MSVCCompat && !isAngled) { - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e - i - 1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) if ((FileEnt = ISEntry.ThePPLexer->getFileEntry())) Includers.push_back(std::make_pair(FileEnt, FileEnt->getDir())); @@ -865,8 +864,7 @@ } } - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e-i-1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) { if ((CurFileEnt = ISEntry.ThePPLexer->getFileEntry())) { if ((FE = HeaderInfo.LookupSubframeworkHeader( @@ -1567,7 +1565,7 @@ FilenameBuffer.push_back(' '); // Get the spelling of the token, directly into FilenameBuffer if possible. -unsigned PreAppendSize = FilenameBuffer.size(); +size_t PreAppendSize = FilenameBuffer.size(); FilenameBuffer.resize(PreAppendSize+CurTok.getLength()); const char *BufPtr = [PreAppendSize]; @@ -1618,7 +1616,7 @@ assert(PP.getLangOpts().ObjC2 && "no import syntax available"); SmallString<128> PathString; - for (unsigned I = 0, N = Path.size(); I != N; ++I) { + for (size_t I = 0, N = Path.size(); I != N; ++I) { if (I) PathString += '.'; PathString += Path[I].first->getName(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25939: PP: Replace some uses of unsigned with size_t
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lg https://reviews.llvm.org/D25939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25939: PP: Replace some uses of unsigned with size_t
erikjv updated the summary for this revision. erikjv updated this revision to Diff 75836. https://reviews.llvm.org/D25939 Files: lib/Lex/PPDirectives.cpp Index: lib/Lex/PPDirectives.cpp === --- lib/Lex/PPDirectives.cpp +++ lib/Lex/PPDirectives.cpp @@ -471,7 +471,7 @@ Directive = RI; } else { std::string DirectiveStr = getSpelling(Tok); - unsigned IdLen = DirectiveStr.size(); + size_t IdLen = DirectiveStr.size(); if (IdLen >= 20) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. @@ -801,8 +801,7 @@ // headers included by quoted include directives. // See: http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx if (LangOpts.MSVCCompat && !isAngled) { - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e - i - 1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) if ((FileEnt = ISEntry.ThePPLexer->getFileEntry())) Includers.push_back(std::make_pair(FileEnt, FileEnt->getDir())); @@ -865,8 +864,7 @@ } } - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e-i-1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) { if ((CurFileEnt = ISEntry.ThePPLexer->getFileEntry())) { if ((FE = HeaderInfo.LookupSubframeworkHeader( @@ -1567,7 +1565,7 @@ FilenameBuffer.push_back(' '); // Get the spelling of the token, directly into FilenameBuffer if possible. -unsigned PreAppendSize = FilenameBuffer.size(); +size_t PreAppendSize = FilenameBuffer.size(); FilenameBuffer.resize(PreAppendSize+CurTok.getLength()); const char *BufPtr = [PreAppendSize]; @@ -1618,7 +1616,7 @@ assert(PP.getLangOpts().ObjC2 && "no import syntax available"); SmallString<128> PathString; - for (unsigned I = 0, N = Path.size(); I != N; ++I) { + for (size_t I = 0, N = Path.size(); I != N; ++I) { if (I) PathString += '.'; PathString += Path[I].first->getName(); Index: lib/Lex/PPDirectives.cpp === --- lib/Lex/PPDirectives.cpp +++ lib/Lex/PPDirectives.cpp @@ -471,7 +471,7 @@ Directive = RI; } else { std::string DirectiveStr = getSpelling(Tok); - unsigned IdLen = DirectiveStr.size(); + size_t IdLen = DirectiveStr.size(); if (IdLen >= 20) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. @@ -801,8 +801,7 @@ // headers included by quoted include directives. // See: http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx if (LangOpts.MSVCCompat && !isAngled) { - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e - i - 1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) if ((FileEnt = ISEntry.ThePPLexer->getFileEntry())) Includers.push_back(std::make_pair(FileEnt, FileEnt->getDir())); @@ -865,8 +864,7 @@ } } - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { -IncludeStackInfo = IncludeMacroStack[e-i-1]; + for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) { if (IsFileLexer(ISEntry)) { if ((CurFileEnt = ISEntry.ThePPLexer->getFileEntry())) { if ((FE = HeaderInfo.LookupSubframeworkHeader( @@ -1567,7 +1565,7 @@ FilenameBuffer.push_back(' '); // Get the spelling of the token, directly into FilenameBuffer if possible. -unsigned PreAppendSize = FilenameBuffer.size(); +size_t PreAppendSize = FilenameBuffer.size(); FilenameBuffer.resize(PreAppendSize+CurTok.getLength()); const char *BufPtr = [PreAppendSize]; @@ -1618,7 +1616,7 @@ assert(PP.getLangOpts().ObjC2 && "no import syntax available"); SmallString<128> PathString; - for (unsigned I = 0, N = Path.size(); I != N; ++I) { + for (size_t I = 0, N = Path.size(); I != N; ++I) { if (I) PathString += '.'; PathString += Path[I].first->getName(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25939: PP: Replace some uses of unsigned with size_t
bkramer added inline comments. Comment at: lib/Lex/PPDirectives.cpp:804 if (LangOpts.MSVCCompat && !isAngled) { - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { IncludeStackInfo = IncludeMacroStack[e - i - 1]; While there you could turn this into a for-range loop ``` for (IncludeStackInfo : llvm::reverse(IncludeMacroStack)) ``` Comment at: lib/Lex/PPDirectives.cpp:868 - for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) { IncludeStackInfo = IncludeMacroStack[e-i-1]; Looks like another candidate for for-range. https://reviews.llvm.org/D25939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits