[clang-tools-extra] 75eacbf - Fix issues reported by -Wrange-loop-analysis when building with latest Clang (trunk). NFC.
Alexandre Ganea via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 10:58:39 PST 2020
Author: Alexandre Ganea
Date: 2020-01-07T13:58:26-05:00
New Revision: 75eacbf1a9fbc29432a6e0c5627e6c8e95683956
URL: https://github.com/llvm/llvm-project/commit/75eacbf1a9fbc29432a6e0c5627e6c8e95683956
DIFF: https://github.com/llvm/llvm-project/commit/75eacbf1a9fbc29432a6e0c5627e6c8e95683956.diff
LOG: Fix issues reported by -Wrange-loop-analysis when building with latest Clang (trunk). NFC.
Fixes warning: loop variable 'E' of type 'const llvm::StringRef' creates a copy from type 'const llvm::StringRef' [-Wrange-loop-analysis]
Added:
Modified:
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
llvm/lib/Support/Windows/Program.inc
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
index d7100980367d..85b8f436dd05 100644
--- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -56,7 +56,7 @@ MATCHER_P(WithTemplateArgs, ArgName, "") {
LangOptions LO;
PrintingPolicy Policy(LO);
Policy.adjustForCPlusPlus();
- for (const auto Arg : Args->asArray()) {
+ for (const auto &Arg : Args->asArray()) {
if (SpecializationArgs.size() > 0)
SpecializationArgs += ",";
SpecializationArgs += Arg.getAsType().getAsString(Policy);
diff --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index be491546aca8..6ced22bf3515 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -404,7 +404,7 @@ TEST(RenameTest, WithinFileRename) {
template <> struct Bar<[[Foo]]> {};
)cpp",
};
- for (const auto T : Tests) {
+ for (llvm::StringRef T : Tests) {
Annotations Code(T);
auto TU = TestTU::withCode(Code.code());
TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
diff --git a/llvm/lib/Support/Windows/Program.inc b/llvm/lib/Support/Windows/Program.inc
index a23ed95fc390..a1482bf17c60 100644
--- a/llvm/lib/Support/Windows/Program.inc
+++ b/llvm/lib/Support/Windows/Program.inc
@@ -197,7 +197,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
// An environment block consists of a null-terminated block of
// null-terminated strings. Convert the array of environment variables to
// an environment block by concatenating them.
- for (const auto E : *Env) {
+ for (StringRef E : *Env) {
SmallVector<wchar_t, MAX_PATH> EnvString;
if (std::error_code ec = windows::UTF8ToUTF16(E, EnvString)) {
SetLastError(ec.value());
More information about the cfe-commits
mailing list