Skip to content

Commit

Permalink
Tweaks config so that short member functions are on a single line
Browse files Browse the repository at this point in the history
  • Loading branch information
ilumsden committed Oct 11, 2024
1 parent 522e8c0 commit 8dfc0f9
Show file tree
Hide file tree
Showing 89 changed files with 340 additions and 1,078 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
Expand Down
10 changes: 2 additions & 8 deletions include/caliper/Annotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,10 @@ class Annotation
Annotation& begin(double data);

/// \copydoc cali::Annotation::begin(int)
Annotation& begin(const char* data)
{
return begin(Variant(data));
}
Annotation& begin(const char* data) { return begin(Variant(data)); }

/// \copydoc cali::Annotation::begin(int)
Annotation& begin(cali_attr_type type, void* data, uint64_t size)
{
return begin(Variant(type, data, size));
}
Annotation& begin(cali_attr_type type, void* data, uint64_t size) { return begin(Variant(type, data, size)); }

/// \copydoc cali::Annotation::begin(int)
Annotation& begin(const Variant& data);
Expand Down
15 changes: 5 additions & 10 deletions include/caliper/AnnotationBinding.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,26 @@ class AnnotationBinding
/// \param c The %Caliper instance
/// \param chn The channel instance
/// \param attr The attribute being marked
virtual void on_mark_attribute(Caliper* c, Channel* chn, const Attribute& attr)
{}
virtual void on_mark_attribute(Caliper* c, Channel* chn, const Attribute& attr) {}

/// \brief Callback for an annotation begin event
/// \param c Caliper instance
/// \param attr Attribute on which the %Caliper begin event was invoked.
/// \param value The annotation name/value.
virtual void on_begin(Caliper* c, Channel* chn, const Attribute& attr, const Variant& value)
{}
virtual void on_begin(Caliper* c, Channel* chn, const Attribute& attr, const Variant& value) {}

/// \brief Callback for an annotation end event
/// \param c Caliper instance
/// \param attr Attribute on which the %Caliper end event was invoked.
/// \param value The annotation name/value.
virtual void on_end(Caliper* c, Channel* chn, const Attribute& attr, const Variant& value)
{}
virtual void on_end(Caliper* c, Channel* chn, const Attribute& attr, const Variant& value) {}

/// \brief Initialization callback. Invoked after the %Caliper
/// initialization completed.
virtual void initialize(Caliper* c, Channel* chn)
{}
virtual void initialize(Caliper* c, Channel* chn) {}

/// \brief Invoked on %Caliper finalization.
virtual void finalize(Caliper* c, Channel* chn)
{}
virtual void finalize(Caliper* c, Channel* chn) {}

public:

