Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing clang tidy #2218

Merged
merged 4 commits into from Jun 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion circle.yml
Expand Up @@ -20,7 +20,8 @@ dependencies:
- docker pull ${IMAGE_NAME}
- mkdir build
override:
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} cmake .. -DCMAKE_BUILD_TYPE=Debug -DHPX_WITH_MALLOC=system -DHPX_WITH_GIT_COMMIT=${CIRCLE_SHA1} -DHPX_WITH_TOOLS=On -DCMAKE_CXX_FLAGS="-fcolor-diagnostics" -DHPX_WITH_TESTS_HEADERS=On
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} cmake .. -DCMAKE_BUILD_TYPE=Debug -DHPX_WITH_MALLOC=system -DHPX_WITH_GIT_COMMIT=${CIRCLE_SHA1} -DHPX_WITH_TOOLS=On -DCMAKE_CXX_FLAGS="-fcolor-diagnostics" -DHPX_WITH_TESTS_HEADERS=On -DCMAKE_EXPORT_COMPILE_COMMANDS=On
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} ../tools/clang-tidy.sh -diff-master
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} make -j2 core
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} make -j2 -k components
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} make -j2 -k examples
Expand Down
2 changes: 1 addition & 1 deletion examples/compute/cuda/data_copy.cu
Expand Up @@ -15,7 +15,7 @@

int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
2 changes: 1 addition & 1 deletion examples/compute/cuda/hello_compute.cu
Expand Up @@ -17,7 +17,7 @@

