Skip to content

Commit

Permalink
Update clang tools to 4.0.
Browse files Browse the repository at this point in the history
This includes clang-tidy-4.0 and clang-format-4.0.

Change-Id: I9c49002dee3c424e9745d68ba7dcfe10a858db12
  • Loading branch information
jacobbramley committed May 7, 2020
1 parent d146374 commit 2fe55ec
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 110 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ To build VIXL the following software is required:

1. Python 2.7
2. SCons 2.0
3. GCC 4.8+ or Clang 3.4+
3. GCC 4.8+ or Clang 4.0+

A 64-bit host machine is required, implementing an LP64 data model. VIXL has
been tested using GCC on AArch64 Debian, GCC and Clang on amd64 Ubuntu
Expand All @@ -54,10 +54,14 @@ software is also required:

1. Git
2. [Google's `cpplint.py`][cpplint]
3. clang-format-3.8
3. clang-format-4.0
4. clang-tidy-4.0

Refer to the 'Usage' section for details.

Note that in Ubuntu 18.04, clang-tidy-4.0 will only work if the clang-4.0
package is also installed.


Known Limitations for AArch64 code generation
=============================================
Expand Down Expand Up @@ -183,9 +187,10 @@ It is possible to tell `tools/test.py` to skip the linter stage by passing
`--nolint`. This removes the dependency on `cpplint.py` and Git. The `--nolint`
option is implied if the VIXL project is a snapshot (with no `.git` directory).

Additionally, `tools/test.py` tests code formatting using `clang-format-3.8`.
If you don't have `clang-format-3.8`, disable the test using the
`--noclang-format` option.
Additionally, `tools/test.py` tests code formatting using `clang-format-4.0`,
and performs static analysis using `clang-tidy-4.0`. If you don't have these
tools, disable the test using `--noclang-format` or `--noclang-tidy`,
respectively.

Also note that the tests for the tracing features depend upon external `diff`
and `sed` tools. If these tools are not available in `PATH`, these tests will
Expand Down
6 changes: 4 additions & 2 deletions examples/aarch32/getting-started.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ int main() {
uint32_t code_size = masm.GetSizeOfCodeGenerated();
ExecutableMemory memory(code, code_size);
// Run the example function.
uint32_t (*demo_function)(uint32_t) = memory.GetEntryPoint<uint32_t (*)(
uint32_t)>(demo, masm.GetInstructionSetInUse());
uint32_t (*demo_function)(uint32_t) =
memory
.GetEntryPoint<uint32_t (*)(uint32_t)>(demo,
masm.GetInstructionSetInUse());
uint32_t input_value = 0x89abcdef;
uint32_t output_value = (*demo_function)(input_value);
printf("native: demo(0x%08x) = 0x%08x\n", input_value, output_value);
Expand Down
9 changes: 6 additions & 3 deletions src/aarch32/macro-assembler-aarch32.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
generate_simulator_code_(VIXL_AARCH32_GENERATE_SIMULATOR_CODE),
pool_end_(NULL) {
#ifdef VIXL_DEBUG
SetAllowMacroInstructions(true);
SetAllowMacroInstructions( // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
true);
#else
USE(allow_macro_instructions_);
#endif
Expand All @@ -283,7 +284,8 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
generate_simulator_code_(VIXL_AARCH32_GENERATE_SIMULATOR_CODE),
pool_end_(NULL) {
#ifdef VIXL_DEBUG
SetAllowMacroInstructions(true);
SetAllowMacroInstructions( // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
true);
#endif
}
MacroAssembler(byte* buffer, size_t size, InstructionSet isa = kDefaultISA)
Expand All @@ -296,7 +298,8 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface {
generate_simulator_code_(VIXL_AARCH32_GENERATE_SIMULATOR_CODE),
pool_end_(NULL) {
#ifdef VIXL_DEBUG
SetAllowMacroInstructions(true);
SetAllowMacroInstructions( // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
true);
#endif
}

Expand Down
60 changes: 17 additions & 43 deletions src/aarch32/operands-aarch32.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,16 @@ class Operand {
// This is allowed to be an implicit constructor because Operand is
// a wrapper class that doesn't normally perform any type conversion.
Operand(uint32_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoReg),
shift_(LSL),
amount_(0),
rs_(NoReg) {}
: imm_(immediate), rm_(NoReg), shift_(LSL), amount_(0), rs_(NoReg) {}
Operand(int32_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoReg),
shift_(LSL),
amount_(0),
rs_(NoReg) {}
: imm_(immediate), rm_(NoReg), shift_(LSL), amount_(0), rs_(NoReg) {}

// rm
// where rm is the base register
// This is allowed to be an implicit constructor because Operand is
// a wrapper class that doesn't normally perform any type conversion.
Operand(Register rm) // NOLINT(runtime/explicit)
: imm_(0),
rm_(rm),
shift_(LSL),
amount_(0),
rs_(NoReg) {
: imm_(0), rm_(rm), shift_(LSL), amount_(0), rs_(NoReg) {
VIXL_ASSERT(rm_.IsValid());
}

Expand Down Expand Up @@ -245,34 +233,28 @@ class NeonImmediate {
// This is allowed to be an implicit constructor because NeonImmediate is
// a wrapper class that doesn't normally perform any type conversion.
NeonImmediate(uint32_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
immediate_type_(I32) {}
: imm_(immediate), immediate_type_(I32) {}
NeonImmediate(int immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
immediate_type_(I32) {}
: imm_(immediate), immediate_type_(I32) {}

// { #<immediate> }
// where <immediate> is a 64 bit number
// This is allowed to be an implicit constructor because NeonImmediate is
// a wrapper class that doesn't normally perform any type conversion.
NeonImmediate(int64_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
immediate_type_(I64) {}
: imm_(immediate), immediate_type_(I64) {}
NeonImmediate(uint64_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
immediate_type_(I64) {}
: imm_(immediate), immediate_type_(I64) {}

// { #<immediate> }
// where <immediate> is a non zero floating point number which can be encoded
// as an 8 bit floating point (checked by the constructor).
// This is allowed to be an implicit constructor because NeonImmediate is
// a wrapper class that doesn't normally perform any type conversion.
NeonImmediate(float immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
immediate_type_(F32) {}
: imm_(immediate), immediate_type_(F32) {}
NeonImmediate(double immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
immediate_type_(F64) {}
: imm_(immediate), immediate_type_(F64) {}

NeonImmediate(const NeonImmediate& src)
: imm_(src.imm_), immediate_type_(src.immediate_type_) {}
Expand Down Expand Up @@ -374,29 +356,21 @@ std::ostream& operator<<(std::ostream& os, const NeonImmediate& operand);
class NeonOperand {
public:
NeonOperand(int32_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoDReg) {}
: imm_(immediate), rm_(NoDReg) {}
NeonOperand(uint32_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoDReg) {}
: imm_(immediate), rm_(NoDReg) {}
NeonOperand(int64_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoDReg) {}
: imm_(immediate), rm_(NoDReg) {}
NeonOperand(uint64_t immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoDReg) {}
: imm_(immediate), rm_(NoDReg) {}
NeonOperand(float immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoDReg) {}
: imm_(immediate), rm_(NoDReg) {}
NeonOperand(double immediate) // NOLINT(runtime/explicit)
: imm_(immediate),
rm_(NoDReg) {}
: imm_(immediate), rm_(NoDReg) {}
NeonOperand(const NeonImmediate& imm) // NOLINT(runtime/explicit)
: imm_(imm),
rm_(NoDReg) {}
: imm_(imm), rm_(NoDReg) {}
NeonOperand(const VRegister& rm) // NOLINT(runtime/explicit)
: imm_(0),
rm_(rm) {
: imm_(0), rm_(rm) {
VIXL_ASSERT(rm_.IsValid());
}

Expand Down
60 changes: 30 additions & 30 deletions src/aarch64/instrument-aarch64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,36 +77,36 @@ struct CounterDescriptor {
};


static const CounterDescriptor kCounterList[] =
{{"Instruction", Cumulative},

{"Move Immediate", Gauge},
{"Add/Sub DP", Gauge},
{"Logical DP", Gauge},
{"Other Int DP", Gauge},
{"FP DP", Gauge},

{"Conditional Select", Gauge},
{"Conditional Compare", Gauge},

{"Unconditional Branch", Gauge},
{"Compare and Branch", Gauge},
{"Test and Branch", Gauge},
{"Conditional Branch", Gauge},

{"Load Integer", Gauge},
{"Load FP", Gauge},
{"Load Pair", Gauge},
{"Load Literal", Gauge},

{"Store Integer", Gauge},
{"Store FP", Gauge},
{"Store Pair", Gauge},

{"PC Addressing", Gauge},
{"Other", Gauge},
{"NEON", Gauge},
{"Crypto", Gauge}};
static const CounterDescriptor kCounterList[] = {{"Instruction", Cumulative},

{"Move Immediate", Gauge},
{"Add/Sub DP", Gauge},
{"Logical DP", Gauge},
{"Other Int DP", Gauge},
{"FP DP", Gauge},

{"Conditional Select", Gauge},
{"Conditional Compare", Gauge},

{"Unconditional Branch",
Gauge},
{"Compare and Branch", Gauge},
{"Test and Branch", Gauge},
{"Conditional Branch", Gauge},

{"Load Integer", Gauge},
{"Load FP", Gauge},
{"Load Pair", Gauge},
{"Load Literal", Gauge},

{"Store Integer", Gauge},
{"Store FP", Gauge},
{"Store Pair", Gauge},

{"PC Addressing", Gauge},
{"Other", Gauge},
{"NEON", Gauge},
{"Crypto", Gauge}};


Instrument::Instrument(const char* datafile, uint64_t sample_period)
Expand Down
4 changes: 2 additions & 2 deletions src/aarch64/macro-assembler-aarch64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ LiteralPool::~LiteralPool() VIXL_NEGATIVE_TESTING_ALLOW_EXCEPTION {


void LiteralPool::Reset() {
std::vector<RawLiteral *>::iterator it, end;
std::vector<RawLiteral*>::iterator it, end;
for (it = entries_.begin(), end = entries_.end(); it != end; ++it) {
RawLiteral* literal = *it;
if (literal->deletion_policy_ == RawLiteral::kDeletedOnPlacementByPool) {
Expand Down Expand Up @@ -145,7 +145,7 @@ void LiteralPool::Emit(EmitOption option) {
}

// Now populate the literal pool.
std::vector<RawLiteral *>::iterator it, end;
std::vector<RawLiteral*>::iterator it, end;
for (it = entries_.begin(), end = entries_.end(); it != end; ++it) {
VIXL_ASSERT((*it)->IsUsed());
masm_->place(*it);
Expand Down
7 changes: 4 additions & 3 deletions src/aarch64/simulator-aarch64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2936,9 +2936,10 @@ void Simulator::VisitExtract(const Instruction* instr) {
unsigned reg_size = (instr->GetSixtyFourBits() == 1) ? kXRegSize : kWRegSize;
uint64_t low_res =
static_cast<uint64_t>(ReadRegister(reg_size, instr->GetRm())) >> lsb;
uint64_t high_res =
(lsb == 0) ? 0 : ReadRegister<uint64_t>(reg_size, instr->GetRn())
<< (reg_size - lsb);
uint64_t high_res = (lsb == 0)
? 0
: ReadRegister<uint64_t>(reg_size, instr->GetRn())
<< (reg_size - lsb);
WriteRegister(reg_size, instr->GetRd(), low_res | high_res);
}

Expand Down
4 changes: 1 addition & 3 deletions src/invalset-vixl.h
Original file line number Diff line number Diff line change
Expand Up @@ -842,9 +842,7 @@ InvalSetIterator<S>::InvalSetIterator(const InvalSetIterator<S>& other)
#if __cplusplus >= 201103L
template <class S>
InvalSetIterator<S>::InvalSetIterator(InvalSetIterator<S>&& other) noexcept
: using_vector_(false),
index_(0),
inval_set_(NULL) {
: using_vector_(false), index_(0), inval_set_(NULL) {
swap(*this, other);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/pool-manager-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ PoolManager<T>::~PoolManager<T>() VIXL_NEGATIVE_TESTING_ALLOW_EXCEPTION {
}
#endif
// Delete objects the pool manager owns.
for (typename std::vector<LocationBase<T> *>::iterator
for (typename std::vector<LocationBase<T>*>::iterator
iter = delete_on_destruction_.begin(),
end = delete_on_destruction_.end();
iter != end;
Expand Down
9 changes: 4 additions & 5 deletions src/utils-vixl.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ T AlignUp(T pointer,
// reinterpret_cast behaviour for other types.

typename Unsigned<sizeof(T)* kBitsPerByte>::type pointer_raw =
(typename Unsigned<sizeof(T) * kBitsPerByte>::type)pointer;
(typename Unsigned<sizeof(T) * kBitsPerByte>::type) pointer;
VIXL_STATIC_ASSERT(sizeof(pointer) <= sizeof(pointer_raw));

size_t mask = alignment - 1;
Expand All @@ -596,7 +596,7 @@ T AlignDown(T pointer,
// reinterpret_cast behaviour for other types.

typename Unsigned<sizeof(T)* kBitsPerByte>::type pointer_raw =
(typename Unsigned<sizeof(T) * kBitsPerByte>::type)pointer;
(typename Unsigned<sizeof(T) * kBitsPerByte>::type) pointer;
VIXL_STATIC_ASSERT(sizeof(pointer) <= sizeof(pointer_raw));

size_t mask = alignment - 1;
Expand Down Expand Up @@ -1244,9 +1244,8 @@ inline Float16 FPRoundToFloat16(int64_t sign,
uint64_t mantissa,
FPRounding round_mode) {
return RawbitsToFloat16(
FPRound<uint16_t,
kFloat16ExponentBits,
kFloat16MantissaBits>(sign, exponent, mantissa, round_mode));
FPRound<uint16_t, kFloat16ExponentBits, kFloat16MantissaBits>(
sign, exponent, mantissa, round_mode));
}


Expand Down
2 changes: 2 additions & 0 deletions test/aarch32/test-assembler-aarch32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,7 @@ TEST_NOASM(set_isa_empty) {
}


// clang-format off
TEST_NOASM(set_isa_noop) {
// It is possible to call a no-op UseA32/T32 or UseInstructionSet even if
// one or more instructions have been generated.
Expand Down Expand Up @@ -3251,6 +3252,7 @@ TEST_NOASM(set_isa_noop) {
}
#endif
}
// clang-format on


TEST(logical_arithmetic_identities) {
Expand Down
Loading

0 comments on commit 2fe55ec

Please sign in to comment.