From: Craig Topper Date: Thu, 24 Dec 2015 02:55:45 +0000 (+0000) Subject: [StaticAnalyzer] Use front() and back() instead of dereferencing begin() and rbegin... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24447961a8bd4ddc00e8c1871e4b3ba3543252f8;p=clang [StaticAnalyzer] Use front() and back() instead of dereferencing begin() and rbegin(). Makes the code a little cleaner. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256358 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index 183acbe1d9..b3edb8569b 100644 --- a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -123,10 +123,10 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, // The path as already been prechecked that all parts of the path are // from the same file and that it is non-empty. - const SourceManager &SMgr = (*path.begin())->getLocation().getManager(); + const SourceManager &SMgr = path.front()->getLocation().getManager(); assert(!path.empty()); FileID FID = - (*path.begin())->getLocation().asLocation().getExpansionLoc().getFileID(); + path.front()->getLocation().asLocation().getExpansionLoc().getFileID(); assert(FID.isValid()); // Create a new rewriter to generate HTML. @@ -144,7 +144,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, // Retrieve the relative position of the declaration which will be used // for the file name FullSourceLoc L( - SMgr.getExpansionLoc((*path.rbegin())->getLocation().asLocation()), + SMgr.getExpansionLoc(path.back()->getLocation().asLocation()), SMgr); FullSourceLoc FunL(SMgr.getExpansionLoc(Body->getLocStart()), SMgr); offsetDecl = L.getExpansionLineNumber() - FunL.getExpansionLineNumber(); @@ -188,8 +188,8 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D, DirName += '/'; } - int LineNumber = (*path.rbegin())->getLocation().asLocation().getExpansionLineNumber(); - int ColumnNumber = (*path.rbegin())->getLocation().asLocation().getExpansionColumnNumber(); + int LineNumber = path.back()->getLocation().asLocation().getExpansionLineNumber(); + int ColumnNumber = path.back()->getLocation().asLocation().getExpansionColumnNumber(); // Add the name of the file as an

tag. diff --git a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index 3e428fa922..55e1222e0a 100644 --- a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -295,7 +295,7 @@ void PlistDiagnostics::FlushDiagnosticsImpl( const SourceManager* SM = nullptr; if (!Diags.empty()) - SM = &(*(*Diags.begin())->path.begin())->getLocation().getManager(); + SM = &Diags.front()->path.front()->getLocation().getManager(); for (std::vector::iterator DI = Diags.begin(),