From 1a2c1d379f723416c157711eea948495dd475e57 Mon Sep 17 00:00:00 2001 From: mmc28a <78873583+mmc28a@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:43:49 +0000 Subject: [PATCH] Update clang tools to version 11+ (#87) Co-authored-by: Sebastian Nickolls --- README.md | 4 +- benchmarks/aarch64/bench-branch-link-masm.cc | 3 +- benchmarks/aarch64/bench-branch-link.cc | 3 +- benchmarks/aarch64/bench-branch-masm.cc | 3 +- benchmarks/aarch64/bench-branch.cc | 3 +- benchmarks/aarch64/bench-dataop.cc | 3 +- benchmarks/aarch64/bench-mixed-disasm.cc | 3 +- benchmarks/aarch64/bench-mixed-masm.cc | 3 +- benchmarks/aarch64/bench-mixed-sim.cc | 3 +- benchmarks/aarch64/bench-utils.cc | 5 +- benchmarks/aarch64/bench-utils.h | 9 +- examples/aarch64/custom-disassembler.cc | 3 +- examples/aarch64/disasm.cc | 1 + examples/aarch64/getting-started.cc | 4 +- examples/aarch64/literal.cc | 2 + examples/aarch64/non-const-visitor.cc | 3 +- src/aarch64/abi-aarch64.h | 4 +- src/aarch64/assembler-aarch64.cc | 3 +- src/aarch64/assembler-aarch64.h | 1 + src/aarch64/cpu-features-auditor-aarch64.cc | 5 +- src/aarch64/cpu-features-auditor-aarch64.h | 1 + src/aarch64/debugger-aarch64.h | 1 + src/aarch64/decoder-aarch64.cc | 3 +- src/aarch64/disasm-aarch64.cc | 4 +- src/aarch64/instructions-aarch64.cc | 1 + src/aarch64/instructions-aarch64.h | 14 +- src/aarch64/macro-assembler-aarch64.cc | 9 +- src/aarch64/macro-assembler-aarch64.h | 6 +- src/aarch64/operands-aarch64.cc | 4 +- src/aarch64/operands-aarch64.h | 6 +- src/aarch64/pointer-auth-aarch64.cc | 4 +- src/aarch64/registers-aarch64.cc | 8 +- src/aarch64/registers-aarch64.h | 4 +- src/aarch64/simulator-aarch64.cc | 12 +- src/aarch64/simulator-aarch64.h | 7 +- src/code-generation-scopes-vixl.h | 19 +- src/compiler-intrinsics-vixl.cc | 1 + src/compiler-intrinsics-vixl.h | 4 +- src/cpu-features.cc | 3 +- src/invalset-vixl.h | 9 +- src/pool-manager-impl.h | 6 +- src/pool-manager.h | 3 +- test/aarch64/examples/test-examples.cc | 2 +- test/aarch64/test-abi.cc | 16 +- test/aarch64/test-api-aarch64.cc | 2 +- test/aarch64/test-api-movprfx-aarch64.cc | 4 +- test/aarch64/test-assembler-aarch64.cc | 6 +- test/aarch64/test-assembler-fp-aarch64.cc | 5 +- test/aarch64/test-assembler-neon-aarch64.cc | 5 +- test/aarch64/test-assembler-sve-aarch64.cc | 9 +- test/aarch64/test-cpu-features-aarch64.cc | 2 +- test/aarch64/test-disasm-aarch64.cc | 7 +- test/aarch64/test-disasm-sve-aarch64.cc | 2 +- test/aarch64/test-metadata-aarch64.cc | 7 +- test/aarch64/test-pointer-auth-aarch64.cc | 5 +- test/aarch64/test-simulator-aarch64.cc | 203 +++++++++++-------- test/aarch64/test-simulator-sve-aarch64.cc | 2 +- test/aarch64/test-simulator-sve2-aarch64.cc | 7 +- test/aarch64/test-trace-aarch64.cc | 3 +- test/aarch64/test-utils-aarch64.cc | 3 +- test/aarch64/test-utils-aarch64.h | 26 +-- test/test-api.cc | 3 +- test/test-pool-manager.cc | 19 +- test/test-runner.cc | 4 +- test/test-runner.h | 1 + tools/clang_format.py | 69 ++++--- tools/clang_tidy.py | 36 +--- tools/test.py | 4 +- 68 files changed, 350 insertions(+), 299 deletions(-) diff --git a/README.md b/README.md index 8d24f500..8329d376 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ software is also required: 1. Git 2. [Google's `cpplint.py`][cpplint] - 3. clang-format-4.0 - 4. clang-tidy-4.0 + 3. clang-format 11+ + 4. clang-tidy 11+ Refer to the 'Usage' section for details. diff --git a/benchmarks/aarch64/bench-branch-link-masm.cc b/benchmarks/aarch64/bench-branch-link-masm.cc index 59f141ed..53a2b58f 100644 --- a/benchmarks/aarch64/bench-branch-link-masm.cc +++ b/benchmarks/aarch64/bench-branch-link-masm.cc @@ -24,13 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-branch-link.cc b/benchmarks/aarch64/bench-branch-link.cc index 43d399ed..b05e68d6 100644 --- a/benchmarks/aarch64/bench-branch-link.cc +++ b/benchmarks/aarch64/bench-branch-link.cc @@ -24,13 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-branch-masm.cc b/benchmarks/aarch64/bench-branch-masm.cc index d395c186..8b989954 100644 --- a/benchmarks/aarch64/bench-branch-masm.cc +++ b/benchmarks/aarch64/bench-branch-masm.cc @@ -24,13 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-branch.cc b/benchmarks/aarch64/bench-branch.cc index b695d930..8d00941b 100644 --- a/benchmarks/aarch64/bench-branch.cc +++ b/benchmarks/aarch64/bench-branch.cc @@ -24,13 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-dataop.cc b/benchmarks/aarch64/bench-dataop.cc index b7b5455d..a6333d22 100644 --- a/benchmarks/aarch64/bench-dataop.cc +++ b/benchmarks/aarch64/bench-dataop.cc @@ -24,13 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-mixed-disasm.cc b/benchmarks/aarch64/bench-mixed-disasm.cc index 17de32ea..785fb547 100644 --- a/benchmarks/aarch64/bench-mixed-disasm.cc +++ b/benchmarks/aarch64/bench-mixed-disasm.cc @@ -24,13 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-mixed-masm.cc b/benchmarks/aarch64/bench-mixed-masm.cc index a3bed0c9..689fb163 100644 --- a/benchmarks/aarch64/bench-mixed-masm.cc +++ b/benchmarks/aarch64/bench-mixed-masm.cc @@ -24,13 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-mixed-sim.cc b/benchmarks/aarch64/bench-mixed-sim.cc index 97394602..89e28aba 100644 --- a/benchmarks/aarch64/bench-mixed-sim.cc +++ b/benchmarks/aarch64/bench-mixed-sim.cc @@ -24,14 +24,13 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" #include "globals-vixl.h" #include "aarch64/instructions-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" -#include "bench-utils.h" - #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64 using namespace vixl; diff --git a/benchmarks/aarch64/bench-utils.cc b/benchmarks/aarch64/bench-utils.cc index 04f56eb1..7b5bafd6 100644 --- a/benchmarks/aarch64/bench-utils.cc +++ b/benchmarks/aarch64/bench-utils.cc @@ -24,12 +24,13 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "bench-utils.h" + #include #include "globals-vixl.h" -#include "aarch64/macro-assembler-aarch64.h" -#include "bench-utils.h" +#include "aarch64/macro-assembler-aarch64.h" using namespace vixl; using namespace vixl::aarch64; diff --git a/benchmarks/aarch64/bench-utils.h b/benchmarks/aarch64/bench-utils.h index a16bf62f..feb9f0e2 100644 --- a/benchmarks/aarch64/bench-utils.h +++ b/benchmarks/aarch64/bench-utils.h @@ -27,14 +27,14 @@ #ifndef VIXL_AARCH64_BENCH_UTILS_H_ #define VIXL_AARCH64_BENCH_UTILS_H_ +#include #include #include #include - -#include #include #include "globals-vixl.h" + #include "aarch64/macro-assembler-aarch64.h" class BenchTimer { @@ -90,7 +90,8 @@ class BenchCLI { } char* end; - unsigned long run_time = strtoul(argv[1], &end, 0); // NOLINT(runtime/int) + unsigned long run_time = // NOLINT(google-runtime-int) + strtoul(argv[1], &end, 0); if ((end == argv[1]) || (run_time > UINT32_MAX)) { PrintUsage(argv[0]); status_ = kExitFailure; @@ -242,7 +243,7 @@ class BenchCodeGenerator { vixl::aarch64::MacroAssembler* masm_; // State for *rand48(), used to randomise code generation. - unsigned short rand_state_[3]; // NOLINT(runtime/int) + unsigned short rand_state_[3]; // NOLINT(google-runtime-int) uint32_t rnd_; int rnd_bits_; diff --git a/examples/aarch64/custom-disassembler.cc b/examples/aarch64/custom-disassembler.cc index 73ca4898..49c95652 100644 --- a/examples/aarch64/custom-disassembler.cc +++ b/examples/aarch64/custom-disassembler.cc @@ -24,9 +24,10 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "custom-disassembler.h" + #include -#include "custom-disassembler.h" #include "examples.h" using namespace vixl; diff --git a/examples/aarch64/disasm.cc b/examples/aarch64/disasm.cc index 1c580270..f546dcf4 100644 --- a/examples/aarch64/disasm.cc +++ b/examples/aarch64/disasm.cc @@ -30,6 +30,7 @@ #include #include "code-buffer-vixl.h" + #include "aarch64/decoder-aarch64.h" #include "aarch64/disasm-aarch64.h" diff --git a/examples/aarch64/getting-started.cc b/examples/aarch64/getting-started.cc index e1ebf95a..dc9705e2 100644 --- a/examples/aarch64/getting-started.cc +++ b/examples/aarch64/getting-started.cc @@ -24,11 +24,11 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "executable-memory.h" + #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" -#include "executable-memory.h" - using namespace vixl; using namespace vixl::aarch64; diff --git a/examples/aarch64/literal.cc b/examples/aarch64/literal.cc index 43effe5c..5ddafac0 100644 --- a/examples/aarch64/literal.cc +++ b/examples/aarch64/literal.cc @@ -84,6 +84,8 @@ int64_t LiteralExample(int64_t a, int64_t b) { b, simulator.ReadXRegister(0)); + free(code); + return simulator.ReadXRegister(0); } #endif diff --git a/examples/aarch64/non-const-visitor.cc b/examples/aarch64/non-const-visitor.cc index 307b618f..ca16b6cc 100644 --- a/examples/aarch64/non-const-visitor.cc +++ b/examples/aarch64/non-const-visitor.cc @@ -24,10 +24,11 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "non-const-visitor.h" + #include #include "examples.h" -#include "non-const-visitor.h" using namespace vixl; using namespace vixl::aarch64; diff --git a/src/aarch64/abi-aarch64.h b/src/aarch64/abi-aarch64.h index 7e6cd9a4..388cf10f 100644 --- a/src/aarch64/abi-aarch64.h +++ b/src/aarch64/abi-aarch64.h @@ -159,8 +159,8 @@ template <> inline GenericOperand ABI::GetReturnGenericOperand() const { return GenericOperand(); } -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl #endif // VIXL_AARCH64_ABI_AARCH64_H_ diff --git a/src/aarch64/assembler-aarch64.cc b/src/aarch64/assembler-aarch64.cc index f7fbd5e6..c0227177 100644 --- a/src/aarch64/assembler-aarch64.cc +++ b/src/aarch64/assembler-aarch64.cc @@ -25,9 +25,10 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "assembler-aarch64.h" + #include -#include "assembler-aarch64.h" #include "macro-assembler-aarch64.h" namespace vixl { diff --git a/src/aarch64/assembler-aarch64.h b/src/aarch64/assembler-aarch64.h index 1cc53d5f..2746f2c8 100644 --- a/src/aarch64/assembler-aarch64.h +++ b/src/aarch64/assembler-aarch64.h @@ -33,6 +33,7 @@ #include "../globals-vixl.h" #include "../invalset-vixl.h" #include "../utils-vixl.h" + #include "operands-aarch64.h" namespace vixl { diff --git a/src/aarch64/cpu-features-auditor-aarch64.cc b/src/aarch64/cpu-features-auditor-aarch64.cc index 563ee078..c1981773 100644 --- a/src/aarch64/cpu-features-auditor-aarch64.cc +++ b/src/aarch64/cpu-features-auditor-aarch64.cc @@ -24,12 +24,13 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "cpu-features-auditor-aarch64.h" + #include "cpu-features.h" #include "globals-vixl.h" #include "utils-vixl.h" -#include "decoder-aarch64.h" -#include "cpu-features-auditor-aarch64.h" +#include "decoder-aarch64.h" namespace vixl { namespace aarch64 { diff --git a/src/aarch64/cpu-features-auditor-aarch64.h b/src/aarch64/cpu-features-auditor-aarch64.h index 041bc88e..613c5009 100644 --- a/src/aarch64/cpu-features-auditor-aarch64.h +++ b/src/aarch64/cpu-features-auditor-aarch64.h @@ -32,6 +32,7 @@ #include #include "cpu-features.h" + #include "decoder-aarch64.h" #include "decoder-visitor-map-aarch64.h" diff --git a/src/aarch64/debugger-aarch64.h b/src/aarch64/debugger-aarch64.h index 88660942..b22b8aa0 100644 --- a/src/aarch64/debugger-aarch64.h +++ b/src/aarch64/debugger-aarch64.h @@ -27,6 +27,7 @@ #ifndef VIXL_AARCH64_DEBUGGER_AARCH64_H_ #define VIXL_AARCH64_DEBUGGER_AARCH64_H_ +#include #include #include diff --git a/src/aarch64/decoder-aarch64.cc b/src/aarch64/decoder-aarch64.cc index dc56633a..4ff02c11 100644 --- a/src/aarch64/decoder-aarch64.cc +++ b/src/aarch64/decoder-aarch64.cc @@ -24,12 +24,13 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "decoder-aarch64.h" + #include #include "../globals-vixl.h" #include "../utils-vixl.h" -#include "decoder-aarch64.h" #include "decoder-constants-aarch64.h" namespace vixl { diff --git a/src/aarch64/disasm-aarch64.cc b/src/aarch64/disasm-aarch64.cc index 3592752c..ae8fac87 100644 --- a/src/aarch64/disasm-aarch64.cc +++ b/src/aarch64/disasm-aarch64.cc @@ -24,12 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "disasm-aarch64.h" + #include #include #include -#include "disasm-aarch64.h" - namespace vixl { namespace aarch64 { diff --git a/src/aarch64/instructions-aarch64.cc b/src/aarch64/instructions-aarch64.cc index a2d05472..298a7be8 100644 --- a/src/aarch64/instructions-aarch64.cc +++ b/src/aarch64/instructions-aarch64.cc @@ -25,6 +25,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "instructions-aarch64.h" + #include "assembler-aarch64.h" namespace vixl { diff --git a/src/aarch64/instructions-aarch64.h b/src/aarch64/instructions-aarch64.h index ec84e26e..38a0d67c 100644 --- a/src/aarch64/instructions-aarch64.h +++ b/src/aarch64/instructions-aarch64.h @@ -147,19 +147,19 @@ const unsigned kMTETagWidth = 4; // Make these moved float constants backwards compatible // with explicit vixl::aarch64:: namespace references. -using vixl::kDoubleMantissaBits; using vixl::kDoubleExponentBits; -using vixl::kFloatMantissaBits; -using vixl::kFloatExponentBits; -using vixl::kFloat16MantissaBits; +using vixl::kDoubleMantissaBits; using vixl::kFloat16ExponentBits; +using vixl::kFloat16MantissaBits; +using vixl::kFloatExponentBits; +using vixl::kFloatMantissaBits; -using vixl::kFP16PositiveInfinity; using vixl::kFP16NegativeInfinity; -using vixl::kFP32PositiveInfinity; +using vixl::kFP16PositiveInfinity; using vixl::kFP32NegativeInfinity; -using vixl::kFP64PositiveInfinity; +using vixl::kFP32PositiveInfinity; using vixl::kFP64NegativeInfinity; +using vixl::kFP64PositiveInfinity; using vixl::kFP16DefaultNaN; using vixl::kFP32DefaultNaN; diff --git a/src/aarch64/macro-assembler-aarch64.cc b/src/aarch64/macro-assembler-aarch64.cc index 71ad1397..8b8bd524 100644 --- a/src/aarch64/macro-assembler-aarch64.cc +++ b/src/aarch64/macro-assembler-aarch64.cc @@ -24,10 +24,10 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include - #include "macro-assembler-aarch64.h" +#include + namespace vixl { namespace aarch64 { @@ -194,9 +194,8 @@ void VeneerPool::Reset() { void VeneerPool::Release() { if (--monitor_ == 0) { - VIXL_ASSERT(IsEmpty() || - masm_->GetCursorOffset() < - unresolved_branches_.GetFirstLimit()); + VIXL_ASSERT(IsEmpty() || masm_->GetCursorOffset() < + unresolved_branches_.GetFirstLimit()); } } diff --git a/src/aarch64/macro-assembler-aarch64.h b/src/aarch64/macro-assembler-aarch64.h index 78c9e9a4..a46e2ccc 100644 --- a/src/aarch64/macro-assembler-aarch64.h +++ b/src/aarch64/macro-assembler-aarch64.h @@ -1754,7 +1754,7 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface { V(casah, Casah) \ V(caslh, Caslh) \ V(casalh, Casalh) -// clang-format on + // clang-format on #define DEFINE_MACRO_ASM_FUNC(ASM, MASM) \ void MASM(const Register& rs, const Register& rt, const MemOperand& src) { \ @@ -1772,7 +1772,7 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface { V(caspa, Caspa) \ V(caspl, Caspl) \ V(caspal, Caspal) -// clang-format on + // clang-format on #define DEFINE_MACRO_ASM_FUNC(ASM, MASM) \ void MASM(const Register& rs, \ @@ -1817,7 +1817,7 @@ class MacroAssembler : public Assembler, public MacroAssemblerInterface { V(MASM##alb, ASM##alb) \ V(MASM##ah, ASM##ah) \ V(MASM##alh, ASM##alh) -// clang-format on + // clang-format on #define DEFINE_MACRO_LOAD_ASM_FUNC(MASM, ASM) \ void MASM(const Register& rs, const Register& rt, const MemOperand& src) { \ diff --git a/src/aarch64/operands-aarch64.cc b/src/aarch64/operands-aarch64.cc index e01d1907..d1bd81c5 100644 --- a/src/aarch64/operands-aarch64.cc +++ b/src/aarch64/operands-aarch64.cc @@ -465,5 +465,5 @@ bool GenericOperand::Equals(const GenericOperand& other) const { } return false; } -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl diff --git a/src/aarch64/operands-aarch64.h b/src/aarch64/operands-aarch64.h index ba3df181..54695422 100644 --- a/src/aarch64/operands-aarch64.h +++ b/src/aarch64/operands-aarch64.h @@ -735,7 +735,7 @@ class SVEMemOperand { class IntegerOperand { public: #define VIXL_INT_TYPES(V) \ - V(char) V(short) V(int) V(long) V(long long) // NOLINT(runtime/int) + V(char) V(short) V(int) V(long) V(long long) // NOLINT(google-runtime-int) #define VIXL_DECL_INT_OVERLOADS(T) \ /* These are allowed to be implicit constructors because this is a */ \ /* wrapper class that doesn't normally perform any type conversion. */ \ @@ -993,7 +993,7 @@ class GenericOperand { // We only support sizes up to X/D register sizes. size_t mem_op_size_; }; -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl #endif // VIXL_AARCH64_OPERANDS_AARCH64_H_ diff --git a/src/aarch64/pointer-auth-aarch64.cc b/src/aarch64/pointer-auth-aarch64.cc index 55cf4ca5..a33f39a8 100644 --- a/src/aarch64/pointer-auth-aarch64.cc +++ b/src/aarch64/pointer-auth-aarch64.cc @@ -26,10 +26,10 @@ #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64 -#include "simulator-aarch64.h" - #include "utils-vixl.h" +#include "simulator-aarch64.h" + namespace vixl { namespace aarch64 { diff --git a/src/aarch64/registers-aarch64.cc b/src/aarch64/registers-aarch64.cc index 90201a60..f7101a76 100644 --- a/src/aarch64/registers-aarch64.cc +++ b/src/aarch64/registers-aarch64.cc @@ -24,11 +24,11 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "registers-aarch64.h" + #include #include -#include "registers-aarch64.h" - namespace vixl { namespace aarch64 { @@ -317,5 +317,5 @@ bool AreSameLaneSize(const CPURegister& reg1, !reg4.IsValid() || (reg4.GetLaneSizeInBits() == reg1.GetLaneSizeInBits()); return match; } -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl diff --git a/src/aarch64/registers-aarch64.h b/src/aarch64/registers-aarch64.h index f9a6d897..7175c650 100644 --- a/src/aarch64/registers-aarch64.h +++ b/src/aarch64/registers-aarch64.h @@ -895,7 +895,7 @@ bool AreSameLaneSize(const CPURegister& reg1, const CPURegister& reg2, const CPURegister& reg3 = NoCPUReg, const CPURegister& reg4 = NoCPUReg); -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl #endif // VIXL_AARCH64_REGISTERS_AARCH64_H_ diff --git a/src/aarch64/simulator-aarch64.cc b/src/aarch64/simulator-aarch64.cc index a02a2965..5166ec87 100644 --- a/src/aarch64/simulator-aarch64.cc +++ b/src/aarch64/simulator-aarch64.cc @@ -26,16 +26,14 @@ #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64 -#include - -#include -#include +#include "simulator-aarch64.h" #include #include +#include #include - -#include "simulator-aarch64.h" +#include +#include namespace vixl { namespace aarch64 { @@ -5090,7 +5088,7 @@ void Simulator::VisitAtomicMemory(const Instruction* instr) { ATOMIC_MEMORY_SIMPLE_INT_LIST(SIM_FUNC_x) AtomicMemorySimpleHelper(instr); break; - // clang-format on + // clang-format on case SWPB: case SWPAB: diff --git a/src/aarch64/simulator-aarch64.h b/src/aarch64/simulator-aarch64.h index e739af07..5c2054d4 100644 --- a/src/aarch64/simulator-aarch64.h +++ b/src/aarch64/simulator-aarch64.h @@ -33,8 +33,8 @@ #include "../globals-vixl.h" #include "../utils-vixl.h" - #include "cpu-features.h" + #include "abi-aarch64.h" #include "cpu-features-auditor-aarch64.h" #include "debugger-aarch64.h" @@ -3083,8 +3083,9 @@ class Simulator : public DecoderVisitor { // either MTE protected or not. if (count != expected) { std::stringstream sstream; - sstream << std::hex << "MTE WARNING : the memory region being unmapped " - "starting at address 0x" + sstream << std::hex + << "MTE WARNING : the memory region being unmapped " + "starting at address 0x" << reinterpret_cast(address) << "is not fully MTE protected.\n"; VIXL_WARNING(sstream.str().c_str()); diff --git a/src/code-generation-scopes-vixl.h b/src/code-generation-scopes-vixl.h index b7ea2d92..f019b685 100644 --- a/src/code-generation-scopes-vixl.h +++ b/src/code-generation-scopes-vixl.h @@ -68,14 +68,19 @@ class CodeBufferCheckScope { size_t size, BufferSpacePolicy check_policy = kReserveBufferSpace, SizePolicy size_policy = kMaximumSize) - : assembler_(NULL), initialised_(false) { + : CodeBufferCheckScope() { Open(assembler, size, check_policy, size_policy); } // This constructor does not implicitly initialise the scope. Instead, the // user is required to explicitly call the `Open` function before using the // scope. - CodeBufferCheckScope() : assembler_(NULL), initialised_(false) { + CodeBufferCheckScope() + : assembler_(NULL), + assert_policy_(kMaximumSize), + limit_(0), + previous_allow_assembler_(false), + initialised_(false) { // Nothing to do. } @@ -152,14 +157,15 @@ class EmissionCheckScope : public CodeBufferCheckScope { // constructed. EmissionCheckScope(MacroAssemblerInterface* masm, size_t size, - SizePolicy size_policy = kMaximumSize) { + SizePolicy size_policy = kMaximumSize) + : EmissionCheckScope() { Open(masm, size, size_policy); } // This constructor does not implicitly initialise the scope. Instead, the // user is required to explicitly call the `Open` function before using the // scope. - EmissionCheckScope() {} + EmissionCheckScope() : masm_(nullptr), pool_policy_(kBlockPools) {} virtual ~EmissionCheckScope() { Close(); } @@ -250,14 +256,15 @@ class ExactAssemblyScope : public EmissionCheckScope { // constructed. ExactAssemblyScope(MacroAssemblerInterface* masm, size_t size, - SizePolicy size_policy = kExactSize) { + SizePolicy size_policy = kExactSize) + : ExactAssemblyScope() { Open(masm, size, size_policy); } // This constructor does not implicitly initialise the scope. Instead, the // user is required to explicitly call the `Open` function before using the // scope. - ExactAssemblyScope() {} + ExactAssemblyScope() : previous_allow_macro_assembler_(false) {} virtual ~ExactAssemblyScope() { Close(); } diff --git a/src/compiler-intrinsics-vixl.cc b/src/compiler-intrinsics-vixl.cc index f6234fa6..b8ed1b21 100644 --- a/src/compiler-intrinsics-vixl.cc +++ b/src/compiler-intrinsics-vixl.cc @@ -25,6 +25,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "compiler-intrinsics-vixl.h" + #include "utils-vixl.h" namespace vixl { diff --git a/src/compiler-intrinsics-vixl.h b/src/compiler-intrinsics-vixl.h index 50ed3579..8d0849a8 100644 --- a/src/compiler-intrinsics-vixl.h +++ b/src/compiler-intrinsics-vixl.h @@ -29,6 +29,7 @@ #define VIXL_COMPILER_INTRINSICS_H #include + #include "globals-vixl.h" namespace vixl { @@ -112,7 +113,8 @@ inline int CountLeadingSignBits(V value, int width = (sizeof(V) * 8)) { VIXL_ASSERT(IsPowerOf2(width) && (width <= 64)); #if COMPILER_HAS_BUILTIN_CLRSB VIXL_ASSERT((LLONG_MIN <= value) && (value <= LLONG_MAX)); - int ll_width = sizeof(long long) * kBitsPerByte; // NOLINT(runtime/int) + int ll_width = + sizeof(long long) * kBitsPerByte; // NOLINT(google-runtime-int) int result = __builtin_clrsbll(value) - (ll_width - width); // Check that the value fits in the specified width. VIXL_ASSERT(result >= 0); diff --git a/src/cpu-features.cc b/src/cpu-features.cc index 08db3f44..e1bd0f15 100644 --- a/src/cpu-features.cc +++ b/src/cpu-features.cc @@ -24,9 +24,10 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "cpu-features.h" + #include -#include "cpu-features.h" #include "globals-vixl.h" #include "utils-vixl.h" diff --git a/src/invalset-vixl.h b/src/invalset-vixl.h index 671dc0d0..40ba5078 100644 --- a/src/invalset-vixl.h +++ b/src/invalset-vixl.h @@ -27,9 +27,8 @@ #ifndef VIXL_INVALSET_H_ #define VIXL_INVALSET_H_ -#include - #include +#include #include #include "globals-vixl.h" @@ -244,8 +243,10 @@ class InvalSet { template -class InvalSetIterator : public std::iterator { +class InvalSetIterator + : public std::iterator< // NOLINT(clang-diagnostic-deprecated-declarations) + std::forward_iterator_tag, + typename S::_ElementType> { private: // Redefine types to mirror the associated set types. typedef typename S::_ElementType ElementType; diff --git a/src/pool-manager-impl.h b/src/pool-manager-impl.h index a1bcaaad..3cee3b77 100644 --- a/src/pool-manager-impl.h +++ b/src/pool-manager-impl.h @@ -27,10 +27,10 @@ #ifndef VIXL_POOL_MANAGER_IMPL_H_ #define VIXL_POOL_MANAGER_IMPL_H_ -#include "pool-manager.h" - #include + #include "assembler-base-vixl.h" +#include "pool-manager.h" namespace vixl { @@ -517,6 +517,6 @@ int PoolManager::GetPoolSizeForTest() const { } return size; } -} +} // namespace vixl #endif // VIXL_POOL_MANAGER_IMPL_H_ diff --git a/src/pool-manager.h b/src/pool-manager.h index 27fa69ec..f5101cc7 100644 --- a/src/pool-manager.h +++ b/src/pool-manager.h @@ -27,11 +27,10 @@ #ifndef VIXL_POOL_MANAGER_H_ #define VIXL_POOL_MANAGER_H_ -#include - #include #include #include +#include #include #include "globals-vixl.h" diff --git a/test/aarch64/examples/test-examples.cc b/test/aarch64/examples/test-examples.cc index 0b4dbb05..7bf4af47 100644 --- a/test/aarch64/examples/test-examples.cc +++ b/test/aarch64/examples/test-examples.cc @@ -29,8 +29,8 @@ #include "non-const-visitor.h" #include "test-runner.h" #include "test-utils.h" -#include "../test-utils-aarch64.h" +#include "../test-utils-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" #define TEST(name) TEST_(EXAMPLE_##name) diff --git a/test/aarch64/test-abi.cc b/test/aarch64/test-abi.cc index d6b15637..0b9a1b0e 100644 --- a/test/aarch64/test-abi.cc +++ b/test/aarch64/test-abi.cc @@ -25,9 +25,9 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "test-runner.h" -#include "test-utils-aarch64.h" #include "aarch64/abi-aarch64.h" +#include "test-utils-aarch64.h" #if (__cplusplus >= 201103L) && !defined(VIXL_HAS_ABI_SUPPORT) #error "C++11 should be sufficient to provide ABI support." @@ -51,9 +51,9 @@ TEST(abi) { VIXL_CHECK(abi.GetReturnGenericOperand().Equals(GenericOperand(w0))); VIXL_CHECK(abi.GetReturnGenericOperand().Equals(GenericOperand(w0))); VIXL_CHECK(abi.GetReturnGenericOperand().Equals(GenericOperand(w0))); - VIXL_CHECK( - abi.GetReturnGenericOperand().Equals( // NOLINT(runtime/int) - GenericOperand(w0))); + VIXL_CHECK(abi.GetReturnGenericOperand() + .Equals( // NOLINT(google-runtime-int) + GenericOperand(w0))); VIXL_CHECK(abi.GetReturnGenericOperand().Equals(GenericOperand(w0))); VIXL_CHECK( abi.GetReturnGenericOperand().Equals(GenericOperand(w0))); @@ -92,7 +92,7 @@ TEST(abi) { CHECK_NEXT_PARAMETER_REG(uint64_t, x4); CHECK_NEXT_PARAMETER_REG(void*, x5); CHECK_NEXT_PARAMETER_REG(uint32_t, w6); - typedef short my_type; // NOLINT(runtime/int) + typedef short my_type; // NOLINT(google-runtime-int) CHECK_NEXT_PARAMETER_REG(my_type, w7); CHECK_NEXT_PARAMETER_MEM(int, MemOperand(sp, 0), kWRegSizeInBytes); CHECK_NEXT_PARAMETER_MEM(int, MemOperand(sp, 8), kWRegSizeInBytes); @@ -102,14 +102,14 @@ TEST(abi) { CHECK_NEXT_PARAMETER_REG(double, d7); CHECK_NEXT_PARAMETER_MEM(double, MemOperand(sp, 16), kDRegSizeInBytes); CHECK_NEXT_PARAMETER_MEM(bool, MemOperand(sp, 24), kWRegSizeInBytes); - CHECK_NEXT_PARAMETER_MEM(short, // NOLINT(runtime/int) + CHECK_NEXT_PARAMETER_MEM(short, // NOLINT(google-runtime-int) MemOperand(sp, 32), kWRegSizeInBytes); CHECK_NEXT_PARAMETER_MEM(float, MemOperand(sp, 40), kSRegSizeInBytes); CHECK_NEXT_PARAMETER_MEM(float, MemOperand(sp, 48), kSRegSizeInBytes); VIXL_CHECK(abi.GetStackSpaceRequired() == 56); } -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl #endif // VIXL_HAS_ABI_SUPPORT diff --git a/test/aarch64/test-api-aarch64.cc b/test/aarch64/test-api-aarch64.cc index 53cb54ea..c724f178 100644 --- a/test/aarch64/test-api-aarch64.cc +++ b/test/aarch64/test-api-aarch64.cc @@ -30,11 +30,11 @@ #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/registers-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #define __ masm. #define TEST(name) TEST_(AARCH64_API_##name) diff --git a/test/aarch64/test-api-movprfx-aarch64.cc b/test/aarch64/test-api-movprfx-aarch64.cc index d3339899..7263a083 100644 --- a/test/aarch64/test-api-movprfx-aarch64.cc +++ b/test/aarch64/test-api-movprfx-aarch64.cc @@ -30,10 +30,10 @@ #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/assembler-aarch64.h" #include "aarch64/instructions-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #define __ assm. #define TEST(name) TEST_(AARCH64_API_##name) @@ -50,7 +50,7 @@ class InstructionReporter : public DecoderVisitor { instr_form_ = (*metadata)["form"]; } - std::string MoveForm() { return std::move(instr_form_); } + std::string MoveForm() { return instr_form_; } private: std::string instr_form_; diff --git a/test/aarch64/test-assembler-aarch64.cc b/test/aarch64/test-assembler-aarch64.cc index 3675eb95..00155471 100644 --- a/test/aarch64/test-assembler-aarch64.cc +++ b/test/aarch64/test-assembler-aarch64.cc @@ -24,23 +24,23 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include +#include "test-assembler-aarch64.h" #include #include #include #include #include +#include #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" -#include "test-assembler-aarch64.h" +#include "aarch64/test-utils-aarch64.h" namespace vixl { namespace aarch64 { diff --git a/test/aarch64/test-assembler-fp-aarch64.cc b/test/aarch64/test-assembler-fp-aarch64.cc index c49a1fbb..56073592 100644 --- a/test/aarch64/test-assembler-fp-aarch64.cc +++ b/test/aarch64/test-assembler-fp-aarch64.cc @@ -24,22 +24,21 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include - #include #include #include #include #include +#include #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #include "test-assembler-aarch64.h" namespace vixl { diff --git a/test/aarch64/test-assembler-neon-aarch64.cc b/test/aarch64/test-assembler-neon-aarch64.cc index 3e1e09bd..1682d13e 100644 --- a/test/aarch64/test-assembler-neon-aarch64.cc +++ b/test/aarch64/test-assembler-neon-aarch64.cc @@ -24,22 +24,21 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include - #include #include #include #include #include +#include #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #include "test-assembler-aarch64.h" namespace vixl { diff --git a/test/aarch64/test-assembler-sve-aarch64.cc b/test/aarch64/test-assembler-sve-aarch64.cc index f34c2466..f16ab336 100644 --- a/test/aarch64/test-assembler-sve-aarch64.cc +++ b/test/aarch64/test-assembler-sve-aarch64.cc @@ -24,24 +24,23 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include -#include - #include #include #include #include #include #include +#include +#include #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #include "test-assembler-aarch64.h" #define TEST_SVE(name) TEST_SVE_INNER("ASM", name) @@ -8705,7 +8704,7 @@ static void BufferFillingHelper(uint64_t data_ptr, uint64_t* addresses = nullptr, uint64_t* max_address = nullptr) { // Use a fixed seed for nrand48() so that test runs are reproducible. - unsigned short seed[3] = {1, 2, 3}; // NOLINT(runtime/int) + unsigned short seed[3] = {1, 2, 3}; // NOLINT(google-runtime-int) // Fill a buffer with arbitrary data. for (size_t i = 0; i < buffer_size; i++) { diff --git a/test/aarch64/test-cpu-features-aarch64.cc b/test/aarch64/test-cpu-features-aarch64.cc index f23da938..4a82127f 100644 --- a/test/aarch64/test-cpu-features-aarch64.cc +++ b/test/aarch64/test-cpu-features-aarch64.cc @@ -30,9 +30,9 @@ #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #define __ masm-> #define TEST(name) TEST_(AARCH64_CPUFeatures_##name) diff --git a/test/aarch64/test-disasm-aarch64.cc b/test/aarch64/test-disasm-aarch64.cc index 99cf4ec1..2babb9e6 100644 --- a/test/aarch64/test-disasm-aarch64.cc +++ b/test/aarch64/test-disasm-aarch64.cc @@ -25,6 +25,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "test-disasm-aarch64.h" + #include #include #include @@ -33,7 +35,6 @@ #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" -#include "test-disasm-aarch64.h" namespace vixl { namespace aarch64 { @@ -1851,8 +1852,8 @@ TEST(load_store_exclusive) { TEST(atomic_memory) { SETUP(); -// These macros generate tests for all the variations of the atomic memory -// operations, e.g. ldadd, ldadda, ldaddb, staddl, etc. + // These macros generate tests for all the variations of the atomic memory + // operations, e.g. ldadd, ldadda, ldaddb, staddl, etc. #define AM_LOAD_X_TESTS(N, MN) \ COMPARE(ld##N(x0, x1, MemOperand(x2)), "ld" MN " x0, x1, [x2]"); \ diff --git a/test/aarch64/test-disasm-sve-aarch64.cc b/test/aarch64/test-disasm-sve-aarch64.cc index c6b7e312..5e001e7e 100644 --- a/test/aarch64/test-disasm-sve-aarch64.cc +++ b/test/aarch64/test-disasm-sve-aarch64.cc @@ -30,10 +30,10 @@ #include #include "test-runner.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #include "test-disasm-aarch64.h" #include "test-utils-aarch64.h" diff --git a/test/aarch64/test-metadata-aarch64.cc b/test/aarch64/test-metadata-aarch64.cc index a96e4e05..350c9597 100644 --- a/test/aarch64/test-metadata-aarch64.cc +++ b/test/aarch64/test-metadata-aarch64.cc @@ -29,13 +29,12 @@ #include "test-runner.h" #include "test-utils.h" -#include "aarch64/cpu-aarch64.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #include "test-assembler-aarch64.h" namespace vixl { @@ -127,5 +126,5 @@ TEST(test_metadata_mte_neg) { } #endif // VIXL_NEGATIVE_TESTING #endif // VIXL_INCLUDE_SIMULATOR_AARCH64 -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl diff --git a/test/aarch64/test-pointer-auth-aarch64.cc b/test/aarch64/test-pointer-auth-aarch64.cc index 80ea873c..b97a58ce 100644 --- a/test/aarch64/test-pointer-auth-aarch64.cc +++ b/test/aarch64/test-pointer-auth-aarch64.cc @@ -27,6 +27,7 @@ #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64 #include "test-runner.h" + #include "aarch64/simulator-aarch64.h" #define TEST(name) TEST_(AARCH64_POINTER_AUTH_##name) @@ -92,7 +93,7 @@ TEST(add_and_strip_pac) { VIXL_CHECK(sim.StripPAC(ptr_a, Simulator::kInstructionPointer) == ptr); } -} -} // namespace vixl::aarch64 +} // namespace aarch64 +} // namespace vixl #endif // VIXL_INCLUDE_SIMULATOR_AARCH64 diff --git a/test/aarch64/test-simulator-aarch64.cc b/test/aarch64/test-simulator-aarch64.cc index 5ee1e0f4..0a9dabed 100644 --- a/test/aarch64/test-simulator-aarch64.cc +++ b/test/aarch64/test-simulator-aarch64.cc @@ -26,19 +26,17 @@ #include #include - #include #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-simulator-inputs-aarch64.h" -#include "aarch64/test-simulator-traces-aarch64.h" -#include "aarch64/test-utils-aarch64.h" - #include "aarch64/cpu-features-auditor-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-simulator-inputs-aarch64.h" +#include "aarch64/test-simulator-traces-aarch64.h" +#include "aarch64/test-utils-aarch64.h" namespace vixl { namespace aarch64 { @@ -3009,23 +3007,31 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) kFormat##vdform, \ kFormat##vnform) -#define CALL_TEST_NEON_HELPER_2Op( \ - mnemonic, vdform, vnform, vmform, input_d, input_n, input_m) \ - Test2OpNEON(STRINGIFY(mnemonic) "_" STRINGIFY(vdform), \ - &MacroAssembler::mnemonic, \ - input_d, \ - input_n, \ - (sizeof(input_n) / sizeof(input_n[0])), \ - input_m, \ - (sizeof(input_m) / sizeof(input_m[0])), \ - kExpected_NEON_##mnemonic##_##vdform, \ - kExpectedCount_NEON_##mnemonic##_##vdform, \ - kFormat##vdform, \ - kFormat##vnform, \ +#define CALL_TEST_NEON_HELPER_2Op(mnemonic, \ + vdform, \ + vnform, \ + vmform, \ + input_d, \ + input_n, \ + input_m) \ + Test2OpNEON(STRINGIFY(mnemonic) "_" STRINGIFY(vdform), \ + &MacroAssembler::mnemonic, \ + input_d, \ + input_n, \ + (sizeof(input_n) / sizeof(input_n[0])), \ + input_m, \ + (sizeof(input_m) / sizeof(input_m[0])), \ + kExpected_NEON_##mnemonic##_##vdform, \ + kExpectedCount_NEON_##mnemonic##_##vdform, \ + kFormat##vdform, \ + kFormat##vnform, \ kFormat##vmform) -#define CALL_TEST_NEON_HELPER_2OpImm( \ - mnemonic, vdform, vnform, input_n, input_m) \ +#define CALL_TEST_NEON_HELPER_2OpImm(mnemonic, \ + vdform, \ + vnform, \ + input_n, \ + input_m) \ Test2OpImmNEON(STRINGIFY(mnemonic) "_" STRINGIFY(vdform) "_2OPIMM", \ &MacroAssembler::mnemonic, \ input_n, \ @@ -3037,23 +3043,29 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) kFormat##vdform, \ kFormat##vnform) -#define CALL_TEST_NEON_HELPER_ByElement( \ - mnemonic, vdform, vnform, vmform, input_d, input_n, input_m, indices) \ - TestByElementNEON( \ - STRINGIFY(mnemonic) "_" STRINGIFY(vdform) "_" STRINGIFY( \ - vnform) "_" STRINGIFY(vmform), \ - &MacroAssembler::mnemonic, \ - input_d, \ - input_n, \ - (sizeof(input_n) / sizeof(input_n[0])), \ - input_m, \ - (sizeof(input_m) / sizeof(input_m[0])), \ - indices, \ - (sizeof(indices) / sizeof(indices[0])), \ - kExpected_NEON_##mnemonic##_##vdform##_##vnform##_##vmform, \ - kExpectedCount_NEON_##mnemonic##_##vdform##_##vnform##_##vmform, \ - kFormat##vdform, \ - kFormat##vnform, \ +#define CALL_TEST_NEON_HELPER_ByElement(mnemonic, \ + vdform, \ + vnform, \ + vmform, \ + input_d, \ + input_n, \ + input_m, \ + indices) \ + TestByElementNEON( \ + STRINGIFY(mnemonic) "_" STRINGIFY(vdform) "_" STRINGIFY( \ + vnform) "_" STRINGIFY(vmform), \ + &MacroAssembler::mnemonic, \ + input_d, \ + input_n, \ + (sizeof(input_n) / sizeof(input_n[0])), \ + input_m, \ + (sizeof(input_m) / sizeof(input_m[0])), \ + indices, \ + (sizeof(indices) / sizeof(indices[0])), \ + kExpected_NEON_##mnemonic##_##vdform##_##vnform##_##vmform, \ + kExpectedCount_NEON_##mnemonic##_##vdform##_##vnform##_##vmform, \ + kFormat##vdform, \ + kFormat##vnform, \ kFormat##vmform) #define CALL_TEST_NEON_HELPER_ByElement_Dot_Product(mnemonic, \ @@ -3543,16 +3555,21 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) kInputFloat16##input_m); \ } -#define CALL_TEST_NEON_HELPER_3DIFF( \ - mnemonic, vdform, vnform, vmform, input_d, input_n, input_m) \ - { \ - CALL_TEST_NEON_HELPER_2Op(mnemonic, \ - vdform, \ - vnform, \ - vmform, \ - input_d, \ - input_n, \ - input_m); \ +#define CALL_TEST_NEON_HELPER_3DIFF(mnemonic, \ + vdform, \ + vnform, \ + vmform, \ + input_d, \ + input_n, \ + input_m) \ + { \ + CALL_TEST_NEON_HELPER_2Op(mnemonic, \ + vdform, \ + vnform, \ + vmform, \ + input_d, \ + input_n, \ + input_m); \ } #define DEFINE_TEST_NEON_3DIFF_LONG_8H(mnemonic, input) \ @@ -3783,14 +3800,17 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) } -#define CALL_TEST_NEON_HELPER_2OPIMM( \ - mnemonic, vdform, vnform, input_n, input_imm) \ - { \ - CALL_TEST_NEON_HELPER_2OpImm(mnemonic, \ - vdform, \ - vnform, \ - input_n, \ - input_imm); \ +#define CALL_TEST_NEON_HELPER_2OPIMM(mnemonic, \ + vdform, \ + vnform, \ + input_n, \ + input_imm) \ + { \ + CALL_TEST_NEON_HELPER_2OpImm(mnemonic, \ + vdform, \ + vnform, \ + input_n, \ + input_imm); \ } #define DEFINE_TEST_NEON_2OPIMM(mnemonic, input, input_imm) \ @@ -4223,8 +4243,10 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) vm_subvector_count); \ } -#define DEFINE_TEST_NEON_BYELEMENT_DOT_PRODUCT( \ - mnemonic, input_d, input_n, input_m) \ +#define DEFINE_TEST_NEON_BYELEMENT_DOT_PRODUCT(mnemonic, \ + input_d, \ + input_n, \ + input_m) \ TEST(mnemonic##_2S_8B_B) { \ CALL_TEST_NEON_HELPER_BYELEMENT_DOT_PRODUCT(mnemonic, \ 2S, \ @@ -4248,17 +4270,23 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) 4); \ } -#define CALL_TEST_NEON_HELPER_BYELEMENT( \ - mnemonic, vdform, vnform, vmform, input_d, input_n, input_m, indices) \ - { \ - CALL_TEST_NEON_HELPER_ByElement(mnemonic, \ - vdform, \ - vnform, \ - vmform, \ - input_d, \ - input_n, \ - input_m, \ - indices); \ +#define CALL_TEST_NEON_HELPER_BYELEMENT(mnemonic, \ + vdform, \ + vnform, \ + vmform, \ + input_d, \ + input_n, \ + input_m, \ + indices) \ + { \ + CALL_TEST_NEON_HELPER_ByElement(mnemonic, \ + vdform, \ + vnform, \ + vmform, \ + input_d, \ + input_n, \ + input_m, \ + indices); \ } #define DEFINE_TEST_NEON_BYELEMENT(mnemonic, input_d, input_n, input_m) \ @@ -4474,8 +4502,10 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) kInputSIndices); \ } -#define DEFINE_TEST_NEON_BYELEMENT_DIFF_SCALAR( \ - mnemonic, input_d, input_n, input_m) \ +#define DEFINE_TEST_NEON_BYELEMENT_DIFF_SCALAR(mnemonic, \ + input_d, \ + input_n, \ + input_m) \ TEST(mnemonic##_S_H_H) { \ CALL_TEST_NEON_HELPER_BYELEMENT(mnemonic, \ S, \ @@ -4498,21 +4528,28 @@ DEFINE_TEST_FP_TO_JS_INT(fjcvtzs, FPToS, Conversions) } -#define CALL_TEST_NEON_HELPER_2OP2IMM( \ - mnemonic, variant, input_d, input_imm1, input_n, input_imm2) \ - { \ - CALL_TEST_NEON_HELPER_OpImmOpImm(&MacroAssembler::mnemonic, \ - mnemonic, \ - variant, \ - variant, \ - input_d, \ - input_imm1, \ - input_n, \ - input_imm2); \ +#define CALL_TEST_NEON_HELPER_2OP2IMM(mnemonic, \ + variant, \ + input_d, \ + input_imm1, \ + input_n, \ + input_imm2) \ + { \ + CALL_TEST_NEON_HELPER_OpImmOpImm(&MacroAssembler::mnemonic, \ + mnemonic, \ + variant, \ + variant, \ + input_d, \ + input_imm1, \ + input_n, \ + input_imm2); \ } -#define DEFINE_TEST_NEON_2OP2IMM( \ - mnemonic, input_d, input_imm1, input_n, input_imm2) \ +#define DEFINE_TEST_NEON_2OP2IMM(mnemonic, \ + input_d, \ + input_imm1, \ + input_n, \ + input_imm2) \ TEST(mnemonic##_B) { \ CALL_TEST_NEON_HELPER_2OP2IMM(mnemonic, \ 16B, \ diff --git a/test/aarch64/test-simulator-sve-aarch64.cc b/test/aarch64/test-simulator-sve-aarch64.cc index 58d9f48c..51f7d82f 100644 --- a/test/aarch64/test-simulator-sve-aarch64.cc +++ b/test/aarch64/test-simulator-sve-aarch64.cc @@ -26,12 +26,12 @@ #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #include "test-assembler-aarch64.h" #define TEST_SVE(name) TEST_SVE_INNER("SIM", name) diff --git a/test/aarch64/test-simulator-sve2-aarch64.cc b/test/aarch64/test-simulator-sve2-aarch64.cc index 0a4c6d13..a7c0f401 100644 --- a/test/aarch64/test-simulator-sve2-aarch64.cc +++ b/test/aarch64/test-simulator-sve2-aarch64.cc @@ -24,24 +24,23 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include -#include - #include #include #include #include #include #include +#include +#include #include "test-runner.h" #include "test-utils.h" -#include "aarch64/test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "aarch64/test-utils-aarch64.h" #include "test-assembler-aarch64.h" #define TEST_SVE(name) TEST_SVE_INNER("SIM", name) diff --git a/test/aarch64/test-trace-aarch64.cc b/test/aarch64/test-trace-aarch64.cc index 1eb70100..d48f806c 100644 --- a/test/aarch64/test-trace-aarch64.cc +++ b/test/aarch64/test-trace-aarch64.cc @@ -29,17 +29,16 @@ #include #include #include - #include #include #include "test-runner.h" -#include "test-utils-aarch64.h" #include "aarch64/cpu-aarch64.h" #include "aarch64/disasm-aarch64.h" #include "aarch64/macro-assembler-aarch64.h" #include "aarch64/simulator-aarch64.h" +#include "test-utils-aarch64.h" namespace vixl { namespace aarch64 { diff --git a/test/aarch64/test-utils-aarch64.cc b/test/aarch64/test-utils-aarch64.cc index 55eccc73..398ed4fd 100644 --- a/test/aarch64/test-utils-aarch64.cc +++ b/test/aarch64/test-utils-aarch64.cc @@ -24,11 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "test-utils-aarch64.h" + #include #include #include "test-runner.h" -#include "test-utils-aarch64.h" #include "../test/aarch64/test-simulator-inputs-aarch64.h" #include "aarch64/cpu-aarch64.h" diff --git a/test/aarch64/test-utils-aarch64.h b/test/aarch64/test-utils-aarch64.h index fde3ad14..9cf91549 100644 --- a/test/aarch64/test-utils-aarch64.h +++ b/test/aarch64/test-utils-aarch64.h @@ -604,18 +604,20 @@ void ComputeMachineStateHash(MacroAssembler* masm, uint32_t* dst); // vector length. #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64 -#define TEST_SVE_INNER(type, name) \ - void Test##name(Test* config); \ - Test* test_##name##_list[] = \ - {Test::MakeSVETest(128, \ - "AARCH64_" type "_" #name "_vl128", \ - &Test##name), \ - Test::MakeSVETest(384, \ - "AARCH64_" type "_" #name "_vl384", \ - &Test##name), \ - Test::MakeSVETest(2048, \ - "AARCH64_" type "_" #name "_vl2048", \ - &Test##name)}; \ +#define TEST_SVE_INNER(type, name) \ + void Test##name(Test* config); \ + Test* test_##name##_list[] = {Test::MakeSVETest(128, \ + "AARCH64_" type "_" #name \ + "_vl128", \ + &Test##name), \ + Test::MakeSVETest(384, \ + "AARCH64_" type "_" #name \ + "_vl384", \ + &Test##name), \ + Test::MakeSVETest(2048, \ + "AARCH64_" type "_" #name \ + "_vl2048", \ + &Test##name)}; \ void Test##name(Test* config) #define SVE_SETUP_WITH_FEATURES(...) \ diff --git a/test/test-api.cc b/test/test-api.cc index b30230d6..dfb61af9 100644 --- a/test/test-api.cc +++ b/test/test-api.cc @@ -29,9 +29,8 @@ #include #include -#include "test-runner.h" - #include "cpu-features.h" +#include "test-runner.h" #include "utils-vixl.h" #if __cplusplus >= 201103L diff --git a/test/test-pool-manager.cc b/test/test-pool-manager.cc index e49f1caf..eb22ae6f 100644 --- a/test/test-pool-manager.cc +++ b/test/test-pool-manager.cc @@ -297,7 +297,7 @@ void PoolManager::DumpCurrentState(int32_t pc) const { object.max_location_)); } } -} +} // namespace vixl // Basic test - checks that emitting a very simple pool works. TEST(Basic) { @@ -343,14 +343,15 @@ static ForwardReference *CreateReference(int id, int32_t min_offset, int32_t max_offset, int alignment) { - IF_VERBOSE(printf( - "About to add a new reference to object %d with min location = %d, max " - "location = %d, alignment = %d, size = %d\n", - id, - min_offset + pc, - max_offset + pc, - alignment, - size)); + IF_VERBOSE( + printf("About to add a new reference to object %d with min location = " + "%d, max " + "location = %d, alignment = %d, size = %d\n", + id, + min_offset + pc, + max_offset + pc, + alignment, + size)); return new ForwardReference(pc, size, min_offset + pc, diff --git a/test/test-runner.cc b/test/test-runner.cc index 092a4ed8..093c5be0 100644 --- a/test/test-runner.cc +++ b/test/test-runner.cc @@ -24,12 +24,12 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include "test-runner.h" + #include #include #include -#include "test-runner.h" - // Initialize the list as empty. vixl::Test* vixl::Test::first_ = NULL; vixl::Test* vixl::Test::last_ = NULL; diff --git a/test/test-runner.h b/test/test-runner.h index bb72ce67..f0c11adf 100644 --- a/test/test-runner.h +++ b/test/test-runner.h @@ -28,6 +28,7 @@ #define TEST_TEST_H_ #include "utils-vixl.h" + #include "aarch64/instructions-aarch64.h" namespace vixl { diff --git a/tools/clang_format.py b/tools/clang_format.py index 2b9252b5..2a081801 100755 --- a/tools/clang_format.py +++ b/tools/clang_format.py @@ -33,17 +33,17 @@ import subprocess import sys import tempfile +import shutil from threaded_tests import Test, TestQueue import printer import util -CLANG_FORMAT_VERSION_MAJOR = 4 -CLANG_FORMAT_VERSION_MINOR = 0 +CLANG_TOOL_SUPPORTED_VERSIONS = range(11, 16) -DEFAULT_CLANG_FORMAT = \ - 'clang-format-{}.{}'.format(CLANG_FORMAT_VERSION_MAJOR, - CLANG_FORMAT_VERSION_MINOR) +DEFAULT_CLANG_FORMAT = 'clang-format' + +CLANG_TOOL_VERSION_MATCH = r"(clang-format|LLVM) version ([\d]+)\.[\d]+\.[\d]+.*$" is_output_redirected = not sys.stdout.isatty() @@ -69,21 +69,37 @@ def BuildOptions(): as it thinks useful.''') return parser.parse_args() +def is_supported(tool): + if not shutil.which(tool): + return False + + cmd = '%s -version' % tool -def ClangFormatIsAvailable(clang_format): - if not util.IsCommandAvailable(clang_format): + try: + rc, version = util.getstatusoutput(cmd) + except OSError: return False - cmd = '%s -version' % clang_format - rc, version = util.getstatusoutput(cmd) + if rc != 0: util.abort("Failed to execute %s: %s" % (cmd, version)) - m = re.search("^clang-format version (\d)\.(\d)\.\d.*$", - version, re.M) + m = re.search(CLANG_TOOL_VERSION_MATCH, version, re.MULTILINE) if not m: - util.abort("Failed to get clang-format's version: %s" % version) - major, minor = m.groups() - return int(major) == CLANG_FORMAT_VERSION_MAJOR and \ - int(minor) == CLANG_FORMAT_VERSION_MINOR + util.abort("Failed to get clang tool version: %s" % version) + _, major = m.groups() + + if int(major) in CLANG_TOOL_SUPPORTED_VERSIONS: + return True + + return False + +def detect_clang_tool(tool): + supported_tools = [tool] + [tool + '-' + str(ver) for ver in CLANG_TOOL_SUPPORTED_VERSIONS] + for tool in supported_tools: + if is_supported(tool): + return tool + + return None + def RunTest(test): filename = test.args['filename'] @@ -102,6 +118,7 @@ def RunTest(test): cmd_diff = ['diff', '--unified', filename, temp_file_name] cmd_diff_string = '$ ' + ' '.join(cmd_diff) + p_diff = subprocess.Popen(cmd_diff, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) @@ -114,12 +131,11 @@ def RunTest(test): else: out, unused = p_diff.communicate() - rc += p_diff.wait() + rc += p_diff.returncode if in_place: cmd_format = [clang_format, '-i', filename] - p_format = subprocess.Popen(cmd_format, - stdout=temp_file, stderr=subprocess.STDOUT) + subprocess.run(cmd_format, stdout=temp_file, stderr=subprocess.STDOUT) if rc != 0: with Test.n_tests_failed.get_lock(): Test.n_tests_failed.value += 1 @@ -143,7 +159,8 @@ def RunTest(test): printer.Print('Incorrectly formatted file: ' + filename + '\n' + \ cmd_format_string + '\n' + \ cmd_diff_string + '\n' + \ - out, has_lock = True) + out.decode(), has_lock = True) + printer.__print_lock__.release() os.remove(temp_file_name) @@ -151,12 +168,12 @@ def RunTest(test): # Returns the total number of files incorrectly formatted. def ClangFormatFiles(files, clang_format, in_place = False, jobs = 1, progress_prefix = ''): - if not ClangFormatIsAvailable(clang_format): - error_message = "`{}` version {}.{} not found. Please ensure it " \ - "is installed, in your PATH and the correct version." \ - .format(clang_format, - CLANG_FORMAT_VERSION_MAJOR, - CLANG_FORMAT_VERSION_MINOR) + + clang_format = detect_clang_tool("clang-format") + + if not clang_format: + error_message = "clang-format not found. Please ensure it " \ + "is installed, in your PATH and the correct version." print(printer.COLOUR_RED + error_message + printer.NO_COLOUR) return -1 @@ -176,7 +193,7 @@ def ClangFormatFiles(files, clang_format, in_place = False, jobs = 1, if __name__ == '__main__': # Parse the arguments. args = BuildOptions() - files = args.files or util.get_source_files() + files = args.files or util.get_source_files(exclude_dirs=['.*', '*/traces/*', '*/aarch32/*']) rc = ClangFormatFiles(files, clang_format = args.clang_format, in_place = args.in_place, jobs = args.jobs) diff --git a/tools/clang_tidy.py b/tools/clang_tidy.py index 727c829d..4297a2b0 100755 --- a/tools/clang_tidy.py +++ b/tools/clang_tidy.py @@ -30,19 +30,15 @@ import os import re import sys +import subprocess -from clang_format import CLANG_FORMAT_VERSION_MAJOR, CLANG_FORMAT_VERSION_MINOR +from clang_format import detect_clang_tool from threaded_tests import Test, TestQueue import config import printer import util -CLANG_TIDY_VERSION_MAJOR = CLANG_FORMAT_VERSION_MAJOR -CLANG_TIDY_VERSION_MINOR = CLANG_FORMAT_VERSION_MINOR - -DEFAULT_CLANG_TIDY = \ - 'clang-tidy-{}.{}'.format(CLANG_TIDY_VERSION_MAJOR, - CLANG_TIDY_VERSION_MINOR) +DEFAULT_CLANG_TIDY = 'clang-tidy' def BuildOptions(): parser = argparse.ArgumentParser( @@ -60,20 +56,6 @@ def BuildOptions(): help='Path to clang-tidy.') return parser.parse_args() -def ClangTidyIsAvailable(clang_tidy): - if not util.IsCommandAvailable(clang_tidy): - return False - cmd = '%s -version' % clang_tidy - rc, version = util.getstatusoutput(cmd) - if rc != 0: - util.abort("Failed to execute %s: %s" % (cmd, version)) - m = re.search("LLVM version (\d)\.(\d)\.\d.*$", version, re.M) - if not m: - util.abort("Failed to get clang-tidy's version: %s" % version) - major, minor = m.groups() - return int(major) == CLANG_TIDY_VERSION_MAJOR and \ - int(minor) == CLANG_TIDY_VERSION_MINOR - def FilterClangTidyLines(lines): out = [] print_context = False @@ -133,12 +115,12 @@ def RunTest(test): printer.__print_lock__.release() def ClangTidyFiles(files, clang_tidy, jobs = 1, progress_prefix = ''): - if not ClangTidyIsAvailable(clang_tidy): - error_message = "`{}` version {}.{} not found. Please ensure it " \ - "is installed, in your PATH and the correct version." \ - .format(clang_tidy, - CLANG_TIDY_VERSION_MAJOR, - CLANG_TIDY_VERSION_MINOR) + + clang_tidy = detect_clang_tool("clang-tidy") + + if not clang_tidy: + error_message = "clang-tidy not found. Please ensure it " \ + "is installed, in your PATH and the correct version." print(printer.COLOUR_RED + error_message + printer.NO_COLOUR) return -1 diff --git a/tools/test.py b/tools/test.py index 85153c0c..9eb859f7 100755 --- a/tools/test.py +++ b/tools/test.py @@ -262,13 +262,13 @@ def RunLinter(jobs): def RunClangFormat(clang_path, jobs): - return clang_format.ClangFormatFiles(util.get_source_files(), + return clang_format.ClangFormatFiles(util.get_source_files(exclude_dirs=['.*', '*/traces/*', '*/aarch32/*']), clang_path, jobs = jobs, progress_prefix = 'clang-format: ') def RunClangTidy(clang_path, jobs): - return clang_tidy.ClangTidyFiles(util.get_source_files(), + return clang_tidy.ClangTidyFiles(util.get_source_files(exclude_dirs=['.*', '*/traces/*', '*/aarch32/*']), clang_path, jobs = jobs, progress_prefix = 'clang-tidy: ')