Fix clang-tidy warnings in art.
* Add parentheses around macro parameters, or
use NOLINT to suppress warning.
Bug: 28705665
Test: build with WITH_TIDY=1
Change-Id: Ifc922c2e66215772042bac372754ea70074f0053
diff --git a/runtime/entrypoints_order_test.cc b/runtime/entrypoints_order_test.cc
index 004cdc4..b102334 100644
--- a/runtime/entrypoints_order_test.cc
+++ b/runtime/entrypoints_order_test.cc
@@ -37,7 +37,7 @@
// name.
#define EXPECT_OFFSET_DIFF(first_type, first_field, second_type, second_field, diff, name) \
CHECKED(OFFSETOF_MEMBER(second_type, second_field) \
- - OFFSETOF_MEMBER(first_type, first_field) == diff, name)
+ - OFFSETOF_MEMBER(first_type, first_field) == (diff), name)
// Helper macro for when the fields are from the same type.
#define EXPECT_OFFSET_DIFFNP(type, first_field, second_field, diff) \
@@ -45,15 +45,16 @@
type ## _ ## first_field ## _ ## second_field)
// Helper macro for when the fields are from the same type and in the same member of said type.
+// NOLINT, do not add parentheses around 'prefix'.
#define EXPECT_OFFSET_DIFFP(type, prefix, first_field, second_field, diff) \
- EXPECT_OFFSET_DIFF(type, prefix . first_field, type, prefix . second_field, diff, \
+ EXPECT_OFFSET_DIFF(type, prefix . first_field, type, prefix . second_field, diff, /* NOLINT */ \
type ## _ ## prefix ## _ ## first_field ## _ ## second_field)
// Macro to check whether two fields have at least an expected difference in offsets. The error is
// named name.
#define EXPECT_OFFSET_DIFF_GT(first_type, first_field, second_type, second_field, diff, name) \
CHECKED(OFFSETOF_MEMBER(second_type, second_field) \
- - OFFSETOF_MEMBER(first_type, first_field) >= diff, name)
+ - OFFSETOF_MEMBER(first_type, first_field) >= (diff), name)
// Helper macro for when the fields are from the same type.
#define EXPECT_OFFSET_DIFF_GT3(type, first_field, second_field, diff, name) \
diff --git a/runtime/gc/space/space_test.h b/runtime/gc/space/space_test.h
index 20ef44a..23e937d 100644
--- a/runtime/gc/space/space_test.h
+++ b/runtime/gc/space/space_test.h
@@ -354,7 +354,7 @@
#define TEST_SizeFootPrintGrowthLimitAndTrimRandom(name, spaceName, spaceFn, size) \
TEST_F(spaceName##RandomTest, SizeFootPrintGrowthLimitAndTrim_RandomAllocationsWithMax_##name) { \
- SizeFootPrintGrowthLimitAndTrimDriver(-size, spaceFn); \
+ SizeFootPrintGrowthLimitAndTrimDriver(-(size), spaceFn); \
}
#define TEST_SPACE_CREATE_FN_STATIC(spaceName, spaceFn) \
diff --git a/runtime/instrumentation_test.cc b/runtime/instrumentation_test.cc
index 684c471..2cc35cf 100644
--- a/runtime/instrumentation_test.cc
+++ b/runtime/instrumentation_test.cc
@@ -588,7 +588,7 @@
do { \
Instrumentation* const instr = Runtime::Current()->GetInstrumentation(); \
bool interpreter = \
- (_level == Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter); \
+ ((_level) == Instrumentation::InstrumentationLevel::kInstrumentWithInterpreter); \
EXPECT_EQ(_level, GetCurrentInstrumentationLevel()); \
EXPECT_EQ(_user_count, GetInstrumentationUserCount()); \
if (instr->IsForcedInterpretOnly()) { \
diff --git a/runtime/jni_internal_test.cc b/runtime/jni_internal_test.cc
index 6495474..fe0081c 100644
--- a/runtime/jni_internal_test.cc
+++ b/runtime/jni_internal_test.cc
@@ -1105,8 +1105,9 @@
ExpectException(aioobe_); \
\
/* Prepare a couple of buffers. */ \
- std::unique_ptr<scalar_type[]> src_buf(new scalar_type[size]); \
- std::unique_ptr<scalar_type[]> dst_buf(new scalar_type[size]); \
+ /* NOLINT, no parentheses around scalar_type. */ \
+ std::unique_ptr<scalar_type[]> src_buf(new scalar_type[size]); /* NOLINT */ \
+ std::unique_ptr<scalar_type[]> dst_buf(new scalar_type[size]); /* NOLINT */ \
for (jsize i = 0; i < size; ++i) { src_buf[i] = scalar_type(i); } \
for (jsize i = 0; i < size; ++i) { dst_buf[i] = scalar_type(-1); } \
\
@@ -1131,7 +1132,7 @@
<< "GetPrimitiveArrayCritical not equal"; \
env_->ReleasePrimitiveArrayCritical(a, v, 0); \
/* GetXArrayElements */ \
- scalar_type* xs = env_->get_elements_fn(a, nullptr); \
+ scalar_type* xs = env_->get_elements_fn(a, nullptr); /* NOLINT, scalar_type */ \
EXPECT_EQ(memcmp(&src_buf[0], xs, size * sizeof(scalar_type)), 0) \
<< # get_elements_fn " not equal"; \
env_->release_elements_fn(a, xs, 0); \