Skip to content

Commit

Permalink
Use Clang-Tidy 10 (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkryukov authored Feb 3, 2020
1 parent 9e712df commit 1ccc8f8
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '*,-*braces-around-statements,-llvm-header-guard,-fuchsia-default-arguments-calls,-fuchsia-overloaded-operator,-fuchsia-statically-constructed-objects,-*-magic-numbers,-cppcoreguidelines-macro-usage,-modernize-use-trailing-return-type,-hicpp-signed-bitwise,-modernize-use-nodiscard,-*-non-private-member-variables-in-classes'
Checks: '*,-*braces-around-statements,-llvm-header-guard,-fuchsia-default-arguments-calls,-fuchsia-overloaded-operator,-fuchsia-statically-constructed-objects,-*-magic-numbers,-cppcoreguidelines-macro-usage,-modernize-use-trailing-return-type,-hicpp-signed-bitwise,-modernize-use-nodiscard,-*-non-private-member-variables-in-classes,-bugprone-infinite-loop'
CheckOptions:
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
value: 1
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ matrix:
addons:
apt:
sources:
- sourceline: "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
- sourceline: "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
update: true
packages:
Expand Down Expand Up @@ -89,13 +89,13 @@ after_success:
- |
if [ $CXX == clang++ ] && [ "$TRAVIS_OS_NAME" == "linux" ] && [ $TRAVIS_CPU_ARCH == amd64 ]; then
# Install GCC 8 to have better constexpr in libstdc++
sudo apt-get install clang-tidy-9 g++-8
sudo apt-get install clang-tidy-10 g++-8
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 40
clang-tidy-9 --version
clang-tidy-10 --version
cd $TRAVIS_BUILD_DIR/simulator/debug
cmake .. -DCMAKE_BUILD_TYPE=Release
run-clang-tidy-9.py -header-filter='.*' 2> /dev/null
run-clang-tidy-10.py -header-filter='.*' 2> /dev/null
fi
- |
if [ $CXX == g++ ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
Expand Down
2 changes: 1 addition & 1 deletion simulator/infra/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ template<typename T, Type type>
static void add_option( popl::OptionParser* options, std::string_view alias, std::string_view name, std::string_view desc, const T& default_value, T* value) noexcept try
{
(void)default_value;
if constexpr ( type == Type::SWITCH) // NOLINTNEXTLINE(bugprone-branch-clone) https://bugs.llvm.org/show_bug.cgi?id=44229
if constexpr ( type == Type::SWITCH)
options->add<popl::Switch>( std::string( alias), std::string( name), std::string( desc), value);
else if constexpr ( type == Type::OPTIONAL)
options->add<popl::Value<T>>( std::string( alias), std::string( name), std::string( desc), default_value, value);
Expand Down
1 change: 0 additions & 1 deletion simulator/infra/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ static constexpr T circ_ls( const T& value, size_t shamt)
template<size_t N, typename T>
T sign_extension( T value)
{
// NOLINTNEXTLINE(bugprone-suspicious-semicolon) https://bugs.llvm.org/show_bug.cgi?id=35824
if constexpr (N < bitwidth<T>) {
const T msb = T{ 1} << ( N - 1);
value = ( ( value & bitmask<T>(N)) ^ msb) - msb;
Expand Down
4 changes: 2 additions & 2 deletions simulator/kernel/mars/mars_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void MARSKernel::write_to_file() {
uint64 descriptor = sim->read_cpu_register( a0);
uint64 buffer_ptr = sim->read_cpu_register( a1);
uint64 chars_to_write = sim->read_cpu_register( a2);
auto file = find_out_file_by_descriptor( descriptor);
auto* file = find_out_file_by_descriptor( descriptor);
if (file == nullptr) {
io_failure();
return;
Expand All @@ -213,7 +213,7 @@ void MARSKernel::read_from_file() {
uint64 descriptor = sim->read_cpu_register( a0);
uint64 buffer_ptr = sim->read_cpu_register( a1);
uint64 chars_to_read = sim->read_cpu_register( a2);
auto file = find_in_file_by_descriptor( descriptor);
auto* file = find_in_file_by_descriptor( descriptor);
if (file == nullptr) {
io_failure();
return;
Expand Down
4 changes: 2 additions & 2 deletions simulator/memory/argv_loader/argv_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ size_t ArgvLoader<T, endian>::load_to( const std::shared_ptr<FuncMemory>& mem, A
place_nullptr( mem, addr + offset);
offset += GUEST_WORD_SIZE;

if ( envp)
if ( envp != nullptr)
{
offset += count_argc( envp) * GUEST_WORD_SIZE; // reserved space for envp[]

Expand All @@ -38,7 +38,7 @@ size_t ArgvLoader<T, endian>::load_to( const std::shared_ptr<FuncMemory>& mem, A

load_argv_contents( mem, addr);

if ( envp)
if ( envp != nullptr)
load_envp_contents( mem, addr);

return offset;
Expand Down
2 changes: 1 addition & 1 deletion simulator/memory/cen64/cen64_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CEN64Memory : public FuncMemory

size_t copy_word( std::byte* dst, Addr src, size_t size) const noexcept
{
uint32 val;
uint32 val = 0;
size_t result = bus_read_word( bus, src, &val);
put_value_to_pointer<uint32, Endian::big>( dst, val, size);
return result;
Expand Down
2 changes: 1 addition & 1 deletion simulator/memory/cen64/t/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C"
TEST_CASE( "bus_controller mock" )
{
bus_controller bus;
uint32 data;
uint32 data = 0;

bus_write_word( &bus, 0x153, 0x22334455, all_ones<uint32>());
bus_read_word( &bus, 0x153, &data);
Expand Down
10 changes: 5 additions & 5 deletions simulator/memory/elf/elf_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ Addr ElfLoader::get_startPC() const
for ( ELFIO::Elf_Xword j = 0; j < symbols.get_symbols_num(); ++j ) {
std::string name;
ELFIO::Elf64_Addr value = 0;
ELFIO::Elf_Xword size;
unsigned char bind;
unsigned char type;
ELFIO::Elf_Half section_index;
unsigned char other;
ELFIO::Elf_Xword size = 0;
unsigned char bind = 0;
unsigned char type = 0;
ELFIO::Elf_Half section_index = 0;
unsigned char other = 0;
symbols.get_symbol( j, name, value, size, bind, type, section_index, other );
if ( name == "__start" || name == "_start")
return value;
Expand Down

0 comments on commit 1ccc8f8

Please sign in to comment.