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

Tidy headers #1534

Merged
merged 14 commits into from
Dec 4, 2024
6 changes: 5 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Checks: |
-performance-avoid-endl
-performance-unnecessary-value-param
-performance-enum-size
-performance-noexcept-destructor
cppcoreguidelines-*
-cppcoreguidelines-owning-memory
-cppcoreguidelines-narrowing-conversions
Expand All @@ -25,6 +26,7 @@ Checks: |
-cppcoreguidelines-noexcept-swap
-cppcoreguidelines-noexcept-move-operations
-cppcoreguidelines-noexcept-destructor
-cppcoreguidelines-virtual-class-destructor
bugprone-*
-bugprone-sizeof-expression
-bugprone-narrowing-conversions
Expand All @@ -37,9 +39,11 @@ CheckOptions:
cppcoreguidelines-avoid-do-while.IgnoreMacros: true
cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreNonDeducedTemplateTypes: true
cppcoreguidelines-rvalue-reference-param-not-moved.AllowPartialMove: true
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: true
cppcoreguidelines-avoid-non-const-global-variables.AllowInternalLinkage: true
performance-move-const-arg.CheckTriviallyCopyableMove: false
performance-move-const-arg.CheckMoveToConstRef: false
HeaderFilterRegex: ''

HeaderFilterRegex: '(example|app|src/(accel|celeritas|corecel|orange|geocel))/.*\.hh$'
FormatStyle: file
...
2 changes: 1 addition & 1 deletion app/celer-g4/ActionInitialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace app
* The parameters will be distributed to worker threads and all the actions.
*/
ActionInitialization::ActionInitialization(SPParams params)
: params_{std::move(params)}, init_shared_{true}
: params_{std::move(params)}
{
CELER_EXPECT(params_);

Expand Down
2 changes: 1 addition & 1 deletion app/celer-g4/ActionInitialization.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ActionInitialization final : public G4VUserActionInitialization
SPParams params_;
SPDiagnostics diagnostics_;
int num_events_{0};
mutable bool init_shared_;
mutable bool init_shared_{true};
};

//---------------------------------------------------------------------------//
Expand Down
7 changes: 0 additions & 7 deletions app/celer-g4/RootIO.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ class RootIO
private:
// Construct by initializing TFile and TTree on each worker thread
RootIO();
RootIO(RootIO&&) = default;

// Assignment operator
RootIO& operator=(RootIO&&) = default;

// Default destructor
~RootIO() = default;

//// HELPER FUNCTIONS ////

Expand Down
2 changes: 1 addition & 1 deletion app/celer-g4/SensitiveDetector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace app
* Construct with sensitive detector name.
*/
SensitiveDetector::SensitiveDetector(std::string name)
: G4VSensitiveDetector(name), hcid_{-1}, collection_{nullptr}
: G4VSensitiveDetector(name)
{
this->collectionName.insert(name);
}
Expand Down
4 changes: 2 additions & 2 deletions app/celer-g4/SensitiveDetector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class SensitiveDetector final : public G4VSensitiveDetector
bool ProcessHits(G4Step*, G4TouchableHistory*) final;

private:
int hcid_;
SensitiveHitsCollection* collection_;
int hcid_{-1};
SensitiveHitsCollection* collection_{nullptr};
};

//---------------------------------------------------------------------------//
Expand Down
1 change: 1 addition & 0 deletions src/accel/HepMC3PrimaryGenerator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class HepMC3PrimaryGenerator final : public G4VPrimaryGenerator
explicit HepMC3PrimaryGenerator(std::string const& filename);

CELER_DELETE_COPY_MOVE(HepMC3PrimaryGenerator);
~HepMC3PrimaryGenerator() override = default;
sethrj marked this conversation as resolved.
Show resolved Hide resolved

//! Add primaries to Geant4 event
void GeneratePrimaryVertex(G4Event* g4_event) final;
Expand Down
3 changes: 2 additions & 1 deletion src/accel/RZMapMagneticField.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class RZMapMagneticField : public G4MagneticField
inline explicit RZMapMagneticField(SPConstFieldParams field_params);

// Calculate values of the magnetic field vector
inline void GetFieldValue(double const point[3], double* field) const;
inline void
GetFieldValue(double const point[3], double* field) const override;