int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
2 changes: 1 addition & 1 deletion examples/compute/cuda/partitioned_vector.cu
Expand Up @@ -27,7 +27,7 @@ HPX_REGISTER_PARTITIONED_VECTOR(int, target_vector);
///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
6 changes: 3 additions & 3 deletions examples/quickstart/init_globally.cpp
Expand Up @@ -73,7 +73,7 @@ char** __argv = *_NSGetArgv();
struct manage_global_runtime
{
manage_global_runtime()
: running_(false), rts_(0)
: running_(false), rts_(nullptr)
{
#if defined(HPX_WINDOWS)
hpx::detail::init_winsocket();
Expand Down Expand Up @@ -106,7 +106,7 @@ struct manage_global_runtime
// notify hpx_main above to tear down the runtime
{
std::lock_guard<hpx::lcos::local::spinlock> lk(mtx_);
rts_ = 0; // reset pointer
rts_ = nullptr; // reset pointer
}

cond_.notify_one(); // signal exit
Expand Down Expand Up @@ -145,7 +145,7 @@ struct manage_global_runtime
// Now, wait for destructor to be called.
{
std::unique_lock<hpx::lcos::local::spinlock> lk(mtx_);
if (rts_ != 0)
if (rts_ != nullptr)
cond_.wait(lk);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/partitioned_vector_spmd_foreach.cpp
Expand Up @@ -114,7 +114,7 @@ struct partitioned_vector_view
///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map& vm)
{
unsigned int seed = (unsigned int)std::time(0);
unsigned int seed = (unsigned int)std::time(nullptr);
if (vm.count("seed"))
seed = vm["seed"].as<unsigned int>();

Expand Down
4 changes: 2 additions & 2 deletions examples/quickstart/shared_mutex.cpp
Expand Up @@ -38,7 +38,7 @@ int main()
[&ready, &stm, i]
{
boost::random::mt19937 urng(
static_cast<boost::uint32_t>(std::time(0)));
static_cast<boost::uint32_t>(std::time(nullptr)));
boost::random::uniform_int_distribution<int> dist(1, 1000);

while (!ready) { /*** wait... ***/ }
Expand All @@ -65,7 +65,7 @@ int main()
[&ready, &stm, k, i]
{
boost::random::mt19937 urng(
static_cast<boost::uint32_t>(std::time(0)));
static_cast<boost::uint32_t>(std::time(nullptr)));
boost::random::uniform_int_distribution<int> dist(1, 1000);

while (!ready) { /*** wait... ***/ }
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/zerocopy_rdma.cpp
Expand Up @@ -31,7 +31,7 @@ class pointer_allocator
typedef std::ptrdiff_t difference_type;

pointer_allocator() HPX_NOEXCEPT
: pointer_(0), size_(0)
: pointer_(nullptr), size_(0)
{
}

Expand Down
2 changes: 1 addition & 1 deletion examples/sheneos/sheneos_compare.cpp
Expand Up @@ -358,7 +358,7 @@ int hpx_main(boost::program_options::variables_map& vm)

std::size_t seed = vm["seed"].as<std::size_t>();
if (!seed)
seed = std::size_t(std::time(0));
seed = std::size_t(std::time(nullptr));

std::cout << "Seed: " << seed << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion examples/sheneos/sheneos_test.cpp
Expand Up @@ -324,7 +324,7 @@ int hpx_main(boost::program_options::variables_map& vm)

std::size_t seed = vm["seed"].as<std::size_t>();
if (!seed)
seed = std::size_t(std::time(0));
seed = std::size_t(std::time(nullptr));

std::cout << "Seed: " << seed << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion examples/startup_shutdown/server/startup_shutdown.hpp
Expand Up @@ -16,7 +16,7 @@ namespace startup_shutdown { namespace server
public:
// constructor: initialize accumulator value
startup_shutdown_component()
: arg_(0)
: arg_(nullptr)
{}

///////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions examples/transpose/transpose_block.cpp
Expand Up @@ -33,7 +33,7 @@ struct sub_block

sub_block()
: size_(0)
, data_(0)
, data_(nullptr)
, mode_(reference)
{}

Expand All @@ -56,15 +56,15 @@ struct sub_block
, data_(other.data_)
, mode_(other.mode_)
{
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }
}

sub_block & operator=(sub_block && other)
{
size_ = other.size_;
data_ = other.data_;
mode_ = other.mode_;
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }

return *this;
}
Expand Down
6 changes: 3 additions & 3 deletions examples/transpose/transpose_block_numa.cpp
Expand Up @@ -45,7 +45,7 @@ struct sub_block

sub_block()
: size_(0)
, data_(0)
, data_(nullptr)
, mode_(reference)
{}

Expand All @@ -68,15 +68,15 @@ struct sub_block
, data_(other.data_)
, mode_(other.mode_)
{
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }
}

sub_block & operator=(sub_block && other)
{
size_ = other.size_;
data_ = other.data_;
mode_ = other.mode_;
if(mode_ == owning) { other.data_ = 0; other.size_ = 0; }
if(mode_ == owning) { other.data_ = nullptr; other.size_ = 0; }

return *this;
}
Expand Down
Expand Up @@ -97,7 +97,7 @@ namespace hpx { namespace components { namespace server

{
std::vector<char> data = f.get();
serialization::input_archive archive(data, data.size(), 0);
serialization::input_archive archive(data, data.size(), nullptr);
archive >> ptr;
}

Expand Down
Expand Up @@ -517,7 +517,7 @@ namespace hpx

bool is_at_end() const
{
return data_ == 0 ||
return data_ == nullptr ||
this->base_type::base_reference() == data_->partitions_.end();
}

Expand Down Expand Up @@ -550,7 +550,7 @@ namespace hpx

bool is_at_end() const
{
return data_ == 0 ||
return data_ == nullptr ||
this->base_type::base_reference() == data_->partitions_.end();
}

Expand Down
2 changes: 1 addition & 1 deletion hpx/components/process/util/posix/executor.hpp
Expand Up @@ -25,7 +25,7 @@ namespace hpx { namespace components { namespace process { namespace posix {

struct executor
{
executor() : exe(0), cmd_line(0), env(0) {}
executor() : exe(nullptr), cmd_line(nullptr), env(nullptr) {}

struct call_on_fork_setup
{
Expand Down
6 changes: 3 additions & 3 deletions hpx/components/process/util/posix/initializers/run_exe.hpp
Expand Up @@ -30,14 +30,14 @@ class run_exe_ : public initializer_base
public:
run_exe_()
{
cmd_line_[0] = cmd_line_[1] = 0;
cmd_line_[0] = cmd_line_[1] = nullptr;
}

explicit run_exe_(const std::string &s)
: s_(s)
{
cmd_line_[0] = const_cast<char*>(s_.c_str());
cmd_line_[1] = 0;
cmd_line_[1] = nullptr;
}

template <class PosixExecutor>
Expand All @@ -63,7 +63,7 @@ class run_exe_ : public initializer_base
ar & s_;

cmd_line_[0] = const_cast<char*>(s_.c_str());
cmd_line_[1] = 0;
cmd_line_[1] = nullptr;
}

HPX_SERIALIZATION_SPLIT_MEMBER()
Expand Down
6 changes: 3 additions & 3 deletions hpx/components/process/util/posix/initializers/set_args.hpp
Expand Up @@ -30,7 +30,7 @@ class set_args_ : public initializer_base
set_args_()
{
args_.resize(1);
args_[0] = 0;
args_[0] = nullptr;
}

explicit set_args_(const Range &args)
Expand All @@ -42,7 +42,7 @@ class set_args_ : public initializer_base
string_args_[i] = args[i];
args_[i] = const_cast<char*>(string_args_[i].c_str());
}
args_[args.size()] = 0;
args_[args.size()] = nullptr;
}

template <class PosixExecutor>
Expand Down Expand Up @@ -72,7 +72,7 @@ class set_args_ : public initializer_base
{
args_[i] = const_cast<char*>(string_args_[i].c_str());
}
args_[string_args_.size()] = 0;
args_[string_args_.size()] = nullptr;
}

HPX_SERIALIZATION_SPLIT_MEMBER()
Expand Down
Expand Up @@ -57,7 +57,7 @@ class set_cmd_line : public initializer_base
std::size_t i = 0;
for (std::string const& s : args_)
cmd_line_[i++] = const_cast<char*>(s.c_str());
cmd_line_[i] = 0;
cmd_line_[i] = nullptr;
}

friend class hpx::serialization::access;
Expand Down
6 changes: 3 additions & 3 deletions hpx/components/process/util/posix/initializers/set_env.hpp
Expand Up @@ -30,7 +30,7 @@ class set_env_ : public initializer_base
set_env_()
{
env_.resize(1);
env_[0] = 0;
env_[0] = nullptr;
}

explicit set_env_(const Range &envs)
Expand All @@ -42,7 +42,7 @@ class set_env_ : public initializer_base
string_env_[i] = envs[i];
env_[i] = const_cast<char*>(string_env_[i].c_str());
}
env_[envs.size()] = 0;
env_[envs.size()] = nullptr;
}

template <class PosixExecutor>
Expand Down Expand Up @@ -70,7 +70,7 @@ class set_env_ : public initializer_base
{
env_[i] = const_cast<char*>(string_env_[i].c_str());
}
env_[string_env_.size()] = 0;
env_[string_env_.size()] = nullptr;
}

HPX_SERIALIZATION_SPLIT_MEMBER()
Expand Down
10 changes: 5 additions & 5 deletions hpx/hpx_init_impl.hpp
Expand Up @@ -215,7 +215,7 @@ namespace hpx
options_description desc_commandline(
std::string("Usage: ") + HPX_APPLICATION_STRING + " [options]");

char *dummy_argv[2] = { const_cast<char*>(HPX_APPLICATION_STRING), 0 };
char *dummy_argv[2] = { const_cast<char*>(HPX_APPLICATION_STRING), nullptr };

return init(static_cast<hpx_main_type>(::hpx_main), desc_commandline,
1, dummy_argv, cfg, startup_function_type(),
Expand All @@ -236,9 +236,9 @@ namespace hpx
options_description desc_commandline(
"Usage: " + app_name + " [options]");

if (argc == 0 || argv == 0)
if (argc == 0 || argv == nullptr)
{
char *dummy_argv[2] = { const_cast<char*>(app_name.c_str()), 0 };
char *dummy_argv[2] = { const_cast<char*>(app_name.c_str()), nullptr };
return init(desc_commandline, 1, dummy_argv, mode);
}

Expand Down Expand Up @@ -282,7 +282,7 @@ namespace hpx
std::vector<std::string> cfg;
util::function_nonser<void()> const empty;

HPX_ASSERT(argc != 0 && argv != 0);
HPX_ASSERT(argc != 0 && argv != nullptr);

return init(main_f, desc_commandline, argc, argv, cfg,
empty, empty, mode);
Expand Down Expand Up @@ -311,7 +311,7 @@ namespace hpx
util::function_nonser<int(boost::program_options::variables_map& vm)>
main_f = util::bind(detail::init_helper, util::placeholders::_1, f);

HPX_ASSERT(argc != 0 && argv != 0);
HPX_ASSERT(argc != 0 && argv != nullptr);

return init(main_f, desc_commandline, argc, argv, cfg,
startup_function_type(), shutdown_function_type(), mode);
Expand Down
10 changes: 5 additions & 5 deletions hpx/hpx_start_impl.hpp
Expand Up @@ -215,7 +215,7 @@ namespace hpx
options_description desc_commandline(
std::string("Usage: ") + HPX_APPLICATION_STRING + " [options]");

char *dummy_argv[2] = { const_cast<char*>(HPX_APPLICATION_STRING), 0 };
char *dummy_argv[2] = { const_cast<char*>(HPX_APPLICATION_STRING), nullptr };

return start(static_cast<hpx_main_type>(::hpx_main), desc_commandline,
1, dummy_argv, cfg, startup_function_type(),
Expand All @@ -238,9 +238,9 @@ namespace hpx
options_description desc_commandline(
"Usage: " + app_name + " [options]");

if (argc == 0 || argv == 0)
if (argc == 0 || argv == nullptr)
{
char *dummy_argv[2] = { const_cast<char*>(app_name.c_str()), 0 };
char *dummy_argv[2] = { const_cast<char*>(app_name.c_str()), nullptr };
return start(desc_commandline, 1, dummy_argv, mode);
}

Expand Down Expand Up @@ -279,7 +279,7 @@ namespace hpx
main_f = util::bind(detail::init_helper, util::placeholders::_1, f);
std::vector<std::string> cfg;

HPX_ASSERT(argc != 0 && argv != 0);
HPX_ASSERT(argc != 0 && argv != nullptr);

return start(main_f, desc_commandline, argc, argv, cfg,
startup_function_type(), shutdown_function_type(), mode);
Expand All @@ -306,7 +306,7 @@ namespace hpx
util::function_nonser<int(boost::program_options::variables_map& vm)>
main_f = util::bind(detail::init_helper, util::placeholders::_1, f);

HPX_ASSERT(argc != 0 && argv != 0);
HPX_ASSERT(argc != 0 && argv != nullptr);

return start(main_f, desc_commandline, argc, argv, cfg,
startup_function_type(), shutdown_function_type(), mode);
Expand Down