[Driver] Avoid copies in range-based for loops
authorMark de Wever <koraq@xs4all.nl>
Tue, 17 Dec 2019 20:56:04 +0000 (21:56 +0100)
committerMark de Wever <koraq@xs4all.nl>
Tue, 17 Dec 2019 20:56:04 +0000 (21:56 +0100)
This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Differential Revision: https://reviews.llvm.org/D71527

clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp

index 9139915..f2b2343 100644 (file)
@@ -744,7 +744,7 @@ static bool searchForFile(SmallVectorImpl<char> &FilePath,
                           ArrayRef<std::string> Dirs,
                           StringRef FileName) {
   SmallString<128> WPath;
-  for (const StringRef &Dir : Dirs) {
+  for (const std::string &Dir : Dirs) {
     if (Dir.empty())
       continue;
     WPath.clear();
index ba4128e..cab97b1 100644 (file)
@@ -850,7 +850,7 @@ void ToolChain::addExternCSystemIncludeIfExists(const ArgList &DriverArgs,
 /*static*/ void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
                                              ArgStringList &CC1Args,
                                              ArrayRef<StringRef> Paths) {
-  for (const auto Path : Paths) {
+  for (const auto &Path : Paths) {
     CC1Args.push_back("-internal-isystem");
     CC1Args.push_back(DriverArgs.MakeArgString(Path));
   }