diff options
author | 2016-11-08 08:09:33 -0800 | |
---|---|---|
committer | 2016-11-08 15:04:48 -0800 | |
commit | ca620d7bc03b23a0bcf0ef58df58603ee000dca0 (patch) | |
tree | 07cb026075b70a958d14ae84b4e213178a6ba0b4 | |
parent | b02b8d7df48ea3314cfcb3c08d84ac9556363833 (diff) |
ART: Fix tidy warnings
Switch to char versions of find variants.
Add "explicit" constructor variants or refactor and
remove defaults.
Use const references.
Bug: 32619234
Test: m test-art-host
Change-Id: I970cc2f47d6cf8f0c74104b994b075b2fafb3d45
33 files changed, 61 insertions, 61 deletions
diff --git a/cmdline/cmdline.h b/cmdline/cmdline.h index dec9c83165..6e042c3c27 100644 --- a/cmdline/cmdline.h +++ b/cmdline/cmdline.h @@ -234,7 +234,7 @@ struct CmdlineArgs { // Checks for --boot-image location. { std::string boot_image_location = boot_image_location_; - size_t file_name_idx = boot_image_location.rfind("/"); + size_t file_name_idx = boot_image_location.rfind('/'); if (file_name_idx == std::string::npos) { // Prevent a InsertIsaDirectory check failure. *error_msg = "Boot image location must have a / in it"; return false; @@ -244,7 +244,7 @@ struct CmdlineArgs { // This prevents a common error "Could not create an image space..." when initing the Runtime. if (file_name_idx != std::string::npos) { std::string no_file_name = boot_image_location.substr(0, file_name_idx); - size_t ancestor_dirs_idx = no_file_name.rfind("/"); + size_t ancestor_dirs_idx = no_file_name.rfind('/'); std::string parent_dir_name; if (ancestor_dirs_idx != std::string::npos) { diff --git a/cmdline/cmdline_parser.h b/cmdline/cmdline_parser.h index cfc096728f..d82fd488e9 100644 --- a/cmdline/cmdline_parser.h +++ b/cmdline/cmdline_parser.h @@ -390,7 +390,7 @@ struct CmdlineParser { // Unlike regular argument definitions, when a value gets parsed into its // stronger type, we just throw it away. - if (ign.find("_") != std::string::npos) { // Does the arg-def have a wildcard? + if (ign.find('_') != std::string::npos) { // Does the arg-def have a wildcard? // pretend this is a string, e.g. -Xjitconfig:<anythinggoeshere> auto&& builder = Define(ignore_name).template WithType<std::string>().IntoIgnore(); assert(&builder == this); diff --git a/cmdline/cmdline_parser_test.cc b/cmdline/cmdline_parser_test.cc index cad51045aa..550e8c4605 100644 --- a/cmdline/cmdline_parser_test.cc +++ b/cmdline/cmdline_parser_test.cc @@ -78,7 +78,7 @@ namespace art { return memcmp(std::addressof(expected), std::addressof(actual), sizeof(expected)) == 0; } - bool UsuallyEquals(const char* expected, std::string actual) { + bool UsuallyEquals(const char* expected, const std::string& actual) { return std::string(expected) == actual; } @@ -129,7 +129,7 @@ class CmdlineParserTest : public ::testing::Test { parser_ = ParsedOptions::MakeParser(false); // do not ignore unrecognized options } - static ::testing::AssertionResult IsResultSuccessful(CmdlineResult result) { + static ::testing::AssertionResult IsResultSuccessful(const CmdlineResult& result) { if (result.IsSuccess()) { return ::testing::AssertionSuccess(); } else { @@ -138,7 +138,7 @@ class CmdlineParserTest : public ::testing::Test { } } - static ::testing::AssertionResult IsResultFailure(CmdlineResult result, + static ::testing::AssertionResult IsResultFailure(const CmdlineResult& result, CmdlineResult::Status failure_status) { if (result.IsSuccess()) { return ::testing::AssertionFailure() << " got success but expected failure: " diff --git a/cmdline/cmdline_types.h b/cmdline/cmdline_types.h index a5bb117509..3f55eefa0e 100644 --- a/cmdline/cmdline_types.h +++ b/cmdline/cmdline_types.h @@ -696,7 +696,7 @@ struct CmdlineType<ProfileSaverOptions> : CmdlineTypeParser<ProfileSaverOptions> } static std::string RemovePrefix(const std::string& source) { - size_t prefix_idx = source.find(":"); + size_t prefix_idx = source.find(':'); if (prefix_idx == std::string::npos) { return ""; diff --git a/cmdline/detail/cmdline_parse_argument_detail.h b/cmdline/detail/cmdline_parse_argument_detail.h index 84beff59c7..14eac30aa1 100644 --- a/cmdline/detail/cmdline_parse_argument_detail.h +++ b/cmdline/detail/cmdline_parse_argument_detail.h @@ -108,7 +108,7 @@ namespace art { // If this is true, then the wildcard matching later on can still fail, so this is not // a guarantee that the argument is correct, it's more of a strong hint that the // user-provided input *probably* was trying to match this argument. - size_t MaybeMatches(TokenRange token_list) const { + size_t MaybeMatches(const TokenRange& token_list) const { auto best_match = FindClosestMatch(token_list); return best_match.second; @@ -118,7 +118,7 @@ namespace art { // // Returns the token range that was the closest match and the # of tokens that // this range was matched up until. - std::pair<const TokenRange*, size_t> FindClosestMatch(TokenRange token_list) const { + std::pair<const TokenRange*, size_t> FindClosestMatch(const TokenRange& token_list) const { const TokenRange* best_match_ptr = nullptr; size_t best_match = 0; diff --git a/compiler/optimizing/bytecode_utils.h b/compiler/optimizing/bytecode_utils.h index 6dfffce117..133afa47fe 100644 --- a/compiler/optimizing/bytecode_utils.h +++ b/compiler/optimizing/bytecode_utils.h @@ -26,7 +26,8 @@ namespace art { class CodeItemIterator : public ValueObject { public: - CodeItemIterator(const DexFile::CodeItem& code_item, uint32_t start_dex_pc = 0u) + explicit CodeItemIterator(const DexFile::CodeItem& code_item) : CodeItemIterator(code_item, 0u) {} + CodeItemIterator(const DexFile::CodeItem& code_item, uint32_t start_dex_pc) : code_ptr_(code_item.insns_ + start_dex_pc), code_end_(code_item.insns_ + code_item.insns_size_in_code_units_), dex_pc_(start_dex_pc) {} diff --git a/compiler/optimizing/code_generator_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc index e69528e43f..2b829cc562 100644 --- a/compiler/optimizing/code_generator_arm_vixl.cc +++ b/compiler/optimizing/code_generator_arm_vixl.cc @@ -660,7 +660,7 @@ CodeGeneratorARMVIXL::CodeGeneratorARMVIXL(HGraph* graph, GetVIXLAssembler()->GetScratchVRegisterList()->Combine(d15); } -#define __ reinterpret_cast<ArmVIXLAssembler*>(GetAssembler())->GetVIXLAssembler()-> +#define __ reinterpret_cast<ArmVIXLAssembler*>(GetAssembler())->GetVIXLAssembler()-> // NOLINT void CodeGeneratorARMVIXL::Finalize(CodeAllocator* allocator) { GetAssembler()->FinalizeCode(); diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc index 9ec32df578..ac83bd9b0c 100644 --- a/compiler/optimizing/codegen_test.cc +++ b/compiler/optimizing/codegen_test.cc @@ -259,7 +259,7 @@ static void ValidateGraph(HGraph* graph) { GraphChecker graph_checker(graph); graph_checker.Run(); if (!graph_checker.IsValid()) { - for (auto error : graph_checker.GetErrors()) { + for (const auto& error : graph_checker.GetErrors()) { std::cout << error << std::endl; } } @@ -269,7 +269,7 @@ static void ValidateGraph(HGraph* graph) { template <typename Expected> static void RunCodeNoCheck(CodeGenerator* codegen, HGraph* graph, - std::function<void(HGraph*)> hook_before_codegen, + const std::function<void(HGraph*)>& hook_before_codegen, bool has_result, Expected expected) { SsaLivenessAnalysis liveness(graph, codegen); diff --git a/compiler/optimizing/constant_folding.h b/compiler/optimizing/constant_folding.h index e10b1d6b2e..05c6df4a93 100644 --- a/compiler/optimizing/constant_folding.h +++ b/compiler/optimizing/constant_folding.h @@ -39,8 +39,7 @@ namespace art { */ class HConstantFolding : public HOptimization { public: - HConstantFolding(HGraph* graph, const char* name = kConstantFoldingPassName) - : HOptimization(graph, name) {} + HConstantFolding(HGraph* graph, const char* name) : HOptimization(graph, name) {} void Run() OVERRIDE; diff --git a/compiler/optimizing/constant_folding_test.cc b/compiler/optimizing/constant_folding_test.cc index d1a2a2649a..5fac3acb8a 100644 --- a/compiler/optimizing/constant_folding_test.cc +++ b/compiler/optimizing/constant_folding_test.cc @@ -42,7 +42,7 @@ class ConstantFoldingTest : public CommonCompilerTest { const std::string& expected_before, const std::string& expected_after_cf, const std::string& expected_after_dce, - std::function<void(HGraph*)> check_after_cf, + const std::function<void(HGraph*)>& check_after_cf, Primitive::Type return_type = Primitive::kPrimInt) { graph_ = CreateCFG(&allocator_, data, return_type); TestCodeOnReadyGraph(expected_before, @@ -54,7 +54,7 @@ class ConstantFoldingTest : public CommonCompilerTest { void TestCodeOnReadyGraph(const std::string& expected_before, const std::string& expected_after_cf, const std::string& expected_after_dce, - std::function<void(HGraph*)> check_after_cf) { + const std::function<void(HGraph*)>& check_after_cf) { ASSERT_NE(graph_, nullptr); StringPrettyPrinter printer_before(graph_); @@ -65,7 +65,7 @@ class ConstantFoldingTest : public CommonCompilerTest { std::unique_ptr<const X86InstructionSetFeatures> features_x86( X86InstructionSetFeatures::FromCppDefines()); x86::CodeGeneratorX86 codegenX86(graph_, *features_x86.get(), CompilerOptions()); - HConstantFolding(graph_).Run(); + HConstantFolding(graph_, "constant_folding").Run(); GraphChecker graph_checker_cf(graph_); graph_checker_cf.Run(); ASSERT_TRUE(graph_checker_cf.IsValid()); @@ -77,7 +77,7 @@ class ConstantFoldingTest : public CommonCompilerTest { check_after_cf(graph_); - HDeadCodeElimination(graph_).Run(); + HDeadCodeElimination(graph_, nullptr /* stats */, "dead_code_elimination").Run(); GraphChecker graph_checker_dce(graph_); graph_checker_dce.Run(); ASSERT_TRUE(graph_checker_dce.IsValid()); diff --git a/compiler/optimizing/dead_code_elimination.h b/compiler/optimizing/dead_code_elimination.h index 58e700deba..84fd890eee 100644 --- a/compiler/optimizing/dead_code_elimination.h +++ b/compiler/optimizing/dead_code_elimination.h @@ -29,9 +29,7 @@ namespace art { */ class HDeadCodeElimination : public HOptimization { public: - HDeadCodeElimination(HGraph* graph, - OptimizingCompilerStats* stats = nullptr, - const char* name = kDeadCodeEliminationPassName) + HDeadCodeElimination(HGraph* graph, OptimizingCompilerStats* stats, const char* name) : HOptimization(graph, name, stats) {} void Run() OVERRIDE; diff --git a/compiler/optimizing/dead_code_elimination_test.cc b/compiler/optimizing/dead_code_elimination_test.cc index fe52aacef7..fdd77e7261 100644 --- a/compiler/optimizing/dead_code_elimination_test.cc +++ b/compiler/optimizing/dead_code_elimination_test.cc @@ -44,7 +44,7 @@ static void TestCode(const uint16_t* data, std::unique_ptr<const X86InstructionSetFeatures> features_x86( X86InstructionSetFeatures::FromCppDefines()); x86::CodeGeneratorX86 codegenX86(graph, *features_x86.get(), CompilerOptions()); - HDeadCodeElimination(graph).Run(); + HDeadCodeElimination(graph, nullptr /* stats */, "dead_code_elimination").Run(); GraphChecker graph_checker(graph); graph_checker.Run(); ASSERT_TRUE(graph_checker.IsValid()); diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index cc420b3260..9e816237dd 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -1315,8 +1315,8 @@ size_t HInliner::RunOptimizations(HGraph* callee_graph, const DexCompilationUnit& dex_compilation_unit) { // Note: if the outermost_graph_ is being compiled OSR, we should not run any // optimization that could lead to a HDeoptimize. The following optimizations do not. - HDeadCodeElimination dce(callee_graph, stats_); - HConstantFolding fold(callee_graph); + HDeadCodeElimination dce(callee_graph, stats_, "dead_code_elimination$inliner"); + HConstantFolding fold(callee_graph, "constant_folding$inliner"); HSharpening sharpening(callee_graph, codegen_, dex_compilation_unit, compiler_driver_); InstructionSimplifier simplify(callee_graph, stats_); IntrinsicsRecognizer intrinsics(callee_graph, stats_); diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index a4847601f5..6f84cdcc4f 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -758,7 +758,7 @@ void OptimizingCompiler::RunOptimizations(HGraph* graph, graph, stats, "dead_code_elimination$after_inlining"); HDeadCodeElimination* dce3 = new (arena) HDeadCodeElimination( graph, stats, "dead_code_elimination$final"); - HConstantFolding* fold1 = new (arena) HConstantFolding(graph); + HConstantFolding* fold1 = new (arena) HConstantFolding(graph, "constant_folding"); InstructionSimplifier* simplify1 = new (arena) InstructionSimplifier(graph, stats); HSelectGenerator* select_generator = new (arena) HSelectGenerator(graph, stats); HConstantFolding* fold2 = new (arena) HConstantFolding( diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc index 58dd047081..fa32178796 100644 --- a/dex2oat/dex2oat_test.cc +++ b/dex2oat/dex2oat_test.cc @@ -438,9 +438,7 @@ class Dex2oatVeryLargeTest : public Dex2oatTest { Copy(GetDexSrc1(), dex_location); - std::vector<std::string> copy(extra_args); - - GenerateOdexForTest(dex_location, odex_location, filter, copy); + GenerateOdexForTest(dex_location, odex_location, filter, extra_args); CheckValidity(); ASSERT_TRUE(success_); diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc index 2b30a1be08..aa806557c2 100644 --- a/dexlayout/dexlayout.cc +++ b/dexlayout/dexlayout.cc @@ -1527,7 +1527,7 @@ static void ProcessDexFile(const char* file_name, const DexFile* dex_file, size_ // Output dex file. if (options_.output_dex_directory_ != nullptr) { std::string output_location(options_.output_dex_directory_); - size_t last_slash = dex_file->GetLocation().rfind("/"); + size_t last_slash = dex_file->GetLocation().rfind('/'); output_location.append(dex_file->GetLocation().substr(last_slash)); DexWriter::OutputDexFile(*header, output_location.c_str()); } diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc index 89544d7ef4..c7f36be905 100644 --- a/dexlayout/dexlayout_test.cc +++ b/dexlayout/dexlayout_test.cc @@ -37,12 +37,12 @@ class DexLayoutTest : public CommonRuntimeTest { bool FullPlainOutputExec(std::string* error_msg) { // TODO: dexdump2 -> dexdump ? ScratchFile dexdump_output; - std::string dexdump_filename = dexdump_output.GetFilename(); + const std::string& dexdump_filename = dexdump_output.GetFilename(); std::string dexdump = GetTestAndroidRoot() + "/bin/dexdump2"; EXPECT_TRUE(OS::FileExists(dexdump.c_str())) << dexdump << " should be a valid file path"; ScratchFile dexlayout_output; - std::string dexlayout_filename = dexlayout_output.GetFilename(); + const std::string& dexlayout_filename = dexlayout_output.GetFilename(); std::string dexlayout = GetTestAndroidRoot() + "/bin/dexlayout"; EXPECT_TRUE(OS::FileExists(dexlayout.c_str())) << dexlayout << " should be a valid file path"; @@ -70,8 +70,8 @@ class DexLayoutTest : public CommonRuntimeTest { // Runs DexFileOutput test. bool DexFileOutputExec(std::string* error_msg) { ScratchFile tmp_file; - std::string tmp_name = tmp_file.GetFilename(); - size_t tmp_last_slash = tmp_name.rfind("/"); + const std::string& tmp_name = tmp_file.GetFilename(); + size_t tmp_last_slash = tmp_name.rfind('/'); std::string tmp_dir = tmp_name.substr(0, tmp_last_slash + 1); std::string dexlayout = GetTestAndroidRoot() + "/bin/dexlayout"; EXPECT_TRUE(OS::FileExists(dexlayout.c_str())) << dexlayout << " should be a valid file path"; @@ -84,7 +84,7 @@ class DexLayoutTest : public CommonRuntimeTest { return false; } - size_t dex_file_last_slash = dex_file.rfind("/"); + size_t dex_file_last_slash = dex_file.rfind('/'); std::string dex_file_name = dex_file.substr(dex_file_last_slash + 1); std::vector<std::string> unzip_exec_argv = { "/usr/bin/unzip", dex_file, "classes.dex", "-d", tmp_dir}; diff --git a/imgdiag/imgdiag.cc b/imgdiag/imgdiag.cc index d1d127d980..a374686dc5 100644 --- a/imgdiag/imgdiag.cc +++ b/imgdiag/imgdiag.cc @@ -89,7 +89,7 @@ class ImgDiagDumper { // Return suffix of the file path after the last /. (e.g. /foo/bar -> bar, bar -> bar) static std::string BaseName(const std::string& str) { - size_t idx = str.rfind("/"); + size_t idx = str.rfind('/'); if (idx == std::string::npos) { return str; } diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index 7ea5beab37..3c8c1a397c 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -1068,7 +1068,7 @@ static int patchoat_image(TimingLogger& timings, TimingLogger::ScopedTiming pt("patch image and oat", &timings); std::string output_directory = - output_image_filename.substr(0, output_image_filename.find_last_of("/")); + output_image_filename.substr(0, output_image_filename.find_last_of('/')); bool ret = PatchOat::Patch(input_image_location, base_delta, output_directory, isa, &timings); if (kIsDebugBuild) { diff --git a/runtime/base/variant_map_test.cc b/runtime/base/variant_map_test.cc index ccb22eb64d..93336e0ac3 100644 --- a/runtime/base/variant_map_test.cc +++ b/runtime/base/variant_map_test.cc @@ -107,8 +107,8 @@ TEST(VariantMaps, RuleOfFive) { fmFilled.Set(FruitMap::Orange, 555.0); EXPECT_EQ(size_t(2), fmFilled.Size()); - // Test copy constructor - FruitMap fmEmptyCopy(fmEmpty); + // Test copy constructor (NOLINT as a reference is suggested, instead) + FruitMap fmEmptyCopy(fmEmpty); // NOLINT EXPECT_EQ(size_t(0), fmEmptyCopy.Size()); // Test copy constructor diff --git a/runtime/dex_file_verifier_test.cc b/runtime/dex_file_verifier_test.cc index e39287018a..3801c228c0 100644 --- a/runtime/dex_file_verifier_test.cc +++ b/runtime/dex_file_verifier_test.cc @@ -58,7 +58,7 @@ class DexFileVerifierTest : public CommonRuntimeTest { void VerifyModification(const char* dex_file_base64_content, const char* location, - std::function<void(DexFile*)> f, + const std::function<void(DexFile*)>& f, const char* expected_error) { size_t length; std::unique_ptr<uint8_t[]> dex_bytes(DecodeBase64(dex_file_base64_content, &length)); diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc index 8d85425c10..adf35b6f01 100644 --- a/runtime/native/dalvik_system_VMDebug.cc +++ b/runtime/native/dalvik_system_VMDebug.cc @@ -420,8 +420,10 @@ static jobject VMDebug_getRuntimeStatInternal(JNIEnv* env, jclass, jint statId) } } -static bool SetRuntimeStatValue(JNIEnv* env, jobjectArray result, VMDebugRuntimeStatId id, - std::string value) { +static bool SetRuntimeStatValue(JNIEnv* env, + jobjectArray result, + VMDebugRuntimeStatId id, + const std::string& value) { ScopedLocalRef<jstring> jvalue(env, env->NewStringUTF(value.c_str())); if (jvalue.get() == nullptr) { return false; diff --git a/runtime/native_bridge_art_interface.cc b/runtime/native_bridge_art_interface.cc index 5ab6097aa4..71d3232af7 100644 --- a/runtime/native_bridge_art_interface.cc +++ b/runtime/native_bridge_art_interface.cc @@ -90,14 +90,14 @@ static android::NativeBridgeRuntimeCallbacks native_bridge_art_callbacks_ { GetMethodShorty, GetNativeMethodCount, GetNativeMethods }; -bool LoadNativeBridge(std::string& native_bridge_library_filename) { +bool LoadNativeBridge(const std::string& native_bridge_library_filename) { VLOG(startup) << "Runtime::Setup native bridge library: " << (native_bridge_library_filename.empty() ? "(empty)" : native_bridge_library_filename); return android::LoadNativeBridge(native_bridge_library_filename.c_str(), &native_bridge_art_callbacks_); } -void PreInitializeNativeBridge(std::string dir) { +void PreInitializeNativeBridge(const std::string& dir) { VLOG(startup) << "Runtime::Pre-initialize native bridge"; #ifndef __APPLE__ // Mac OS does not support CLONE_NEWNS. if (unshare(CLONE_NEWNS) == -1) { diff --git a/runtime/native_bridge_art_interface.h b/runtime/native_bridge_art_interface.h index 090cddb9b6..c86e5da0df 100644 --- a/runtime/native_bridge_art_interface.h +++ b/runtime/native_bridge_art_interface.h @@ -26,10 +26,10 @@ namespace art { // Mirror libnativebridge interface. Done to have the ART callbacks out of line, and not require // the system/core header file in other files. -bool LoadNativeBridge(std::string& native_bridge_library_filename); +bool LoadNativeBridge(const std::string& native_bridge_library_filename); // This is mostly for testing purposes, as in a full system this is called by Zygote code. -void PreInitializeNativeBridge(std::string dir); +void PreInitializeNativeBridge(const std::string& dir); void InitializeNativeBridge(JNIEnv* env, const char* instruction_set); diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc index 00ab5771da..23768899bd 100644 --- a/runtime/native_stack_dump.cc +++ b/runtime/native_stack_dump.cc @@ -256,7 +256,7 @@ static void Addr2line(const std::string& map_src, Drain(2U, prefix, pipe, os); } -static bool RunCommand(std::string cmd) { +static bool RunCommand(const std::string& cmd) { FILE* stream = popen(cmd.c_str(), "r"); if (stream) { pclose(stream); diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc index d18e9464e6..d4337b971b 100644 --- a/runtime/oat_file_assistant_test.cc +++ b/runtime/oat_file_assistant_test.cc @@ -999,7 +999,7 @@ TEST_F(OatFileAssistantTest, GenNoDex) { // Turn an absolute path into a path relative to the current working // directory. -static std::string MakePathRelative(std::string target) { +static std::string MakePathRelative(const std::string& target) { char buf[MAXPATHLEN]; std::string cwd = getcwd(buf, MAXPATHLEN); diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc index cf9efe0782..f2b3542699 100644 --- a/runtime/oat_file_manager.cc +++ b/runtime/oat_file_manager.cc @@ -224,9 +224,10 @@ static void AddNext(/*inout*/DexFileAndClassPair* original, } } +template <typename T> static void IterateOverJavaDexFile(ObjPtr<mirror::Object> dex_file, ArtField* const cookie_field, - std::function<bool(const DexFile*)> fn) + const T& fn) REQUIRES_SHARED(Locks::mutator_lock_) { if (dex_file != nullptr) { mirror::LongArray* long_array = cookie_field->GetObject(dex_file)->AsLongArray(); @@ -247,11 +248,12 @@ static void IterateOverJavaDexFile(ObjPtr<mirror::Object> dex_file, } } +template <typename T> static void IterateOverPathClassLoader( ScopedObjectAccessAlreadyRunnable& soa, Handle<mirror::ClassLoader> class_loader, MutableHandle<mirror::ObjectArray<mirror::Object>> dex_elements, - std::function<bool(const DexFile*)> fn) REQUIRES_SHARED(Locks::mutator_lock_) { + const T& fn) REQUIRES_SHARED(Locks::mutator_lock_) { // Handle this step. // Handle as if this is the child PathClassLoader. // The class loader is a PathClassLoader which inherits from BaseDexClassLoader. diff --git a/runtime/openjdkjvmti/transform.cc b/runtime/openjdkjvmti/transform.cc index 3443aea744..fa2983c19c 100644 --- a/runtime/openjdkjvmti/transform.cc +++ b/runtime/openjdkjvmti/transform.cc @@ -283,7 +283,7 @@ jvmtiError GetTransformationData(ArtJvmTiEnv* env, // Install the new dex file. // TODO do error checks for bad state (method in a stack, changes to number of methods/fields/etc). jvmtiError MoveTransformedFileIntoRuntime(jclass jklass, - std::string original_location, + const std::string& original_location, jint data_len, unsigned char* dex_data) { const char* dex_file_name = "Ldalvik/system/DexFile;"; diff --git a/runtime/openjdkjvmti/transform.h b/runtime/openjdkjvmti/transform.h index 85bcb00eca..a76ed939b5 100644 --- a/runtime/openjdkjvmti/transform.h +++ b/runtime/openjdkjvmti/transform.h @@ -54,7 +54,7 @@ jvmtiError GetTransformationData(ArtJvmTiEnv* env, // Install the new dex file. jvmtiError MoveTransformedFileIntoRuntime(jclass jklass, - std::string original_location, + const std::string& original_location, jint data_len, unsigned char* dex_data); diff --git a/runtime/plugin.h b/runtime/plugin.h index 18f3977bd5..f077aaf3fb 100644 --- a/runtime/plugin.h +++ b/runtime/plugin.h @@ -34,7 +34,7 @@ using PluginDeinitializationFunction = bool (*)(); // single-threaded fashion so not much need class Plugin { public: - static Plugin Create(std::string lib) { + static Plugin Create(const std::string& lib) { return Plugin(lib); } @@ -66,7 +66,7 @@ class Plugin { } private: - explicit Plugin(std::string library) : library_(library), dlopen_handle_(nullptr) { } + explicit Plugin(const std::string& library) : library_(library), dlopen_handle_(nullptr) { } std::string library_; void* dlopen_handle_; diff --git a/runtime/utf_test.cc b/runtime/utf_test.cc index 328492523f..d1e97515d3 100644 --- a/runtime/utf_test.cc +++ b/runtime/utf_test.cc @@ -113,8 +113,8 @@ TEST_F(UtfTest, CountModifiedUtf8Chars) { EXPECT_EQ(2u, CountModifiedUtf8Chars(reinterpret_cast<const char *>(kSurrogateEncoding))); } -static void AssertConversion(const std::vector<uint16_t> input, - const std::vector<uint8_t> expected) { +static void AssertConversion(const std::vector<uint16_t>& input, + const std::vector<uint8_t>& expected) { ASSERT_EQ(expected.size(), CountUtf8Bytes(&input[0], input.size())); std::vector<uint8_t> output(expected.size()); diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc index 53d717a8ff..68ebcdf79f 100644 --- a/runtime/well_known_classes.cc +++ b/runtime/well_known_classes.cc @@ -239,8 +239,8 @@ void Thread::InitStringEntryPoints() { ArtMethod* WellKnownClasses::StringInitToStringFactory(ArtMethod* string_init) { #define TO_STRING_FACTORY(init_runtime_name, init_signature, new_runtime_name, \ new_java_name, new_signature, entry_point_name) \ - if (string_init == init_runtime_name) { \ - return new_runtime_name; \ + if (string_init == (init_runtime_name)) { \ + return (new_runtime_name); \ } STRING_INIT_LIST(TO_STRING_FACTORY) #undef TO_STRING_FACTORY @@ -251,7 +251,7 @@ ArtMethod* WellKnownClasses::StringInitToStringFactory(ArtMethod* string_init) { uint32_t WellKnownClasses::StringInitToEntryPoint(ArtMethod* string_init) { #define TO_ENTRY_POINT(init_runtime_name, init_signature, new_runtime_name, \ new_java_name, new_signature, entry_point_name) \ - if (string_init == init_runtime_name) { \ + if (string_init == (init_runtime_name)) { \ return kQuick ## entry_point_name; \ } STRING_INIT_LIST(TO_ENTRY_POINT) diff --git a/tools/cpp-define-generator/main.cc b/tools/cpp-define-generator/main.cc index a1b463a92d..fc99f8abc7 100644 --- a/tools/cpp-define-generator/main.cc +++ b/tools/cpp-define-generator/main.cc @@ -59,12 +59,12 @@ pretty_format(T value) { } template <typename T> -void cpp_define(std::string name, T value) { +void cpp_define(const std::string& name, T value) { std::cout << "#define " << name << " " << pretty_format(value) << std::endl; } template <typename T> -void emit_check_eq(T value, std::string expr) { +void emit_check_eq(T value, const std::string& expr) { std::cout << "DEFINE_CHECK_EQ(" << value << ", (" << expr << "))" << std::endl; } |