Expand Down
41 changes: 9 additions & 32 deletions include/caliper/CaliFunctional.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,11 @@ struct SafeAnnotation {
public:

//ValidatedAnnotation() : inner_annot("ERROR"){}
SafeAnnotation(const char* name, int opt = 0) : inner_annot(name, opt)
{
inner_annot = Annotation(name, opt);
}
SafeAnnotation(const char* name, int opt = 0) : inner_annot(name, opt) { inner_annot = Annotation(name, opt); }

SafeAnnotation(SafeAnnotation& other) : inner_annot(other.getAnnot())
{}
SafeAnnotation(SafeAnnotation& other) : inner_annot(other.getAnnot()) {}

Annotation& getAnnot()
{
return inner_annot;
}
Annotation& getAnnot() { return inner_annot; }

SafeAnnotation& operator=(SafeAnnotation& other)
{
Expand Down Expand Up @@ -114,10 +107,7 @@ struct SafeAnnotation {
return *this;
}

void end()
{
inner_annot.end();
}
void end() { inner_annot.end(); }

template <typename T>
SafeAnnotation& begin(T start)
Expand Down Expand Up @@ -180,10 +170,7 @@ cali::Annotation& dummy_annot()

template <int N, typename... Args>
struct ArgRecorder {
static auto record(const char* name) -> std::tuple<>
{
return std::make_tuple();
}
static auto record(const char* name) -> std::tuple<> { return std::make_tuple(); }
};

template <int N, typename Arg, typename... Args>
Expand Down Expand Up @@ -217,10 +204,7 @@ auto wrap_with_args(const char* name, LB body, Args... args) -> typename std::re
//but through calls to wrap_function below
template <class LB>
struct WrappedFunction {
WrappedFunction(const char* func_name, LB func) : body(func)
{
name = func_name;
}
WrappedFunction(const char* func_name, LB func) : body(func) { name = func_name; }

template <typename... Args>
auto operator()(Args... args) -> typename std::result_of<LB(Args...)>::type
Expand All @@ -236,10 +220,7 @@ struct WrappedFunction {

template <class LB>
struct ArgWrappedFunction {
ArgWrappedFunction(const char* func_name, LB func) : body(func)
{
name = func_name;
}
ArgWrappedFunction(const char* func_name, LB func) : body(func) { name = func_name; }

template <typename... Args>
auto operator()(Args... args) ->
Expand Down Expand Up @@ -297,8 +278,7 @@ struct Recordable {

template <typename... Args>
struct MapRecordingOperator {
static auto record() -> void
{}
static auto record() -> void {}
};

template <typename MaybeRecordable>
Expand Down Expand Up @@ -336,10 +316,7 @@ cali::Annotation recording_phase("recording_phase");

template <class LB>
struct RecordedFunction {
RecordedFunction(const char* func_name, LB func) : body(func)
{
name = func_name;
}
RecordedFunction(const char* func_name, LB func) : body(func) { name = func_name; }

template <typename... Args>
auto operator()(Args... args) ->
Expand Down
19 changes: 5 additions & 14 deletions include/caliper/Caliper.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class Channel

public:

constexpr Channel() : mP { nullptr }
{}
constexpr Channel() : mP { nullptr } {}

Channel(const Channel&) = default;
Channel(Channel&&) = default;
Expand Down Expand Up @@ -182,10 +181,7 @@ class Channel

cali_id_t id() const;

operator bool() const
{
return mP.use_count() > 0;
}
operator bool() const { return mP.use_count() > 0; }

friend class Caliper;
friend bool operator==(const Channel&, const Channel&);
Expand Down Expand Up @@ -229,8 +225,7 @@ class Caliper : public CaliperMetadataAccessInterface

bool m_is_signal; // are we in a signal handler?

Caliper(GlobalData* g, ThreadData* t, bool sig) : sG(g), sT(t), m_is_signal(sig)
{}
Caliper(GlobalData* g, ThreadData* t, bool sig) : sG(g), sT(t), m_is_signal(sig) {}

void release_thread();

Expand Down Expand Up @@ -694,8 +689,7 @@ class Caliper : public CaliperMetadataAccessInterface
/// \see instance()
Caliper();

~Caliper()
{}
~Caliper() {}

Caliper(const Caliper&) = default;

Expand All @@ -707,10 +701,7 @@ class Caliper : public CaliperMetadataAccessInterface
/// must check is_signal() before executing potentially non-signal safe
/// actions to determine if these are allowed in the current %Caliper
/// instance.
bool is_signal() const
{
return m_is_signal;
};
bool is_signal() const { return m_is_signal; };

/// \brief Return \a true if this is a valid %Caliper instance.
operator bool() const;
Expand Down
3 changes: 1 addition & 2 deletions include/caliper/ChannelController.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class ChannelController
///
/// This can be used to setup additional functionality, e.g.
/// registering %Caliper callbacks.
virtual void on_create(Caliper* /*c*/, Channel& /*chn*/)
{}
virtual void on_create(Caliper* /*c*/, Channel& /*chn*/) {}

public:

Expand Down
90 changes: 20 additions & 70 deletions include/caliper/SnapshotRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,26 @@ class SnapshotView

public:

SnapshotView() : m_data { nullptr }, m_len { 0 }
{}
SnapshotView() : m_data { nullptr }, m_len { 0 } {}

SnapshotView(size_t len, const Entry* data) : m_data { data }, m_len { len }
{}
SnapshotView(size_t len, const Entry* data) : m_data { data }, m_len { len } {}

SnapshotView(const Entry& e) : m_data { &e }, m_len { 1 }
{}
SnapshotView(const Entry& e) : m_data { &e }, m_len { 1 } {}

using iterator = Entry*;
using const_iterator = const Entry*;

const_iterator begin() const
{
return m_data;
}
const_iterator begin() const { return m_data; }

const_iterator end() const
{
return m_data + m_len;
}
const_iterator end() const { return m_data + m_len; }

size_t size() const
{
return m_len;
}
size_t size() const { return m_len; }

const Entry* data() const
{
return m_data;
}
const Entry* data() const { return m_data; }

bool empty() const
{
return m_len == 0;
}
bool empty() const { return m_len == 0; }

const Entry& operator[](std::size_t n) const
{
return m_data[n];
}
const Entry& operator[](std::size_t n) const { return m_data[n]; }

Entry get(const Attribute& attr) const
{
Expand Down Expand Up @@ -98,8 +77,7 @@ class SnapshotBuilder

public:

SnapshotBuilder() : m_data { nullptr }, m_capacity { 0 }, m_len { 0 }, m_skipped { 0 }
{}
SnapshotBuilder() : m_data { nullptr }, m_capacity { 0 }, m_len { 0 }, m_skipped { 0 } {}

SnapshotBuilder(size_t capacity, Entry* data)
: m_data { data }, m_capacity { capacity }, m_len { 0 }, m_skipped { 0 }
Expand All @@ -111,20 +89,11 @@ class SnapshotBuilder
SnapshotBuilder& operator=(SnapshotBuilder&&) = default;
SnapshotBuilder& operator=(const SnapshotBuilder&) = delete;

size_t capacity() const
{
return m_capacity;
}
size_t capacity() const { return m_capacity; }

size_t size() const
{
return m_len;
}
size_t size() const { return m_len; }

size_t skipped() const
{
return m_skipped;
}
size_t skipped() const { return m_skipped; }

void append(const Entry& e)
{
Expand All @@ -142,20 +111,11 @@ class SnapshotBuilder
m_skipped += n - num_copied;
}

void append(const Attribute& attr, const Variant& val)
{
append(Entry(attr, val));
}
void append(const Attribute& attr, const Variant& val) { append(Entry(attr, val)); }

void append(SnapshotView view)
{
append(view.size(), view.data());
}
void append(SnapshotView view) { append(view.size(), view.data()); }

SnapshotView view() const
{
return SnapshotView { m_len, m_data };
}
SnapshotView view() const { return SnapshotView { m_len, m_data }; }
};

/// \brief A fixed-size snapshot record
Expand All @@ -167,26 +127,16 @@ class FixedSizeSnapshotRecord

public:

FixedSizeSnapshotRecord() : m_builder { N, m_data }
{}
FixedSizeSnapshotRecord() : m_builder { N, m_data } {}

FixedSizeSnapshotRecord(const FixedSizeSnapshotRecord<N>&) = delete;
FixedSizeSnapshotRecord<N> operator=(const FixedSizeSnapshotRecord<N>&) = delete;

SnapshotBuilder& builder()
{
return m_builder;
}
SnapshotBuilder& builder() { return m_builder; }

SnapshotView view() const
{
return m_builder.view();
}
SnapshotView view() const { return m_builder.view(); }

void reset()
{
m_builder = SnapshotBuilder(N, m_data);
}
void reset() { m_builder = SnapshotBuilder(N, m_data); }
};

} // namespace cali
Loading

0 comments on commit 8dfc0f9

Please sign in to comment.