Skip to content

Commit

Permalink
ART: Refactor for bugprone-argument-comment
Browse files Browse the repository at this point in the history
Handles compiler.

Bug: 116054210
Test: WITH_TIDY=1 mmma art
Change-Id: I5cdfe73c31ac39144838a2736146b71de037425e
  • Loading branch information
agampe committed Dec 27, 2018
1 parent 1650daf commit 3db7068
Show file tree
Hide file tree
Showing 87 changed files with 1,208 additions and 1,205 deletions.
8 changes: 4 additions & 4 deletions compiler/cfi_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ class CFITest : public dwarf::DwarfTest {
dwarf::WriteCIE(is64bit, dwarf::Reg(8), initial_opcodes, kCFIFormat, &debug_frame_data_);
std::vector<uintptr_t> debug_frame_patches;
dwarf::WriteFDE(is64bit,
/* section_address */ 0,
/* cie_address */ 0,
/* code_address */ 0,
/* section_address= */ 0,
/* cie_address= */ 0,
/* code_address= */ 0,
actual_asm.size(),
actual_cfi,
kCFIFormat,
/* buffer_address */ 0,
/* buffer_address= */ 0,
&debug_frame_data_,
&debug_frame_patches);
ReformatCfi(Objdump(false, "-W"), &lines);
Expand Down
2 changes: 1 addition & 1 deletion compiler/common_compiler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void CommonCompilerTest::CreateCompilerDriver() {
compiler_driver_.reset(new CompilerDriver(compiler_options_.get(),
compiler_kind_,
number_of_threads_,
/* swap_fd */ -1));
/* swap_fd= */ -1));
}

