diff options
author | 2022-06-09 14:46:08 +0000 | |
---|---|---|
committer | 2022-06-20 08:55:03 +0000 | |
commit | 86c4b39d929c37b2899b41c030c9756ea336333f (patch) | |
tree | fc98573796877f6159fe81467943e80df94078cf | |
parent | bc0318ab1496e2468223be3ad76738d7b8ee7579 (diff) |
Fix modernize-use-using clang-tidy issues
All the // NOLINT comments introduced in this CL were meant
to disable only the modernize-use-using checks, but changing
the comment to be // NOLINT(modernize-use-using) as explained
in https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics
will make cpplint throw an error, as also cpplint uses the
// NOLINT(...) notation to suppress unwanted warnings.
Test: m tidy-art
Test: art/libnativebridge/tests/runtests.sh
Bug: 213953102
Change-Id: I9a992e0f0ecd06f7e64fd0bbf473bec4582370f6
21 files changed, 46 insertions, 48 deletions
diff --git a/build/Android.bp b/build/Android.bp index 930a9c7722..7c6737fbe5 100644 --- a/build/Android.bp +++ b/build/Android.bp @@ -47,7 +47,7 @@ art_clang_tidy_allowed = [ "bugprone-unused-return-value", "misc-unused-using-decls", "modernize-use-nullptr", - "modernize-use-using", + "modernize-use-using", // TODO: move to art_clang_tidy_errors after b/236243696 is done "performance-faster-string-find", "performance-for-range-copy", "performance-noexcept-move-constructor", diff --git a/compiler/optimizing/codegen_test_utils.h b/compiler/optimizing/codegen_test_utils.h index 397e601cee..95cb548905 100644 --- a/compiler/optimizing/codegen_test_utils.h +++ b/compiler/optimizing/codegen_test_utils.h @@ -45,7 +45,7 @@ namespace art { -typedef CodeGenerator* (*CreateCodegenFn)(HGraph*, const CompilerOptions&); +using CreateCodegenFn = CodeGenerator* (*)(HGraph*, const CompilerOptions&); class CodegenTargetConfig { public: @@ -257,7 +257,7 @@ static void Run(const InternalCodeAllocator& allocator, const void* code_ptr = code_holder.MakeExecutable(allocator.GetMemory(), ArrayRef<const uint8_t>(), target_isa); - typedef Expected (*fptr)(); + using fptr = Expected (*)(); fptr f = reinterpret_cast<fptr>(reinterpret_cast<uintptr_t>(code_ptr)); if (target_isa == InstructionSet::kThumb2) { // For thumb we need the bottom bit set. diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h index e83688039a..4b3d0abb64 100644 --- a/compiler/optimizing/optimizing_unit_test.h +++ b/compiler/optimizing/optimizing_unit_test.h @@ -559,7 +559,7 @@ class OptimizingUnitTestHelper { class OptimizingUnitTest : public CommonArtTest, public OptimizingUnitTestHelper {}; // Naive string diff data type. -typedef std::list<std::pair<std::string, std::string>> diff_t; +using diff_t = std::list<std::pair<std::string, std::string>>; // An alias for the empty string used to make it clear that a line is // removed in a diff. diff --git a/compiler/optimizing/scheduler_arm.h b/compiler/optimizing/scheduler_arm.h index d11222d9f4..6aeea6dde1 100644 --- a/compiler/optimizing/scheduler_arm.h +++ b/compiler/optimizing/scheduler_arm.h @@ -22,9 +22,6 @@ namespace art { namespace arm { -// TODO: Replace CodeGeneratorARMType with CodeGeneratorARMVIXL everywhere? -typedef CodeGeneratorARMVIXL CodeGeneratorARMType; - // AArch32 instruction latencies. // We currently assume that all ARM CPUs share the same instruction latency list. // The following latencies were tuned based on performance experiments and @@ -52,7 +49,7 @@ static constexpr uint32_t kArmRuntimeTypeCheckLatency = 46; class SchedulingLatencyVisitorARM : public SchedulingLatencyVisitor { public: explicit SchedulingLatencyVisitorARM(CodeGenerator* codegen) - : codegen_(down_cast<CodeGeneratorARMType*>(codegen)) {} + : codegen_(down_cast<CodeGeneratorARMVIXL*>(codegen)) {} // Default visitor for instructions not handled specifically below. void VisitInstruction(HInstruction* ATTRIBUTE_UNUSED) override { @@ -133,7 +130,7 @@ class SchedulingLatencyVisitorARM : public SchedulingLatencyVisitor { // The latency setting for each HInstruction depends on how CodeGenerator may generate code, // latency visitors may query CodeGenerator for such information for accurate latency settings. - CodeGeneratorARMType* codegen_; + CodeGeneratorARMVIXL* codegen_; }; class HSchedulerARM : public HScheduler { diff --git a/compiler/utils/assembler_test.h b/compiler/utils/assembler_test.h index 5c6bf13c96..09146ea428 100644 --- a/compiler/utils/assembler_test.h +++ b/compiler/utils/assembler_test.h @@ -59,7 +59,7 @@ class AssemblerTest : public AssemblerTestBase { return assembler_.get(); } - typedef std::string (*TestFn)(AssemblerTest* assembler_test, Ass* assembler); + using TestFn = std::string (*)(AssemblerTest *, Ass *); void DriverFn(TestFn f, const std::string& test_name) { DriverWrapper(f(this, assembler_.get()), test_name); diff --git a/compiler/utils/jni_macro_assembler_test.h b/compiler/utils/jni_macro_assembler_test.h index e77177e43e..62e81914ac 100644 --- a/compiler/utils/jni_macro_assembler_test.h +++ b/compiler/utils/jni_macro_assembler_test.h @@ -39,7 +39,7 @@ class JNIMacroAssemblerTest : public AssemblerTestBase { return assembler_.get(); } - typedef std::string (*TestFn)(JNIMacroAssemblerTest* assembler_test, Ass* assembler); + using TestFn = std::string (*)(JNIMacroAssemblerTest *, Ass *); void DriverFn(TestFn f, const std::string& test_name) { DriverWrapper(f(this, assembler_.get()), test_name); diff --git a/libartbase/base/data_hash.h b/libartbase/base/data_hash.h index 339989974e..ccb8736e3b 100644 --- a/libartbase/base/data_hash.h +++ b/libartbase/base/data_hash.h @@ -44,7 +44,7 @@ class DataHash { uint32_t hash = Murmur3Start(); const size_t nblocks = length_in_bytes / 4; - typedef __attribute__((__aligned__(1))) uint32_t unaligned_uint32_t; + using unaligned_uint32_t __attribute__((__aligned__(1))) = uint32_t; const unaligned_uint32_t* blocks = reinterpret_cast<const unaligned_uint32_t*>(data); for (size_t i = 0; i != nblocks; ++i) { hash = Murmur3Update(hash, blocks[i]); diff --git a/libartpalette/include/palette/palette_types.h b/libartpalette/include/palette/palette_types.h index 905a341d4d..3c0254479f 100644 --- a/libartpalette/include/palette/palette_types.h +++ b/libartpalette/include/palette/palette_types.h @@ -23,7 +23,7 @@ extern "C" { #endif // __cplusplus -typedef int32_t palette_status_t; +using palette_status_t = int32_t; // Palette function return value when the function completed successfully. #define PALETTE_STATUS_OK ((palette_status_t) 0) diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h index cc5d2fd926..37a601d3a1 100644 --- a/libdexfile/dex/dex_file.h +++ b/libdexfile/dex/dex_file.h @@ -570,7 +570,7 @@ class DexFile { }; // Callback for "new locals table entry". - typedef void (*DexDebugNewLocalCb)(void* context, const LocalInfo& entry); + using DexDebugNewLocalCb = void (*)(void* context, const LocalInfo& entry); const dex::AnnotationsDirectoryItem* GetAnnotationsDirectory(const dex::ClassDef& class_def) const { diff --git a/libdexfile/dex/dex_instruction.h b/libdexfile/dex/dex_instruction.h index 7e43f75786..ff6fcf7bd4 100644 --- a/libdexfile/dex/dex_instruction.h +++ b/libdexfile/dex/dex_instruction.h @@ -22,8 +22,8 @@ #include "base/globals.h" #include "base/macros.h" -typedef uint8_t uint4_t; -typedef int8_t int4_t; +using uint4_t = uint8_t; +using int4_t = int8_t; namespace art { diff --git a/libdexfile/external/include/art_api/dex_file_external.h b/libdexfile/external/include/art_api/dex_file_external.h index 360be926d7..d9db200fdc 100644 --- a/libdexfile/external/include/art_api/dex_file_external.h +++ b/libdexfile/external/include/art_api/dex_file_external.h @@ -28,10 +28,10 @@ __BEGIN_DECLS // may only be added here. C++ users should use dex_file_support.h instead. struct ADexFile; -typedef struct ADexFile ADexFile; +typedef struct ADexFile ADexFile; // NOLINT struct ADexFile_Method; -typedef struct ADexFile_Method ADexFile_Method; +typedef struct ADexFile_Method ADexFile_Method; // NOLINT enum ADexFile_Error : uint32_t { ADEXFILE_ERROR_OK = 0, @@ -39,10 +39,11 @@ enum ADexFile_Error : uint32_t { ADEXFILE_ERROR_INVALID_HEADER = 2, ADEXFILE_ERROR_NOT_ENOUGH_DATA = 3, }; -typedef enum ADexFile_Error ADexFile_Error; +typedef enum ADexFile_Error ADexFile_Error; // NOLINT // Callback used to return information about a dex method. // The method information is valid only during the callback. +// NOLINTNEXTLINE typedef void ADexFile_MethodCallback(void* _Nullable callback_data, const ADexFile_Method* _Nonnull method); diff --git a/libelffile/elf/elf_debug_reader.h b/libelffile/elf/elf_debug_reader.h index 266c638473..6e01989e2b 100644 --- a/libelffile/elf/elf_debug_reader.h +++ b/libelffile/elf/elf_debug_reader.h @@ -35,11 +35,11 @@ template <typename ElfTypes> class ElfDebugReader { public: // Note that the input buffer might be misaligned. - typedef typename ElfTypes::Ehdr ALIGNED(1) Elf_Ehdr; - typedef typename ElfTypes::Phdr ALIGNED(1) Elf_Phdr; - typedef typename ElfTypes::Shdr ALIGNED(1) Elf_Shdr; - typedef typename ElfTypes::Sym ALIGNED(1) Elf_Sym; - typedef typename ElfTypes::Addr ALIGNED(1) Elf_Addr; + using Elf_Ehdr ALIGNED(1) = typename ElfTypes::Ehdr; + using Elf_Phdr ALIGNED(1) = typename ElfTypes::Phdr; + using Elf_Shdr ALIGNED(1) = typename ElfTypes::Shdr; + using Elf_Sym ALIGNED(1) = typename ElfTypes::Sym; + using Elf_Addr ALIGNED(1) = typename ElfTypes::Addr; // Call Frame Information. struct CFI { diff --git a/libnativebridge/include/nativebridge/native_bridge.h b/libnativebridge/include/nativebridge/native_bridge.h index 2199bab552..5904c0fe3f 100644 --- a/libnativebridge/include/nativebridge/native_bridge.h +++ b/libnativebridge/include/nativebridge/native_bridge.h @@ -40,7 +40,7 @@ struct NativeBridgeRuntimeValues; // Function pointer type for sigaction. This is mostly the signature of a signal handler, except // for the return type. The runtime needs to know whether the signal was handled or should be given // to the chain. -typedef bool (*NativeBridgeSignalHandlerFn)(int, siginfo_t*, void*); +typedef bool (*NativeBridgeSignalHandlerFn)(int, siginfo_t*, void*); // NOLINT // Open the native bridge, if any. Should be called by Runtime::Init(). A null library filename // signals that we do not want to load a native bridge. diff --git a/libnativeloader/native_loader_test.h b/libnativeloader/native_loader_test.h index 5c51f00e82..30b2f84cd2 100644 --- a/libnativeloader/native_loader_test.h +++ b/libnativeloader/native_loader_test.h @@ -42,7 +42,7 @@ class Platform { // Instead of having two set of mock APIs for the two, define only one set with an additional // argument 'bool bridged' to identify the context (i.e., called for libdl_android or // libnativebridge). - typedef char* mock_namespace_handle; + using mock_namespace_handle = char*; virtual bool mock_init_anonymous_namespace(bool bridged, const char* sonames, const char* search_paths) = 0; virtual mock_namespace_handle mock_create_namespace( diff --git a/openjdkjvmti/jvmti_allocator.h b/openjdkjvmti/jvmti_allocator.h index bd4c85bd7c..4adf769f12 100644 --- a/openjdkjvmti/jvmti_allocator.h +++ b/openjdkjvmti/jvmti_allocator.h @@ -46,13 +46,13 @@ template <typename T> class JvmtiAllocator; template <> class JvmtiAllocator<void> { public: - typedef void value_type; - typedef void* pointer; - typedef const void* const_pointer; + using value_type = void; + using pointer = void*; + using const_pointer = const void*; template <typename U> struct rebind { - typedef JvmtiAllocator<U> other; + using other = JvmtiAllocator<U>; }; explicit JvmtiAllocator(jvmtiEnv* env) : env_(env) {} @@ -79,17 +79,17 @@ class JvmtiAllocator<void> { template <typename T> class JvmtiAllocator { public: - typedef T value_type; - typedef T* pointer; - typedef T& reference; - typedef const T* const_pointer; - typedef const T& const_reference; - typedef size_t size_type; - typedef ptrdiff_t difference_type; + using value_type = T; + using pointer = T*; + using reference = T&; + using const_pointer = const T*; + using const_reference = const T&; + using size_type = size_t; + using difference_type = ptrdiff_t; template <typename U> struct rebind { - typedef JvmtiAllocator<U> other; + using other = JvmtiAllocator<U>; }; explicit JvmtiAllocator(jvmtiEnv* env) : env_(env) {} diff --git a/runtime/gc/accounting/space_bitmap.h b/runtime/gc/accounting/space_bitmap.h index 0d8ffa0d67..6fc35d92fb 100644 --- a/runtime/gc/accounting/space_bitmap.h +++ b/runtime/gc/accounting/space_bitmap.h @@ -40,8 +40,8 @@ namespace accounting { template<size_t kAlignment> class SpaceBitmap { public: - typedef void ScanCallback(mirror::Object* obj, void* finger, void* arg); - typedef void SweepCallback(size_t ptr_count, mirror::Object** ptrs, void* arg); + using ScanCallback = void(mirror::Object* obj, void* finger, void* arg); + using SweepCallback = void(size_t ptr_count, mirror::Object** ptrs, void* arg); // Initialize a space bitmap so that it points to a bitmap large enough to cover a heap at // heap_begin of heap_capacity bytes, where objects are guaranteed to be kAlignment-aligned. diff --git a/runtime/gc/space/bump_pointer_space.h b/runtime/gc/space/bump_pointer_space.h index 08ed503b5f..002b36382a 100644 --- a/runtime/gc/space/bump_pointer_space.h +++ b/runtime/gc/space/bump_pointer_space.h @@ -39,7 +39,7 @@ namespace space { // implementation as its intended to be evacuated. class BumpPointerSpace final : public ContinuousMemMapAllocSpace { public: - typedef void(*WalkCallback)(void *start, void *end, size_t num_bytes, void* callback_arg); + using WalkCallback = void (*)(void *, void *, int, void *); SpaceType GetType() const override { return kSpaceTypeBumpPointerSpace; diff --git a/runtime/gc/space/malloc_space.h b/runtime/gc/space/malloc_space.h index 50006568ca..59ab3f3214 100644 --- a/runtime/gc/space/malloc_space.h +++ b/runtime/gc/space/malloc_space.h @@ -38,7 +38,7 @@ class ZygoteSpace; // A common parent of DlMallocSpace and RosAllocSpace. class MallocSpace : public ContinuousMemMapAllocSpace { public: - typedef void(*WalkCallback)(void *start, void *end, size_t num_bytes, void* callback_arg); + using WalkCallback = void (*)(void *start, void *end, size_t num_bytes, void* callback_arg); SpaceType GetType() const override { return kSpaceTypeMallocSpace; diff --git a/runtime/gc/space/region_space.h b/runtime/gc/space/region_space.h index 1463eb7d2a..27b9e9c367 100644 --- a/runtime/gc/space/region_space.h +++ b/runtime/gc/space/region_space.h @@ -46,7 +46,7 @@ static constexpr bool kCyclicRegionAllocation = kIsDebugBuild; // A space that consists of equal-sized regions. class RegionSpace final : public ContinuousMemMapAllocSpace { public: - typedef void(*WalkCallback)(void *start, void *end, size_t num_bytes, void* callback_arg); + using WalkCallback = void (*)(void *start, void *end, size_t num_bytes, void* callback_arg); enum EvacMode { kEvacModeNewlyAllocated, diff --git a/runtime/interpreter/interpreter_cache.h b/runtime/interpreter/interpreter_cache.h index c57d0233a6..8714bc613c 100644 --- a/runtime/interpreter/interpreter_cache.h +++ b/runtime/interpreter/interpreter_cache.h @@ -47,7 +47,7 @@ class Thread; class ALIGNED(16) InterpreterCache { public: // Aligned since we load the whole entry in single assembly instruction. - typedef std::pair<const void*, size_t> Entry ALIGNED(2 * sizeof(size_t)); + using Entry ALIGNED(2 * sizeof(size_t)) = std::pair<const void*, size_t>; // 2x size increase/decrease corresponds to ~0.5% interpreter performance change. // Value of 256 has around 75% cache hit rate. diff --git a/runtime/interpreter/shadow_frame.h b/runtime/interpreter/shadow_frame.h index 8cb2b33a07..67f6759c92 100644 --- a/runtime/interpreter/shadow_frame.h +++ b/runtime/interpreter/shadow_frame.h @@ -169,14 +169,14 @@ class ShadowFrame { int64_t GetVRegLong(size_t i) const { DCHECK_LT(i + 1, NumberOfVRegs()); const uint32_t* vreg = &vregs_[i]; - typedef const int64_t unaligned_int64 __attribute__ ((aligned (4))); + using unaligned_int64 __attribute__((aligned(4))) = const int64_t; return *reinterpret_cast<unaligned_int64*>(vreg); } double GetVRegDouble(size_t i) const { DCHECK_LT(i + 1, NumberOfVRegs()); const uint32_t* vreg = &vregs_[i]; - typedef const double unaligned_double __attribute__ ((aligned (4))); + using unaligned_double __attribute__((aligned(4))) = const double; return *reinterpret_cast<unaligned_double*>(vreg); } @@ -221,7 +221,7 @@ class ShadowFrame { void SetVRegLong(size_t i, int64_t val) { DCHECK_LT(i + 1, NumberOfVRegs()); uint32_t* vreg = &vregs_[i]; - typedef int64_t unaligned_int64 __attribute__ ((aligned (4))); + using unaligned_int64 __attribute__((aligned(4))) = int64_t; *reinterpret_cast<unaligned_int64*>(vreg) = val; // This is needed for moving collectors since these can update the vreg references if they // happen to agree with references in the reference array. @@ -232,7 +232,7 @@ class ShadowFrame { void SetVRegDouble(size_t i, double val) { DCHECK_LT(i + 1, NumberOfVRegs()); uint32_t* vreg = &vregs_[i]; - typedef double unaligned_double __attribute__ ((aligned (4))); + using unaligned_double __attribute__((aligned(4))) = double; *reinterpret_cast<unaligned_double*>(vreg) = val; // This is needed for moving collectors since these can update the vreg references if they // happen to agree with references in the reference array. |