summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Stefano Cianciulli <scianciulli@google.com> 2023-07-06 14:06:20 +0000
committer Stefano Cianciulli <scianciulli@google.com> 2023-07-11 10:05:16 +0000
commitdb9deaf6695ec111eb154f3dcf2a043d63043a70 (patch)
tree0988bf38eb7bc0607318222be80cd39206930a2a
parenta23be81ffa13177d4fffe5e515486349e2903011 (diff)
Fix performance-inefficient-string-concatenation clang-tidy issues
Bug: 264654008 Test: m tidy-art Change-Id: I10c4192331a7a0608f4252b6da5d7579ce4af9d0
-rw-r--r--build/Android.bp1
-rw-r--r--compiler/cfi_test.h2
-rw-r--r--compiler/debug/elf_debug_line_writer.h2
-rw-r--r--compiler/utils/riscv64/assembler_riscv64_test.cc43
-rw-r--r--dex2oat/dex2oat_image_test.cc67
-rw-r--r--libprofile/profile/profile_test_helper.h2
-rw-r--r--odrefresh/odrefresh.cc2
-rw-r--r--profman/profman.cc9
-rw-r--r--runtime/cha.cc2
-rw-r--r--runtime/class_loader_context.cc3
-rw-r--r--runtime/gc/space/image_space.cc2
-rw-r--r--runtime/gc/space/image_space_test.cc7
-rw-r--r--runtime/verifier/class_verifier.cc5
-rw-r--r--runtime/verifier/verifier_deps.cc2
-rw-r--r--tools/veridex/hidden_api_finder.cc2
-rw-r--r--tools/veridex/precise_hidden_api_finder.cc2
16 files changed, 87 insertions, 66 deletions
diff --git a/build/Android.bp b/build/Android.bp
index a8993288d9..69fc564e4a 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -44,6 +44,7 @@ art_clang_tidy_errors = [
"performance-faster-string-find",
"performance-for-range-copy",
"performance-implicit-conversion-in-loop",
+ "performance-inefficient-string-concatenation",
"performance-inefficient-vector-operation",
"performance-no-automatic-move",
"performance-noexcept-move-constructor",
diff --git a/compiler/cfi_test.h b/compiler/cfi_test.h
index e65bee8e2e..6835e92dfd 100644
--- a/compiler/cfi_test.h
+++ b/compiler/cfi_test.h
@@ -131,7 +131,7 @@ class CFITest : public dwarf::DwarfTest {
}
// Use the .cfi_ prefix.
new_line = ".cfi_" + new_line.substr(FindEndOf(new_line, "DW_CFA_"));
- output->push_back(address + ": " + new_line);
+ output->push_back(ART_FORMAT("{}: {}", address, new_line));
}
}
}
diff --git a/compiler/debug/elf_debug_line_writer.h b/compiler/debug/elf_debug_line_writer.h
index 4896bc1e9b..5d654e3e06 100644
--- a/compiler/debug/elf_debug_line_writer.h
+++ b/compiler/debug/elf_debug_line_writer.h
@@ -194,7 +194,7 @@ class ElfDebugLineWriter {
} else {
directory_index = it->second;
}
- full_path = package_name + "/" + file_name;
+ full_path = ART_FORMAT("{}/{}", package_name, file_name);
}
// Add file entry.
diff --git a/compiler/utils/riscv64/assembler_riscv64_test.cc b/compiler/utils/riscv64/assembler_riscv64_test.cc
index 707e2cffb4..e6e08f5baa 100644
--- a/compiler/utils/riscv64/assembler_riscv64_test.cc
+++ b/compiler/utils/riscv64/assembler_riscv64_test.cc
@@ -650,8 +650,8 @@ class AssemblerRISCV64Test : public AssemblerTest<riscv64::Riscv64Assembler,
std::string expected;
for (XRegister* rd : GetRegisters()) {
std::string rd_name = GetRegisterName(*rd);
- std::string addi_rd = "addi" + suffix + " " + rd_name + ", ";
- std::string add_rd = "add" + suffix + " " + rd_name + ", ";
+ std::string addi_rd = ART_FORMAT("addi{} {}, ", suffix, rd_name);
+ std::string add_rd = ART_FORMAT("add{} {}, ", suffix, rd_name);
for (XRegister* rs1 : GetRegisters()) {
ScratchRegisterScope srs(GetAssembler());
srs.ExcludeXRegister(*rs1);
@@ -659,18 +659,19 @@ class AssemblerRISCV64Test : public AssemblerTest<riscv64::Riscv64Assembler,
std::string rs1_name = GetRegisterName(*rs1);
std::string tmp_name = GetRegisterName((*rs1 != TMP) ? TMP : TMP2);
- std::string addi_tmp = "addi" + suffix + " " + tmp_name + ", ";
+ std::string addi_tmp = ART_FORMAT("addi{} {}, ", suffix, tmp_name);
for (int64_t imm : kImm12s) {
emit_op(*rd, *rs1, imm);
- expected += addi_rd + rs1_name + ", " + std::to_string(imm) + "\n";
+ expected += ART_FORMAT("{}{}, {}\n", addi_rd, rs1_name, std::to_string(imm));
}
auto emit_simple_ops = [&](ArrayRef<const int64_t> imms, int64_t adjustment) {
for (int64_t imm : imms) {
emit_op(*rd, *rs1, imm);
- expected += addi_tmp + rs1_name + ", " + std::to_string(adjustment) + "\n" +
- addi_rd + tmp_name + ", " + std::to_string(imm - adjustment) + "\n";
+ expected += ART_FORMAT("{}{}, {}\n", addi_tmp, rs1_name, std::to_string(adjustment));
+ expected +=
+ ART_FORMAT("{}{}, {}\n", addi_rd, tmp_name, std::to_string(imm - adjustment));
}
};
emit_simple_ops(ArrayRef<const int64_t>(kSimplePositiveValues), 0x7ff);
@@ -678,8 +679,8 @@ class AssemblerRISCV64Test : public AssemblerTest<riscv64::Riscv64Assembler,
for (int64_t imm : large_values) {
emit_op(*rd, *rs1, imm);
- expected += "li " + tmp_name + ", " + std::to_string(imm) + "\n" +
- add_rd + rs1_name + ", " + tmp_name + "\n";
+ expected += ART_FORMAT("li {}, {}\n", tmp_name, std::to_string(imm));
+ expected += ART_FORMAT("{}{}, {}\n", add_rd, rs1_name, tmp_name);
}
}
}
@@ -732,15 +733,15 @@ class AssemblerRISCV64Test : public AssemblerTest<riscv64::Riscv64Assembler,
for (int64_t imm : kImm12s) {
emit_op(*rs1, imm);
- expected += head + ", " + std::to_string(imm) + "(" + rs1_name + ")" + "\n";
+ expected += ART_FORMAT("{}, {}({})\n", head, std::to_string(imm), rs1_name);
}
auto emit_simple_ops = [&](ArrayRef<const int64_t> imms, int64_t adjustment) {
for (int64_t imm : imms) {
emit_op(*rs1, imm);
expected +=
- "addi " + tmp_name + ", " + rs1_name + ", " + std::to_string(adjustment) + "\n" +
- head + ", " + std::to_string(imm - adjustment) + "(" + tmp_name + ")" + "\n";
+ ART_FORMAT("addi {}, {}, {}\n", tmp_name, rs1_name, std::to_string(adjustment));
+ expected += ART_FORMAT("{}, {}({})\n", head, std::to_string(imm - adjustment), tmp_name);
}
};
emit_simple_ops(ArrayRef<const int64_t>(kSimplePositiveOffsetsAlign8), 0x7f8);
@@ -753,18 +754,18 @@ class AssemblerRISCV64Test : public AssemblerTest<riscv64::Riscv64Assembler,
emit_op(*rs1, imm);
uint32_t imm20 = ((imm >> 12) + ((imm >> 11) & 1)) & 0xfffff;
int32_t small_offset = (imm & 0xfff) - ((imm & 0x800) << 1);
- expected += "lui " + tmp_name + ", " + std::to_string(imm20) + "\n"
- "add " + tmp_name + ", " + tmp_name + ", " + rs1_name + "\n" +
- head + ", " + std::to_string(small_offset) + "(" + tmp_name + ")\n";
+ expected += ART_FORMAT("lui {}, {}\n", tmp_name, std::to_string(imm20));
+ expected += ART_FORMAT("add {}, {}, {}\n", tmp_name, tmp_name, rs1_name);
+ expected += ART_FORMAT("{},{}({})\n", head, std::to_string(small_offset), tmp_name);
}
for (int64_t imm : kSpecialOffsets) {
emit_op(*rs1, imm);
+ expected += ART_FORMAT("lui {}, 0x80000\n", tmp_name);
expected +=
- "lui " + tmp_name + ", 0x80000\n"
- "addiw " + tmp_name + ", " + tmp_name + ", " + std::to_string(imm - 0x80000000) + "\n" +
- "add " + tmp_name + ", " + tmp_name + ", " + rs1_name + "\n" +
- head + ", (" + tmp_name + ")\n";
+ ART_FORMAT("addiw {}, {}, {}\n", tmp_name, tmp_name, std::to_string(imm - 0x80000000));
+ expected += ART_FORMAT("add {}, {}, {}\n", tmp_name, tmp_name, rs1_name);
+ expected += ART_FORMAT("{}, ({})\n", head, tmp_name);
}
}
return expected;
@@ -2360,9 +2361,9 @@ TEST_F(AssemblerRISCV64Test, LoadLabelAddress) {
DCHECK_NE(rd, Zero);
std::string rd_name = GetRegisterName(rd);
__ LoadLabelAddress(rd, &label);
- expected += "1:\n"
- "auipc " + rd_name + ", %pcrel_hi(" + target_label + ")\n"
- "addi " + rd_name + ", " + rd_name + ", %pcrel_lo(1b)\n";
+ expected += "1:\n";
+ expected += ART_FORMAT("auipc {}, %pcrel_hi({})\n", rd_name, target_label);
+ expected += ART_FORMAT("addi {}, {}, %pcrel_lo(1b)\n", rd_name, rd_name);
}
};
emit_batch(kNumLoadsForward, "2f");
diff --git a/dex2oat/dex2oat_image_test.cc b/dex2oat/dex2oat_image_test.cc
index f90c1614be..dae1186cf7 100644
--- a/dex2oat/dex2oat_image_test.cc
+++ b/dex2oat/dex2oat_image_test.cc
@@ -461,33 +461,33 @@ TEST_F(Dex2oatImageTest, TestExtension) {
ASSERT_FALSE(load_ok);
// Load the primary and first extension with full path.
- load_ok = load(base_location + ':' + mid_location);
+ load_ok = load(ART_FORMAT("{}:{}", base_location, mid_location));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(mid_bcp.size(), boot_image_spaces.size());
// Load the primary with full path and fail to load first extension without full path.
- load_ok = load(base_location + ':' + mid_name);
+ load_ok = load(ART_FORMAT("{}:{}", base_location, mid_name));
ASSERT_TRUE(load_ok) << error_msg; // Primary image loaded successfully.
ASSERT_EQ(head_dex_files.size(), boot_image_spaces.size()); // But only the primary image.
// Load all the libcore images with full paths.
- load_ok = load(base_location + ':' + mid_location + ':' + tail_location);
+ load_ok = load(ART_FORMAT("{}:{}:{}", base_location, mid_location, tail_location));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(full_bcp.size(), boot_image_spaces.size());
// Load the primary and first extension with full paths, fail to load second extension by name.
- load_ok = load(base_location + ':' + mid_location + ':' + tail_name);
+ load_ok = load(ART_FORMAT("{}:{}:{}", base_location, mid_location, tail_name));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(mid_bcp.size(), boot_image_spaces.size());
// Load the primary with full path and fail to load first extension without full path,
// fail to load second extension because it depends on the first.
- load_ok = load(base_location + ':' + mid_name + ':' + tail_location);
+ load_ok = load(ART_FORMAT("{}:{}:{}", base_location, mid_name, tail_location));
ASSERT_TRUE(load_ok) << error_msg; // Primary image loaded successfully.
ASSERT_EQ(head_dex_files.size(), boot_image_spaces.size()); // But only the primary image.
// Load the primary with full path and extensions with a specified search path.
- load_ok = load(base_location + ':' + scratch_dir + '*');
+ load_ok = load(ART_FORMAT("{}:{}*", base_location, scratch_dir));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(full_bcp.size(), boot_image_spaces.size());
@@ -516,33 +516,33 @@ TEST_F(Dex2oatImageTest, TestExtension) {
ASSERT_FALSE(load_ok);
// Load the primary and first extension without paths.
- load_ok = load(base_name + ':' + mid_name);
+ load_ok = load(ART_FORMAT("{}:{}", base_name, mid_name));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(mid_bcp.size(), boot_image_spaces.size());
// Load the primary without path and first extension with path.
- load_ok = load(base_name + ':' + mid_location);
+ load_ok = load(ART_FORMAT("{}:{}", base_name, mid_location));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(mid_bcp.size(), boot_image_spaces.size());
// Load the primary with full path and the first extension without full path.
- load_ok = load(base_location + ':' + mid_name);
+ load_ok = load(ART_FORMAT("{}:{}", base_location, mid_name));
ASSERT_TRUE(load_ok) << error_msg; // Loaded successfully.
ASSERT_EQ(mid_bcp.size(), boot_image_spaces.size()); // Including the extension.
// Load all the libcore images without paths.
- load_ok = load(base_name + ':' + mid_name + ':' + tail_name);
+ load_ok = load(ART_FORMAT("{}:{}:{}", base_name, mid_name, tail_name));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(full_bcp.size(), boot_image_spaces.size());
// Load the primary and first extension with full paths and second extension by name.
- load_ok = load(base_location + ':' + mid_location + ':' + tail_name);
+ load_ok = load(ART_FORMAT("{}:{}:{}", base_location, mid_location, tail_name));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(full_bcp.size(), boot_image_spaces.size());
// Load the primary with full path, first extension without path,
// and second extension with full path.
- load_ok = load(base_location + ':' + mid_name + ':' + tail_location);
+ load_ok = load(ART_FORMAT("{}:{}:{}", base_location, mid_name, tail_location));
ASSERT_TRUE(load_ok) << error_msg; // Loaded successfully.
ASSERT_EQ(full_bcp.size(), boot_image_spaces.size()); // Including both extensions.
@@ -552,18 +552,18 @@ TEST_F(Dex2oatImageTest, TestExtension) {
ASSERT_EQ(full_bcp.size(), boot_image_spaces.size());
// Fail to load any images with invalid image locations (named component after search paths).
- load_ok = silent_load(base_location + ":*:" + tail_location);
+ load_ok = silent_load(ART_FORMAT("{}:*:{}", base_location, tail_location));
ASSERT_FALSE(load_ok);
- load_ok = silent_load(base_location + ':' + scratch_dir + "*:" + tail_location);
+ load_ok = silent_load(ART_FORMAT("{}:{}*:{}", base_location, scratch_dir, tail_location));
ASSERT_FALSE(load_ok);
// Load the primary and single-image extension with full path.
- load_ok = load(base_location + ':' + single_location);
+ load_ok = load(ART_FORMAT("{}:{}", base_location, single_location));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size() + 1u, boot_image_spaces.size());
// Load the primary with full path and single-image extension with a specified search path.
- load_ok = load(base_location + ':' + single_dir + '*');
+ load_ok = load(ART_FORMAT("{}:{}*", base_location, single_dir));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size() + 1u, boot_image_spaces.size());
}
@@ -595,29 +595,31 @@ TEST_F(Dex2oatImageTest, TestExtension) {
relocate = r;
// Load primary boot image with a profile name.
- bool load_ok = silent_load(base_location + "!" + single_profile_filename);
+ bool load_ok = silent_load(ART_FORMAT("{}!{}", base_location, single_profile_filename));
ASSERT_TRUE(load_ok);
// Try and fail to load with invalid spec, two profile name separators.
- load_ok = silent_load(base_location + ":" + single_location + "!!arbitrary-profile-name");
+ load_ok =
+ silent_load(ART_FORMAT("{}:{}!!arbitrary-profile-name", base_location, single_location));
ASSERT_FALSE(load_ok);
// Try and fail to load with invalid spec, missing profile name.
- load_ok = silent_load(base_location + ":" + single_location + "!");
+ load_ok = silent_load(ART_FORMAT("{}:{}!", base_location, single_location));
ASSERT_FALSE(load_ok);
// Try and fail to load with invalid spec, missing component name.
- load_ok = silent_load(base_location + ":!" + single_profile_filename);
+ load_ok = silent_load(ART_FORMAT("{}:!{}", base_location, single_profile_filename));
ASSERT_FALSE(load_ok);
// Load primary boot image, specifying invalid extension component and profile name.
- load_ok = load(base_location + ":/non-existent/" + single_name + "!non-existent-profile-name");
+ load_ok = load(
+ ART_FORMAT("{}:/non-existent/{}!non-existent-profile-name", base_location, single_name));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size(), boot_image_spaces.size());
// Load primary boot image and the single extension, specifying invalid profile name.
// (Load extension from file.)
- load_ok = load(base_location + ":" + single_location + "!non-existent-profile-name");
+ load_ok = load(ART_FORMAT("{}:{}!non-existent-profile-name", base_location, single_location));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size() + 1u, boot_image_spaces.size());
ASSERT_EQ(single_dex_files.size(),
@@ -627,7 +629,8 @@ TEST_F(Dex2oatImageTest, TestExtension) {
// invalid extension component name but a valid profile file.
// (Running dex2oat to compile extension is disabled.)
ASSERT_FALSE(Runtime::Current()->IsImageDex2OatEnabled());
- load_ok = load(base_location + ":/non-existent/" + single_name + "!" + single_profile_filename);
+ load_ok = load(
+ ART_FORMAT("{}:/non-existent/{}!{}", base_location, single_name, single_profile_filename));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size(), boot_image_spaces.size());
@@ -635,7 +638,8 @@ TEST_F(Dex2oatImageTest, TestExtension) {
// Load primary boot image and the single extension, specifying invalid extension
// component name but a valid profile file. (Compile extension by running dex2oat.)
- load_ok = load(base_location + ":/non-existent/" + single_name + "!" + single_profile_filename);
+ load_ok = load(
+ ART_FORMAT("{}:/non-existent/{}!{}", base_location, single_name, single_profile_filename));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size() + 1u, boot_image_spaces.size());
ASSERT_EQ(single_dex_files.size(),
@@ -643,8 +647,12 @@ TEST_F(Dex2oatImageTest, TestExtension) {
// Load primary boot image and two extensions, specifying invalid extension component
// names but valid profile files. (Compile extensions by running dex2oat.)
- load_ok = load(base_location + ":/non-existent/" + mid_name + "!" + mid_profile_filename
- + ":/non-existent/" + tail_name + "!" + tail_profile_filename);
+ load_ok = load(ART_FORMAT("{}:/non-existent/{}!{}:/non-existent/{}!{}",
+ base_location,
+ mid_name,
+ mid_profile_filename,
+ tail_name,
+ tail_profile_filename));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size() + 2u, boot_image_spaces.size());
ASSERT_EQ(mid_dex_files.size(),
@@ -655,8 +663,11 @@ TEST_F(Dex2oatImageTest, TestExtension) {
// Load primary boot image and fail to load extensions, specifying invalid component
// names but valid profile file only for the second one. As we fail to load the first
// extension, the second extension has a missing dependency and cannot be compiled.
- load_ok = load(base_location + ":/non-existent/" + mid_name
- + ":/non-existent/" + tail_name + "!" + tail_profile_filename);
+ load_ok = load(ART_FORMAT("{}:/non-existent/{}:/non-existent/{}!{}",
+ base_location,
+ mid_name,
+ tail_name,
+ tail_profile_filename));
ASSERT_TRUE(load_ok) << error_msg;
ASSERT_EQ(head_dex_files.size(), boot_image_spaces.size());
diff --git a/libprofile/profile/profile_test_helper.h b/libprofile/profile/profile_test_helper.h
index 9410620d26..1140ee7bbe 100644
--- a/libprofile/profile/profile_test_helper.h
+++ b/libprofile/profile/profile_test_helper.h
@@ -174,7 +174,7 @@ class ProfileTestHelper {
size_t method_name_index = (method_index / num_shared_ids) / num_shared_ids;
std::string return_type = "LSharedType" + std::to_string(return_type_index) + ";";
std::string arg_type = "LSharedType" + std::to_string(arg_type_index) + ";";
- std::string signature = "(" + arg_type + ")" + return_type;
+ std::string signature = ART_FORMAT("({}){}", arg_type, return_type);
builder.AddMethod(class_descriptor, signature, "m" + std::to_string(method_name_index));
}
storage.push_back(builder.Build(location, location_checksum));
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc
index e925f856ef..9807789a29 100644
--- a/odrefresh/odrefresh.cc
+++ b/odrefresh/odrefresh.cc
@@ -532,7 +532,7 @@ void AddCompiledBootClasspathFdsIfAny(
}
}
CHECK(!artifact_dir.empty());
- std::string image_path = artifact_dir + "/" + basename;
+ std::string image_path = ART_FORMAT("{}/{}", artifact_dir, basename);
image_path = GetSystemImageFilename(image_path.c_str(), isa);
std::unique_ptr<File> image_file(OS::OpenFileForReading(image_path.c_str()));
if (image_file && image_file->IsValid()) {
diff --git a/profman/profman.cc b/profman/profman.cc
index 21efd45ff3..63bc861436 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -901,8 +901,13 @@ class ProfMan final {
}
std::string inline_cache_string =
GetInlineCacheLine(profile_info, id, dex_file.get(), dex_method_idx);
- out_lines->insert(flags_string + type_string + kMethodSep + method_name +
- signature_string + inline_cache_string);
+ out_lines->insert(ART_FORMAT("{}{}{}{}{}{}",
+ flags_string,
+ type_string,
+ kMethodSep,
+ method_name,
+ signature_string,
+ inline_cache_string));
}
}
}
diff --git a/runtime/cha.cc b/runtime/cha.cc
index a40afb42bd..8b77f76146 100644
--- a/runtime/cha.cc
+++ b/runtime/cha.cc
@@ -290,7 +290,7 @@ static void VerifyNonSingleImplementation(ObjPtr<mirror::Class> verify_class,
std::string tmp = in->PrettyClass();
while (in != failed) {
in = in->GetSuperClass();
- tmp = tmp + "->" + in->PrettyClass();
+ tmp += "->" + in->PrettyClass();
}
return tmp;
};
diff --git a/runtime/class_loader_context.cc b/runtime/class_loader_context.cc
index 178c54fb6b..73546ed0a9 100644
--- a/runtime/class_loader_context.cc
+++ b/runtime/class_loader_context.cc
@@ -455,7 +455,8 @@ bool ClassLoaderContext::OpenDexFiles(const std::string& classpath_dir,
// If path is relative, append it to the provided base directory.
std::string location = cp_elem;
if (location[0] != '/' && !classpath_dir.empty()) {
- location = classpath_dir + (classpath_dir.back() == '/' ? "" : "/") + location;
+ location =
+ ART_FORMAT("{}{}{}", classpath_dir, classpath_dir.back() == '/' ? "" : "/", location);
}
// If file descriptors were provided for the class loader context dex paths,
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 4e0b561a12..0352c05505 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -3734,7 +3734,7 @@ std::vector<std::string> ImageSpace::ExpandMultiImageLocations(
if (last_dex_dot != std::string::npos) {
name.resize(last_dex_dot);
}
- locations.push_back(base + name + extension);
+ locations.push_back(ART_FORMAT("{}{}{}", base, name, extension));
}
return locations;
}
diff --git a/runtime/gc/space/image_space_test.cc b/runtime/gc/space/image_space_test.cc
index 5f4039cedb..2a67f16b90 100644
--- a/runtime/gc/space/image_space_test.cc
+++ b/runtime/gc/space/image_space_test.cc
@@ -83,14 +83,15 @@ TEST_F(ImageSpaceTest, StringDeduplication) {
std::vector<std::string> extra_args = {
"--profile-file=" + profile_file.GetFilename(),
"--runtime-arg",
- "-Xbootclasspath:" + base_bcp_string + ':' + jar_name,
+ ART_FORMAT("-Xbootclasspath:{}:{}", base_bcp_string, jar_name),
"--runtime-arg",
- "-Xbootclasspath-locations:" + base_bcp_locations_string + ':' + jar_name,
+ ART_FORMAT("-Xbootclasspath-locations:{}:{}", base_bcp_locations_string, jar_name),
"--boot-image=" + base_image_location,
};
std::string prefix = GetFilenameBase(base_image_location);
std::string error_msg;
- bool success = CompileBootImage(extra_args, image_dir + '/' + prefix, dex_files, &error_msg);
+ bool success =
+ CompileBootImage(extra_args, ART_FORMAT("{}/{}", image_dir, prefix), dex_files, &error_msg);
ASSERT_TRUE(success) << error_msg;
bcp.push_back(jar_name);
bcp_locations.push_back(jar_name);
diff --git a/runtime/verifier/class_verifier.cc b/runtime/verifier/class_verifier.cc
index 40584f401b..084e714b42 100644
--- a/runtime/verifier/class_verifier.cc
+++ b/runtime/verifier/class_verifier.cc
@@ -159,8 +159,9 @@ FailureKind ClassVerifier::VerifyClass(Thread* self,
StringPrintf("Method %s failed lock verification and will run slower.",
dex_file->PrettyMethod(method.GetIndex()).c_str());
if (!gPrintedDxMonitorText) {
- tmp = tmp + "\nCommon causes for lock verification issues are non-optimized dex code\n"
- "and incorrect proguard optimizations.";
+ tmp +=
+ "\nCommon causes for lock verification issues are non-optimized dex code\n"
+ "and incorrect proguard optimizations.";
gPrintedDxMonitorText = true;
}
LOG(WARNING) << tmp;
diff --git a/runtime/verifier/verifier_deps.cc b/runtime/verifier/verifier_deps.cc
index e9e488b2f4..3286a605e8 100644
--- a/runtime/verifier/verifier_deps.cc
+++ b/runtime/verifier/verifier_deps.cc
@@ -728,7 +728,7 @@ bool VerifierDeps::VerifyAssignability(Handle<mirror::ClassLoader> class_loader,
DCHECK(destination->IsResolved() && source->IsResolved());
if (!destination->IsAssignableFrom(source.Get())) {
- *error_msg = "Class " + destination_desc + " not assignable from " + source_desc;
+ *error_msg = ART_FORMAT("Class {} not assignable from {}", destination_desc, source_desc);
return false;
}
}
diff --git a/tools/veridex/hidden_api_finder.cc b/tools/veridex/hidden_api_finder.cc
index d7ed1e4345..0f9ed52e3d 100644
--- a/tools/veridex/hidden_api_finder.cc
+++ b/tools/veridex/hidden_api_finder.cc
@@ -217,7 +217,7 @@ void HiddenApiFinder::Dump(std::ostream& os,
// Dump potential reflection uses.
for (const std::string& cls : classes_) {
for (const std::string& name : strings_) {
- std::string full_name = cls + "->" + name;
+ std::string full_name = ART_FORMAT("{}->{}", cls, name);
if (hidden_api_.GetSignatureSource(full_name) != SignatureSource::APP &&
hidden_api_.ShouldReport(full_name)) {
hiddenapi::ApiList api_list = hidden_api_.GetApiList(full_name);
diff --git a/tools/veridex/precise_hidden_api_finder.cc b/tools/veridex/precise_hidden_api_finder.cc
index 6f66a3368c..d9eb271bc4 100644
--- a/tools/veridex/precise_hidden_api_finder.cc
+++ b/tools/veridex/precise_hidden_api_finder.cc
@@ -98,7 +98,7 @@ void PreciseHiddenApiFinder::Dump(std::ostream& os, HiddenApiStats* stats) {
for (const ReflectAccessInfo& info : it.second) {
std::string cls(info.cls.ToString());
std::string name(info.name.ToString());
- std::string full_name = cls + "->" + name;
+ std::string full_name = ART_FORMAT("{}->{}", cls, name);
named_uses[full_name].push_back(ref);
}
}