private:
SPConstFieldParams params_;
Expand Down
2 changes: 1 addition & 1 deletion src/accel/SetupOptionsMessenger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SetupOptionsMessenger : public G4UImessenger
explicit SetupOptionsMessenger(SetupOptions* options);

// Default destructor
~SetupOptionsMessenger();
~SetupOptionsMessenger() override;

protected:
void SetNewValue(G4UIcommand* command, G4String newValue) override;
Expand Down
2 changes: 2 additions & 0 deletions src/accel/detail/HitProcessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <vector>
#include <G4TouchableHandle.hh>

#include "corecel/Macros.hh"
#include "celeritas/Types.hh"
#include "celeritas/geo/GeoFwd.hh"
#include "celeritas/user/DetectorSteps.hh"
Expand Down Expand Up @@ -81,6 +82,7 @@ class HitProcessor

// Log on destruction
~HitProcessor();
CELER_DEFAULT_MOVE_DELETE_COPY(HitProcessor);

// Process CPU-generated hits
void operator()(StepStateHostRef const&);
Expand Down
2 changes: 1 addition & 1 deletion src/accel/detail/LevelTouchableUpdater.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LevelTouchableUpdater final : public TouchableUpdaterInterface
explicit LevelTouchableUpdater(SPConstGeo);

// Destroy pointers
~LevelTouchableUpdater();
~LevelTouchableUpdater() final;

// Update from a particular detector step
bool operator()(DetectorStepOutput const& out,
Expand Down
2 changes: 1 addition & 1 deletion src/accel/detail/NaviTouchableUpdater.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NaviTouchableUpdater final : public TouchableUpdaterInterface
G4VPhysicalVolume const* world);

// Default external deleter
~NaviTouchableUpdater();
~NaviTouchableUpdater() final;

// Update from a particular detector step
bool operator()(DetectorStepOutput const& out,
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/Types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using IsotopeId = OpaqueId<struct IsotopeRecord>;
using MaterialId = OpaqueId<class Material_>;

//! Opaque index of model in the list of physics processes
using ModelId = OpaqueId<class Model>;
using ModelId = OpaqueId<class Model_>;
sethrj marked this conversation as resolved.
Show resolved Hide resolved

//! Opaque index to a material with optical properties
using OpticalMaterialId = OpaqueId<struct OpticalMaterial_>;
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/alongstep/AlongStepGeneralLinearAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AlongStepGeneralLinearAction final : public CoreStepActionInterface
SPConstMsc msc);

// Default destructor
~AlongStepGeneralLinearAction();
~AlongStepGeneralLinearAction() final;

// Launch kernel with host data
void step(CoreParams const&, CoreStateHost&) const final;
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/alongstep/AlongStepUniformMscAction.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AlongStepUniformMscAction final : public CoreStepActionInterface
SPConstMsc msc);

// Default destructor
~AlongStepUniformMscAction();
~AlongStepUniformMscAction() final;

// Launch kernel with host data
void step(CoreParams const&, CoreStateHost&) const final;
Expand Down
1 change: 1 addition & 0 deletions src/celeritas/em/data/AtomicRelaxationData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct AtomicRelaxStateData