void CommonCompilerTest::SetUpRuntimeOptions(RuntimeOptions* options) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/compiled_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CompiledMethod final : public CompiledCode {
// This affects debug information generated at link time.
void MarkAsIntrinsic() {
DCHECK(!IsIntrinsic());
SetPackedField<IsIntrinsicField>(/* value */ true);
SetPackedField<IsIntrinsicField>(/* value= */ true);
}

ArrayRef<const uint8_t> GetVmapTable() const;
Expand Down
2 changes: 1 addition & 1 deletion compiler/debug/dwarf/dwarf_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ TEST_F(DwarfTest, DebugInfo) {

std::vector<uintptr_t> debug_info_patches;
std::vector<uintptr_t> expected_patches = { 16, 20, 29, 33, 42, 46 };
dwarf::WriteDebugInfoCU(0 /* debug_abbrev_offset */, info,
dwarf::WriteDebugInfoCU(/* debug_abbrev_offset= */ 0, info,
0, &debug_info_data_, &debug_info_patches);

EXPECT_EQ(expected_patches, debug_info_patches);
Expand Down
20 changes: 10 additions & 10 deletions compiler/debug/elf_debug_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void WriteDebugInfo(linker::ElfBuilder<ElfTypes>* builder,
dwarf::CFIFormat cfi_format,
bool write_oat_patches) {
// Write .strtab and .symtab.
WriteDebugSymbols(builder, false /* mini-debug-info */, debug_info);
WriteDebugSymbols(builder, /* mini-debug-info= */ false, debug_info);

// Write .debug_frame.
WriteCFISection(builder, debug_info.compiled_methods, cfi_format, write_oat_patches);
Expand Down Expand Up @@ -125,17 +125,17 @@ static std::vector<uint8_t> MakeMiniDebugInfoInternal(
linker::VectorOutputStream out("Mini-debug-info ELF file", &buffer);
std::unique_ptr<linker::ElfBuilder<ElfTypes>> builder(
new linker::ElfBuilder<ElfTypes>(isa, features, &out));
builder->Start(false /* write_program_headers */);
builder->Start(/* write_program_headers= */ false);
// Mirror ELF sections as NOBITS since the added symbols will reference them.
builder->GetText()->AllocateVirtualMemory(text_section_address, text_section_size);
if (dex_section_size != 0) {
builder->GetDex()->AllocateVirtualMemory(dex_section_address, dex_section_size);
}
WriteDebugSymbols(builder.get(), true /* mini-debug-info */, debug_info);
WriteDebugSymbols(builder.get(), /* mini-debug-info= */ true, debug_info);
WriteCFISection(builder.get(),
debug_info.compiled_methods,
dwarf::DW_DEBUG_FRAME_FORMAT,
false /* write_oat_paches */);
/* write_oat_patches= */ false);
builder->End();
CHECK(builder->Good());
std::vector<uint8_t> compressed_buffer;
Expand Down Expand Up @@ -187,21 +187,21 @@ std::vector<uint8_t> MakeElfFileForJIT(
std::unique_ptr<linker::ElfBuilder<ElfTypes>> builder(
new linker::ElfBuilder<ElfTypes>(isa, features, &out));
// No program headers since the ELF file is not linked and has no allocated sections.
builder->Start(false /* write_program_headers */);
builder->Start(/* write_program_headers= */ false);
builder->GetText()->AllocateVirtualMemory(method_info.code_address, method_info.code_size);
if (mini_debug_info) {
// The compression is great help for multiple methods but it is not worth it for a
// single method due to the overheads so skip the compression here for performance.
WriteDebugSymbols(builder.get(), true /* mini-debug-info */, debug_info);
WriteDebugSymbols(builder.get(), /* mini-debug-info= */ true, debug_info);
WriteCFISection(builder.get(),
debug_info.compiled_methods,
dwarf::DW_DEBUG_FRAME_FORMAT,
false /* write_oat_paches */);
/* write_oat_patches= */ false);
} else {
WriteDebugInfo(builder.get(),
debug_info,
dwarf::DW_DEBUG_FRAME_FORMAT,
false /* write_oat_patches */);
/* write_oat_patches= */ false);
}
builder->End();
CHECK(builder->Good());
Expand Down Expand Up @@ -359,12 +359,12 @@ std::vector<uint8_t> WriteDebugElfFileForClasses(
std::unique_ptr<linker::ElfBuilder<ElfTypes>> builder(
new linker::ElfBuilder<ElfTypes>(isa, features, &out));
// No program headers since the ELF file is not linked and has no allocated sections.
builder->Start(false /* write_program_headers */);
builder->Start(/* write_program_headers= */ false);
ElfDebugInfoWriter<ElfTypes> info_writer(builder.get());
info_writer.Start();
ElfCompilationUnitWriter<ElfTypes> cu_writer(&info_writer);
cu_writer.Write(types);
info_writer.End(false /* write_oat_patches */);
info_writer.End(/* write_oat_patches= */ false);

builder->End();
CHECK(builder->Good());
Expand Down
2 changes: 1 addition & 1 deletion compiler/dex/dex_to_dex_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ void DexToDexCompiler::CompilationState::CompileInvokeVirtual(Instruction* inst,
method_idx,
unit_.GetDexCache(),
unit_.GetClassLoader(),
/* referrer */ nullptr,
/* referrer= */ nullptr,
kVirtual);

if (UNLIKELY(resolved_method == nullptr)) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/dex/dex_to_dex_decompiler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DexToDexDecompilerTest : public CommonCompilerTest {
optimizer::ArtDecompileDEX(*updated_dex_file,
*accessor.GetCodeItem(method),
table,
/* decompile_return_instruction */ true);
/* decompile_return_instruction= */ true);
}
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/dex/inline_method_analyser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ bool RecordConstructorIPut(ArtMethod* method,
DCHECK(IsInstructionIPut(new_iput->Opcode()));
uint32_t field_index = new_iput->VRegC_22c();
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
ArtField* field = class_linker->LookupResolvedField(field_index, method, /* is_static */ false);
ArtField* field = class_linker->LookupResolvedField(field_index, method, /* is_static= */ false);
if (UNLIKELY(field == nullptr)) {
return false;
}
Expand All @@ -228,7 +228,7 @@ bool RecordConstructorIPut(ArtMethod* method,
}
ArtField* f = class_linker->LookupResolvedField(iputs[old_pos].field_index,
method,
/* is_static */ false);
/* is_static= */ false);
DCHECK(f != nullptr);
if (f == field) {
auto back_it = std::copy(iputs + old_pos + 1, iputs + arraysize(iputs), iputs + old_pos);
Expand Down Expand Up @@ -713,7 +713,7 @@ bool InlineMethodAnalyser::ComputeSpecialAccessorInfo(ArtMethod* method,
}
ObjPtr<mirror::DexCache> dex_cache = method->GetDexCache();
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
ArtField* field = class_linker->LookupResolvedField(field_idx, method, /* is_static */ false);
ArtField* field = class_linker->LookupResolvedField(field_idx, method, /* is_static= */ false);
if (field == nullptr || field->IsStatic()) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/dex/verification_results.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void VerificationResults::CreateVerifiedMethodFor(MethodReference ref) {
// which have no verifier error, nor has methods that we know will throw
// at runtime.
std::unique_ptr<VerifiedMethod> verified_method = std::make_unique<VerifiedMethod>(
/* encountered_error_types */ 0, /* has_runtime_throw */ false);
/* encountered_error_types= */ 0, /* has_runtime_throw= */ false);
if (atomic_verified_methods_.Insert(ref,
/*expected*/ nullptr,
verified_method.get()) ==
Expand Down
6 changes: 3 additions & 3 deletions compiler/dex/verified_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void VerifiedMethod::GenerateSafeCastSet(verifier::MethodVerifier* method_verifi
method_verifier->ResolveCheckedClass(dex::TypeIndex(inst.VRegB_21c()));
// Pass null for the method verifier to not record the VerifierDeps dependency
// if the types are not assignable.
if (cast_type.IsStrictlyAssignableFrom(reg_type, /* method_verifier */ nullptr)) {
if (cast_type.IsStrictlyAssignableFrom(reg_type, /* verifier= */ nullptr)) {
// The types are assignable, we record that dependency in the VerifierDeps so
// that if this changes after OTA, we will re-verify again.
// We check if reg_type has a class, as the verifier may have inferred it's
Expand All @@ -92,8 +92,8 @@ void VerifiedMethod::GenerateSafeCastSet(verifier::MethodVerifier* method_verifi
verifier::VerifierDeps::MaybeRecordAssignability(method_verifier->GetDexFile(),
cast_type.GetClass(),
reg_type.GetClass(),
/* strict */ true,
/* assignable */ true);
/* is_strict= */ true,
/* is_assignable= */ true);
}
if (safe_cast_set_ == nullptr) {
safe_cast_set_.reset(new SafeCastSet());
Expand Down
2 changes: 1 addition & 1 deletion compiler/driver/compiled_method_storage_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
namespace art {

TEST(CompiledMethodStorage, Deduplicate) {
CompiledMethodStorage storage(/* swap_fd */ -1);
CompiledMethodStorage storage(/* swap_fd= */ -1);

ASSERT_TRUE(storage.DedupeEnabled()); // The default.

Expand Down
8 changes: 4 additions & 4 deletions compiler/driver/compiler_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ static void InitializeTypeCheckBitstrings(CompilerDriver* driver,
ObjPtr<mirror::Class> klass =
class_linker->LookupResolvedType(type_index,
dex_cache.Get(),
/* class_loader */ nullptr);
/* class_loader= */ nullptr);
CHECK(klass != nullptr) << descriptor << " should have been previously resolved.";
// Now assign the bitstring if the class is not final. Keep this in sync with sharpening.
if (!klass->IsFinal()) {
Expand Down Expand Up @@ -1191,7 +1191,7 @@ class ClinitImageUpdate {
// Visitor for VisitReferences.
void operator()(ObjPtr<mirror::Object> object,
MemberOffset field_offset,
bool /* is_static */) const
bool is_static ATTRIBUTE_UNUSED) const
REQUIRES_SHARED(Locks::mutator_lock_) {
mirror::Object* ref = object->GetFieldObject<mirror::Object>(field_offset);
if (ref != nullptr) {
Expand Down Expand Up @@ -1361,7 +1361,7 @@ ArtField* CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx,
Handle<mirror::DexCache> dex_cache(mUnit->GetDexCache());
{
Handle<mirror::ClassLoader> class_loader = mUnit->GetClassLoader();
resolved_field = ResolveField(soa, dex_cache, class_loader, field_idx, /* is_static */ false);
resolved_field = ResolveField(soa, dex_cache, class_loader, field_idx, /* is_static= */ false);
referrer_class = resolved_field != nullptr
? ResolveCompilingMethodsClass(soa, dex_cache, class_loader, mUnit) : nullptr;
}
Expand Down Expand Up @@ -2538,7 +2538,7 @@ void CompilerDriver::InitializeClasses(jobject class_loader,
}
if (GetCompilerOptions().IsBootImage()) {
// Prune garbage objects created during aborted transactions.
Runtime::Current()->GetHeap()->CollectGarbage(/* clear_soft_references */ true);
Runtime::Current()->GetHeap()->CollectGarbage(/* clear_soft_references= */ true);
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/exception_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ TEST_F(ExceptionTest, StackTraceElement) {
}

fake_stack.push_back(method_g_->GetOatQuickMethodHeader(0)->ToNativeQuickPc(
method_g_, kDexPc, /* is_catch_handler */ false)); // return pc
method_g_, kDexPc, /* is_for_catch_handler= */ false)); // return pc

// Create/push fake 16byte stack frame for method g
fake_stack.push_back(reinterpret_cast<uintptr_t>(method_g_));
fake_stack.push_back(0);
fake_stack.push_back(0);
fake_stack.push_back(method_g_->GetOatQuickMethodHeader(0)->ToNativeQuickPc(
method_g_, kDexPc, /* is_catch_handler */ false)); // return pc
method_g_, kDexPc, /* is_for_catch_handler= */ false)); // return pc

// Create/push fake 16byte stack frame for method f
fake_stack.push_back(reinterpret_cast<uintptr_t>(method_f_));
Expand Down
4 changes: 2 additions & 2 deletions compiler/jit/jit_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ JitCompiler::JitCompiler() {
compiler_driver_.reset(new CompilerDriver(
compiler_options_.get(),
Compiler::kOptimizing,
/* thread_count */ 1,
/* swap_fd */ -1));
/* thread_count= */ 1,
/* swap_fd= */ -1));
// Disable dedupe so we can remove compiled methods.
compiler_driver_->SetDedupeEnabled(false);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/jni/jni_cfi_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class JNICFITest : public CFITest {
callee_save_regs, mr_conv->EntrySpills());
jni_asm->IncreaseFrameSize(32);
jni_asm->DecreaseFrameSize(32);
jni_asm->RemoveFrame(frame_size, callee_save_regs, /* may_suspend */ true);
jni_asm->RemoveFrame(frame_size, callee_save_regs, /* may_suspend= */ true);
jni_asm->FinalizeCode();
std::vector<uint8_t> actual_asm(jni_asm->CodeSize());
MemoryRegion code(&actual_asm[0], actual_asm.size());
Expand Down
6 changes: 3 additions & 3 deletions compiler/jni/jni_compiler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ void Java_MyClassNatives_normalNative(JNIEnv*, jclass) {
// Methods not annotated with anything are not considered "fast native"
// -- Check that the annotation lookup does not find it.
void JniCompilerTest::NormalNativeImpl() {
SetUpForTest(/* direct */ true,
SetUpForTest(/* direct= */ true,
"normalNative",
"()V",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_normalNative));
Expand All @@ -2218,7 +2218,7 @@ void Java_MyClassNatives_fastNative(JNIEnv*, jclass) {
}

void JniCompilerTest::FastNativeImpl() {
SetUpForTest(/* direct */ true,
SetUpForTest(/* direct= */ true,
"fastNative",
"()V",
CURRENT_JNI_WRAPPER(Java_MyClassNatives_fastNative));
Expand All @@ -2241,7 +2241,7 @@ void Java_MyClassNatives_criticalNative() {
}

void JniCompilerTest::CriticalNativeImpl() {
SetUpForTest(/* direct */ true,
SetUpForTest(/* direct= */ true,
// Important: Don't change the "current jni" yet to avoid a method name suffix.
"criticalNative",
"()V",
Expand Down
10 changes: 5 additions & 5 deletions compiler/jni/quick/jni_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static JniCompiledMethod ArtJniCompileMethodInternal(const CompilerOptions& comp
// Don't allow both @FastNative and @CriticalNative. They are mutually exclusive.
if (UNLIKELY(is_fast_native && is_critical_native)) {
LOG(FATAL) << "JniCompile: Method cannot be both @CriticalNative and @FastNative"
<< dex_file.PrettyMethod(method_idx, /* with_signature */ true);
<< dex_file.PrettyMethod(method_idx, /* with_signature= */ true);
}

// @CriticalNative - extra checks:
Expand All @@ -162,15 +162,15 @@ static JniCompiledMethod ArtJniCompileMethodInternal(const CompilerOptions& comp
CHECK(is_static)
<< "@CriticalNative functions cannot be virtual since that would"
<< "require passing a reference parameter (this), which is illegal "
<< dex_file.PrettyMethod(method_idx, /* with_signature */ true);
<< dex_file.PrettyMethod(method_idx, /* with_signature= */ true);
CHECK(!is_synchronized)
<< "@CriticalNative functions cannot be synchronized since that would"
<< "require passing a (class and/or this) reference parameter, which is illegal "
<< dex_file.PrettyMethod(method_idx, /* with_signature */ true);
<< dex_file.PrettyMethod(method_idx, /* with_signature= */ true);
for (size_t i = 0; i < strlen(shorty); ++i) {
CHECK_NE(Primitive::kPrimNot, Primitive::GetType(shorty[i]))
<< "@CriticalNative methods' shorty types must not have illegal references "
<< dex_file.PrettyMethod(method_idx, /* with_signature */ true);
<< dex_file.PrettyMethod(method_idx, /* with_signature= */ true);
}
}
}
Expand Down Expand Up @@ -632,7 +632,7 @@ static JniCompiledMethod ArtJniCompileMethodInternal(const CompilerOptions& comp
__ DecreaseFrameSize(current_out_arg_size);

// 15. Process pending exceptions from JNI call or monitor exit.
__ ExceptionPoll(main_jni_conv->InterproceduralScratchRegister(), 0 /* stack_adjust */);
__ ExceptionPoll(main_jni_conv->InterproceduralScratchRegister(), 0 /* stack_adjust= */);

// 16. Remove activation - need to restore callee save registers since the GC may have changed
// them.
Expand Down
18 changes: 9 additions & 9 deletions compiler/linker/elf_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ class ElfBuilder final {
name,
SHT_STRTAB,
flags,
/* link */ nullptr,
/* info */ 0,
/* link= */ nullptr,
/* info= */ 0,
align,
/* entsize */ 0) { }
/* entsize= */ 0) { }

Elf_Word Add(const std::string& name) {
if (CachedSection::GetCacheSize() == 0u) {
Expand All @@ -306,10 +306,10 @@ class ElfBuilder final {
name,
SHT_STRTAB,
flags,
/* link */ nullptr,
/* info */ 0,
/* link= */ nullptr,
/* info= */ 0,
align,
/* entsize */ 0) {
/* entsize= */ 0) {
Reset();
}

Expand Down Expand Up @@ -351,7 +351,7 @@ class ElfBuilder final {
type,
flags,
strtab,
/* info */ 1,
/* info= */ 1,
sizeof(Elf_Off),
sizeof(Elf_Sym)) {
syms_.push_back(Elf_Sym()); // The symbol table always has to start with NULL symbol.
Expand Down Expand Up @@ -768,7 +768,7 @@ class ElfBuilder final {
// The runtime does not care about the size of this symbol (it uses the "lastword" symbol).
// We use size 0 (meaning "unknown size" in ELF) to prevent overlap with the debug symbols.
Elf_Word oatexec = dynstr_.Add("oatexec");
dynsym_.Add(oatexec, &text_, text_.GetAddress(), /* size */ 0, STB_GLOBAL, STT_OBJECT);
dynsym_.Add(oatexec, &text_, text_.GetAddress(), /* size= */ 0, STB_GLOBAL, STT_OBJECT);
Elf_Word oatlastword = dynstr_.Add("oatlastword");
Elf_Word oatlastword_address = text_.GetAddress() + text_size - 4;
dynsym_.Add(oatlastword, &text_, oatlastword_address, 4, STB_GLOBAL, STT_OBJECT);
Expand Down Expand Up @@ -824,7 +824,7 @@ class ElfBuilder final {
}
if (dex_size != 0u) {
Elf_Word oatdex = dynstr_.Add("oatdex");
dynsym_.Add(oatdex, &dex_, dex_.GetAddress(), /* size */ 0, STB_GLOBAL, STT_OBJECT);
dynsym_.Add(oatdex, &dex_, dex_.GetAddress(), /* size= */ 0, STB_GLOBAL, STT_OBJECT);
Elf_Word oatdexlastword = dynstr_.Add("oatdexlastword");
Elf_Word oatdexlastword_address = dex_.GetAddress() + dex_size - 4;
dynsym_.Add(oatdexlastword, &dex_, oatdexlastword_address, 4, STB_GLOBAL, STT_OBJECT);
Expand Down
Loading

0 comments on commit 3db7068

Please sign in to comment.