diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp index fe4d2b6d03aa4..eb21827bdeba3 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp +++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp @@ -134,12 +134,13 @@ void IncludeSorter::addInclude(StringRef FileName, bool IsAngled, int Offset = findNextLine(SourceMgr->getCharacterData(EndLocation)); // Record the relevant location information for this inclusion directive. - IncludeLocations[FileName].push_back( + auto &IncludeLocation = IncludeLocations[FileName]; + IncludeLocation.push_back( SourceRange(HashLocation, EndLocation.getLocWithOffset(Offset))); - SourceLocations.push_back(IncludeLocations[FileName].back()); + SourceLocations.push_back(IncludeLocation.back()); // Stop if this inclusion is a duplicate. - if (IncludeLocations[FileName].size() > 1) + if (IncludeLocation.size() > 1) return; // Add the included file's name to the appropriate bucket.