//! Assign from another set of states
template<Ownership W2, MemSpace M2>
// NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature)
sethrj marked this conversation as resolved.
Show resolved Hide resolved
AtomicRelaxStateData& operator=(AtomicRelaxStateData<W2, M2>& other)
{
scratch = other.scratch;
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/xs/RBDiffXsCalculator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ RBDiffXsCalculator::RBDiffXsCalculator(RelativisticBremRef const& shared,
, material_(material)
, element_(material.make_element_view(elcomp_id))
, total_energy_(value_as<Energy>(particle.total_energy()))
, dielectric_suppression_(shared.dielectric_suppression())
{
real_type density_factor = material.electron_density()
* detail::migdal_constant();
Expand All @@ -133,7 +134,6 @@ RBDiffXsCalculator::RBDiffXsCalculator(RelativisticBremRef const& shared,
* value_as<detail::MevPerLen>(detail::lpm_constant());
real_type lpm_threshold = lpm_energy * std::sqrt(density_factor);
enable_lpm_ = (shared.enable_lpm && (total_energy_ > lpm_threshold));
dielectric_suppression_ = shared.dielectric_suppression();
}

//---------------------------------------------------------------------------//
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/ext/GeantImporter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class GeantImporter final : public ImporterInterface
ImportData operator()(DataSelection const& selection);

//! Fill all available data from Geant4
ImportData operator()() { return (*this)(DataSelection{}); }
ImportData operator()() final { return (*this)(DataSelection{}); }

private:
// Optional setup if celeritas handles initialization
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/ext/RootImporter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class RootImporter final : public ImporterInterface
}

// Load data from the ROOT files
ImportData operator()();
ImportData operator()() final;

private:
// ROOT file
Expand Down
1 change: 1 addition & 0 deletions src/celeritas/ext/detail/AllElementReader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AllElementReader

//! Load a map of data for all stored elements
template<class ReadOneElement>
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
sethrj marked this conversation as resolved.
Show resolved Hide resolved
auto operator()(ReadOneElement&& read_el) const -> decltype(auto)
{
using result_type = typename ReadOneElement::result_type;
Expand Down
4 changes: 1 addition & 3 deletions src/celeritas/ext/detail/GeantBremsstrahlungProcess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ namespace detail
* Construct with model selection.
*/
GeantBremsstrahlungProcess::GeantBremsstrahlungProcess(ModelSelection selection)
: G4VEnergyLossProcess("eBrem")
, is_initialized_(false)
, model_selection_(selection)
: G4VEnergyLossProcess("eBrem"), model_selection_(selection)
{
CELER_VALIDATE(selection != ModelSelection::none,
<< "Cannot initialize GeantBremsstrahlungProcess with "
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/ext/detail/GeantBremsstrahlungProcess.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GeantBremsstrahlungProcess : public G4VEnergyLossProcess
void StreamProcessInfo(std::ostream& output) const override;

private:
bool is_initialized_;
bool is_initialized_{false};
ModelSelection model_selection_;
};

Expand Down
5 changes: 5 additions & 0 deletions src/celeritas/field/MakeMagFieldPropagator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace celeritas
*/
template<template<class EquationT> class StepperT, class FieldT>
CELER_FUNCTION decltype(auto)
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
sethrj marked this conversation as resolved.
Show resolved Hide resolved
make_mag_field_stepper(FieldT&& field, units::ElementaryCharge charge)
{
using Equation_t = MagFieldEquation<FieldT>;
Expand All @@ -58,10 +59,12 @@ make_mag_field_stepper(FieldT&& field, units::ElementaryCharge charge)
*/
template<class StepperT, class GTV>
CELER_FUNCTION decltype(auto)
// NOLINTBEGIN(cppcoreguidelines-missing-std-forward)
make_field_propagator(StepperT&& stepper,
FieldDriverOptions const& options,
ParticleTrackView const& particle,
GTV&& geometry)
// NOLINTEND(cppcoreguidelines-missing-std-forward)
{
return FieldPropagator{
FieldDriver{options, ::celeritas::forward<StepperT>(stepper)},
Expand All @@ -84,12 +87,14 @@ make_field_propagator(StepperT&& stepper,
* propagate(0.123);
* \endcode
*/
// NOLINTBEGIN(cppcoreguidelines-missing-std-forward)
template<template<class EquationT> class StepperT, class FieldT, class GTV>
CELER_FUNCTION decltype(auto)
make_mag_field_propagator(FieldT&& field,
FieldDriverOptions const& options,
ParticleTrackView const& particle,
GTV&& geometry)
// NOLINTEND(cppcoreguidelines-missing-std-forward)
{
return make_field_propagator(
make_mag_field_stepper<StepperT>(::celeritas::forward<FieldT>(field),
Expand Down
9 changes: 5 additions & 4 deletions src/celeritas/global/ActionLauncher.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ namespace celeritas
* \endcode
*/
template<class F>
void launch_core(std::string_view label,
celeritas::CoreParams const& params,
celeritas::CoreState<MemSpace::host>& state,
F&& execute_thread)
void launch_core(
std::string_view label,
celeritas::CoreParams const& params,
celeritas::CoreState<MemSpace::host>& state,
F&& execute_thread) // NOLINT(cppcoreguidelines-missing-std-forward)
{
MultiExceptionHandler capture_exception;
size_type const size = state.size();
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/global/CoreState.hh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CoreState final : public CoreStateInterface
size_type num_track_slots);

// Default destructor
~CoreState();
~CoreState() final;

// Prevent move/copy
CELER_DELETE_COPY_MOVE(CoreState);
Expand Down
1 change: 1 addition & 0 deletions src/celeritas/global/CoreTrackData.hh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ struct CoreStateData

//! Assign from another set of data
template<Ownership W2, MemSpace M2>
// NOLINTNEXTLINE(cppcoreguidelines-c-copy-assignment-signature)
CoreStateData& operator=(CoreStateData<W2, M2>& other)
{
CELER_EXPECT(other);
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/global/Stepper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Stepper final : public StepperInterface
explicit Stepper(Input input);

// Default destructor
~Stepper();
~Stepper() final;

// Warm up before stepping
void warm_up() final;
Expand Down
28 changes: 14 additions & 14 deletions src/celeritas/global/TrackExecutor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ CELER_FUNCTION ConditionalTrackExecutor(CoreParamsPtr<MemSpace::native>,
* Return a track executor that only applies to active, non-errored tracks.
*/
template<class T>
inline CELER_FUNCTION decltype(auto)
make_active_track_executor(CoreParamsPtr<MemSpace::native> params,
CoreStatePtr<MemSpace::native> const& state,
T&& apply_track)
inline CELER_FUNCTION decltype(auto) make_active_track_executor(
CoreParamsPtr<MemSpace::native> params,
CoreStatePtr<MemSpace::native> const& state,
T&& apply_track) // NOLINT(cppcoreguidelines-missing-std-forward)
{
return ConditionalTrackExecutor{
params, state, AppliesValid{}, celeritas::forward<T>(apply_track)};
Expand All @@ -177,11 +177,11 @@ make_active_track_executor(CoreParamsPtr<MemSpace::native> params,
* threads, active or not.
*/
template<class T>
inline CELER_FUNCTION decltype(auto)
make_action_track_executor(CoreParamsPtr<MemSpace::native> params,
CoreStatePtr<MemSpace::native> state,
ActionId action,
T&& apply_track)
inline CELER_FUNCTION decltype(auto) make_action_track_executor(
CoreParamsPtr<MemSpace::native> params,
CoreStatePtr<MemSpace::native> state,
ActionId action,
T&& apply_track) // NOLINT(cppcoreguidelines-missing-std-forward)
{
CELER_EXPECT(action);
return ConditionalTrackExecutor{params,
Expand All @@ -195,11 +195,11 @@ make_action_track_executor(CoreParamsPtr<MemSpace::native> params,
* Return a track executor that only applies for the given along-step action.
*/
template<class T>
inline CELER_FUNCTION decltype(auto)
make_along_step_track_executor(CoreParamsPtr<MemSpace::native> params,
CoreStatePtr<MemSpace::native> state,
ActionId action,
T&& apply_track)
inline CELER_FUNCTION decltype(auto) make_along_step_track_executor(
CoreParamsPtr<MemSpace::native> params,
CoreStatePtr<MemSpace::native> state,
ActionId action,
T&& apply_track) // NOLINT(cppcoreguidelines-missing-std-forward)
{
CELER_EXPECT(action);
return ConditionalTrackExecutor{params,
Expand Down
10 changes: 3 additions & 7 deletions src/celeritas/grid/GridIdFinder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,10 @@ GridIdFinder<K, V>::operator()(argument_type quant) const -> result_type
{
auto iter
= celeritas::lower_bound(grid_.begin(), grid_.end(), quant.value());
if (iter == grid_.end())
if (iter == grid_.end() // Higher than end point
// Below first point
|| (iter == grid_.begin() && quant.value() != *iter))
{
// Higher than end point
return {};
}
else if (iter == grid_.begin() && quant.value() != *iter)
{
// Below first point
return {};
esseivaju marked this conversation as resolved.
Show resolved Hide resolved
}
else if (iter + 1 == grid_.end() || quant.value() != *iter)
Expand Down
2 changes: 2 additions & 0 deletions src/celeritas/io/EventReader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class EventReader : public EventReaderInterface
//! Prevent copying and moving
CELER_DELETE_COPY_MOVE(EventReader);

~EventReader() override = default;

// Read a single event from the event record
result_type operator()() final;

Expand Down
Loading
Loading