Skip to content

Commit

Permalink
Apply "readability-convert-member-functions-to-static" clang-tidy che…
Browse files Browse the repository at this point in the history
…cks (#4561)

Test: Compile
  • Loading branch information
florian-kuebler authored Dec 7, 2022
1 parent 2be04ed commit 5f13ad7
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 43 deletions.
13 changes: 7 additions & 6 deletions src/LinuxTracing/TracerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@ class TracerImpl : public Tracer {
void InitUprobesEventVisitor();
bool OpenUserSpaceProbes(absl::Span<const int32_t> cpus);
bool OpenUprobesToRecordAdditionalStackOn(absl::Span<const int32_t> cpus);
bool OpenUprobes(const orbit_grpc_protos::InstrumentedFunction& function,
absl::Span<const int32_t> cpus, absl::flat_hash_map<int32_t, int>* fds_per_cpu);
static bool OpenUprobes(const orbit_grpc_protos::InstrumentedFunction& function,
absl::Span<const int32_t> cpus,
absl::flat_hash_map<int32_t, int>* fds_per_cpu);
bool OpenUprobesWithStack(const orbit_grpc_protos::FunctionToRecordAdditionalStackOn& function,
absl::Span<const int32_t> cpus,
absl::flat_hash_map<int32_t, int>* fds_per_cpu);
bool OpenUretprobes(const orbit_grpc_protos::InstrumentedFunction& function,
absl::Span<const int32_t> cpus,
absl::flat_hash_map<int32_t, int>* fds_per_cpu);
static bool OpenUretprobes(const orbit_grpc_protos::InstrumentedFunction& function,
absl::Span<const int32_t> cpus,
absl::flat_hash_map<int32_t, int>* fds_per_cpu);
bool OpenMmapTask(absl::Span<const int32_t> cpus);
bool OpenSampling(absl::Span<const int32_t> cpus);

Expand Down Expand Up @@ -108,7 +109,7 @@ class TracerImpl : public Tracer {
PerfEventRingBuffer* ring_buffer);
[[nodiscard]] uint64_t ProcessLostEventAndReturnTimestamp(const perf_event_header& header,
PerfEventRingBuffer* ring_buffer);
[[nodiscard]] uint64_t ProcessThrottleUnthrottleEventAndReturnTimestamp(
[[nodiscard]] static uint64_t ProcessThrottleUnthrottleEventAndReturnTimestamp(
const perf_event_header& header, PerfEventRingBuffer* ring_buffer);

void DeferEvent(PerfEvent&& event);
Expand Down
2 changes: 1 addition & 1 deletion src/MizarData/BaselineAndComparisonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class MockFunctionTimeComparator {
const Comparison<SamplingCounts>& /*comparison_counts*/,
const Comparison<orbit_client_data::ScopeStats>& /*comparison_frame_stats*/) {}

[[nodiscard]] orbit_mizar_statistics::ComparisonResult Compare(SampledFunctionId sfid) const {
[[nodiscard]] static orbit_mizar_statistics::ComparisonResult Compare(SampledFunctionId sfid) {
return {kStatistic, kSfidToPvalue.at(sfid)};
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/MizarData/MizarPairedDataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ class MockFrameTrackManager {

explicit MockFrameTrackManager(const MockMizarData* data) { passed_data_ = data; }

[[nodiscard]] std::vector<TimestampNs> GetFrameStarts(FrameTrackId, TimestampNs,
TimestampNs) const {
[[nodiscard]] static std::vector<TimestampNs> GetFrameStarts(FrameTrackId, TimestampNs,
TimestampNs) {
return kStarts;
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/OrbitGl/OrbitApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ bool OrbitApp::IsCaptureConnected(const CaptureData& capture) const {
selected_process->full_path() == capture_process->full_path();
}

bool OrbitApp::IsDevMode() const { return absl::GetFlag(FLAGS_devmode); }
bool OrbitApp::IsDevMode() { return absl::GetFlag(FLAGS_devmode); }

void OrbitApp::SendDisassemblyToUi(const orbit_client_data::FunctionInfo& function_info,
std::string disassembly,
Expand Down
2 changes: 1 addition & 1 deletion src/OrbitGl/PickingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool PickingManager::IsThisElementPicked(const Pickable* pickable) const {
return picked && picked.get() == pickable;
}

Color PickingManager::ColorFromPickingID(PickingId id) const {
Color PickingManager::ColorFromPickingID(PickingId id) {
auto color_values = absl::bit_cast<std::array<uint8_t, 4>>(id.ToPixelValue());
return {color_values[0], color_values[1], color_values[2], color_values[3]};
}
4 changes: 2 additions & 2 deletions src/OrbitGl/TimelineTicks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ std::optional<uint64_t> TimelineTicks::GetPreviousMajorTick(uint64_t start_ns,
return major_ticks[0] - major_tick_scale;
}

uint32_t TimelineTicks::GetTimestampNumDigitsPrecision(uint64_t timestamp_ns) const {
uint32_t TimelineTicks::GetTimestampNumDigitsPrecision(uint64_t timestamp_ns) {
constexpr uint32_t kMaxDigitsPrecision = 9; // 1ns = 0.000'000'001s

uint64_t current_precision_ns = kNanosecondsPerSecond;
Expand All @@ -109,7 +109,7 @@ uint64_t TimelineTicks::GetMinorTicksScale(uint64_t visible_ns) const {
return *std::prev(kTimelineScales.lower_bound(major_scale));
}

uint64_t TimelineTicks::GetMajorTicksScale(uint64_t visible_ns) const {
uint64_t TimelineTicks::GetMajorTicksScale(uint64_t visible_ns) {
// Biggest scale smaller than half the total range, as we want to see at least 2 major ticks.
uint64_t half_visible_ns = visible_ns / 2;
ORBIT_CHECK(half_visible_ns > 0);
Expand Down
4 changes: 2 additions & 2 deletions src/OrbitGl/TimerTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TimerTrack::TimerTrack(CaptureViewElement* parent,
app_{app},
timer_data_{timer_data} {}

std::string TimerTrack::GetExtraInfo(const TimerInfo& timer_info) const {
std::string TimerTrack::GetExtraInfo(const TimerInfo& timer_info) {
std::string info;
static bool show_return_value = absl::GetFlag(FLAGS_show_return_values);
if (show_return_value && timer_info.type() == TimerInfo::kNone) {
Expand Down Expand Up @@ -92,7 +92,7 @@ WorldXInfo ToWorldX(double start_us, double end_us, double inv_time_window, floa

} // namespace

std::string TimerTrack::GetDisplayTime(const TimerInfo& timer) const {
std::string TimerTrack::GetDisplayTime(const TimerInfo& timer) {
return orbit_display_formats::GetDisplayTime(absl::Nanoseconds(timer.end() - timer.start()));
}

Expand Down
4 changes: 2 additions & 2 deletions src/OrbitGl/include/OrbitGl/CaptureViewElementTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CaptureViewElementTester {
// to be set.
// In most cases, you'll want to use `SimulateDrawLoopAndCheckFlags` to combine flag checking
// and an update / render loop.
void CheckDrawFlags(CaptureViewElement* element, bool draw, bool update_primitives);
static void CheckDrawFlags(CaptureViewElement* element, bool draw, bool update_primitives);

// Run layout updates without rendering. This is equal to what would happen during
// CaptureWindow::PreRender. You'll want to use this when you want to verify that a particular
Expand Down Expand Up @@ -68,7 +68,7 @@ class CaptureViewElementTester {
StaticTimeGraphLayout layout_;

private:
void TestWidthPropagationToChildren(CaptureViewElement* element);
static void TestWidthPropagationToChildren(CaptureViewElement* element);

MockBatcher batcher_;
MockTextRenderer text_renderer_;
Expand Down
2 changes: 1 addition & 1 deletion src/OrbitGl/include/OrbitGl/OrbitApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class OrbitApp final : public DataViewFactory,
[[nodiscard]] bool IsCaptureConnected(
const orbit_client_data::CaptureData& capture) const override;

[[nodiscard]] bool IsDevMode() const;
[[nodiscard]] static bool IsDevMode();

// Callbacks
using CaptureStartedCallback = std::function<void(const std::optional<std::filesystem::path>&)>;
Expand Down
2 changes: 1 addition & 1 deletion src/OrbitGl/include/OrbitGl/PickingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class PickingManager {
private:
[[nodiscard]] PickingId GetOrCreatePickableId(const std::shared_ptr<Pickable>& pickable,
BatcherId batcher_id);
[[nodiscard]] Color ColorFromPickingID(PickingId id) const;
[[nodiscard]] static Color ColorFromPickingID(PickingId id);

private:
uint32_t pickable_id_counter_ = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/OrbitGl/include/OrbitGl/PrimitiveAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ class PrimitiveAssembler {
const Color& picking_color,
std::unique_ptr<PickingUserData> user_data = nullptr);

void GetBoxGradientColors(const Color& color, std::array<Color, 4>* colors,
ShadingDirection shading_direction = ShadingDirection::kLeftToRight);
static void GetBoxGradientColors(
const Color& color, std::array<Color, 4>* colors,
ShadingDirection shading_direction = ShadingDirection::kLeftToRight);

Batcher* batcher_;
PickingManager* picking_manager_;
Expand Down
4 changes: 2 additions & 2 deletions src/OrbitGl/include/OrbitGl/TimelineTicks.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class TimelineTicks {
[[nodiscard]] std::optional<uint64_t> GetPreviousMajorTick(uint64_t start_ns,
uint64_t end_ns) const;
// Number of digits needed to show precisely parts of a second in a timestamp.
[[nodiscard]] uint32_t GetTimestampNumDigitsPrecision(uint64_t timestamp_ns) const;
[[nodiscard]] static uint32_t GetTimestampNumDigitsPrecision(uint64_t timestamp_ns);

private:
[[nodiscard]] uint64_t GetMajorTicksScale(uint64_t visible_ns) const;
[[nodiscard]] static uint64_t GetMajorTicksScale(uint64_t visible_ns);
[[nodiscard]] uint64_t GetMinorTicksScale(uint64_t visible_ns) const;
};

Expand Down
4 changes: 2 additions & 2 deletions src/OrbitGl/include/OrbitGl/TimerTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TimerTrack : public Track {
[[nodiscard]] Type GetType() const override { return Type::kTimerTrack; }

[[nodiscard]] uint32_t GetProcessId() const override { return timer_data_->GetProcessId(); }
[[nodiscard]] std::string GetExtraInfo(const orbit_client_protos::TimerInfo& timer) const;
[[nodiscard]] static std::string GetExtraInfo(const orbit_client_protos::TimerInfo& timer);

[[nodiscard]] const orbit_client_protos::TimerInfo* GetLeft(
const orbit_client_protos::TimerInfo& timer_info) const override;
Expand Down Expand Up @@ -139,7 +139,7 @@ class TimerTrack : public Track {
const orbit_client_protos::TimerInfo& /*timer*/) const {
return "";
}
[[nodiscard]] std::string GetDisplayTime(const orbit_client_protos::TimerInfo&) const;
[[nodiscard]] static std::string GetDisplayTime(const orbit_client_protos::TimerInfo&);

void DrawTimesliceText(orbit_gl::TextRenderer& text_renderer,
const orbit_client_protos::TimerInfo& timer, float min_x, Vec2 box_pos,
Expand Down
8 changes: 4 additions & 4 deletions src/OrbitQt/CallTreeViewItemModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ QVariant CallTreeViewItemModel::GetEditRoleData(const QModelIndex& index) const
return {};
}

QVariant CallTreeViewItemModel::GetToolTipRoleData(const QModelIndex& index) const {
QVariant CallTreeViewItemModel::GetToolTipRoleData(const QModelIndex& index) {
ORBIT_CHECK(index.isValid());
auto* item = static_cast<CallTreeNode*>(index.internalPointer());
auto* function_item = dynamic_cast<CallTreeFunction*>(item);
Expand All @@ -193,7 +193,7 @@ QVariant CallTreeViewItemModel::GetToolTipRoleData(const QModelIndex& index) con
return {};
}

QVariant CallTreeViewItemModel::GetForegroundRoleData(const QModelIndex& index) const {
QVariant CallTreeViewItemModel::GetForegroundRoleData(const QModelIndex& index) {
ORBIT_CHECK(index.isValid());
auto* item = static_cast<CallTreeNode*>(index.internalPointer());
auto* unwind_errors_item = dynamic_cast<CallTreeUnwindErrors*>(item);
Expand All @@ -214,7 +214,7 @@ QVariant CallTreeViewItemModel::GetForegroundRoleData(const QModelIndex& index)
return {};
}

QVariant CallTreeViewItemModel::GetModulePathRoleData(const QModelIndex& index) const {
QVariant CallTreeViewItemModel::GetModulePathRoleData(const QModelIndex& index) {
ORBIT_CHECK(index.isValid());
auto* item = static_cast<CallTreeNode*>(index.internalPointer());
auto* function_item = dynamic_cast<CallTreeFunction*>(item);
Expand All @@ -224,7 +224,7 @@ QVariant CallTreeViewItemModel::GetModulePathRoleData(const QModelIndex& index)
return {};
}

QVariant CallTreeViewItemModel::GetModuleBuildIdRoleData(const QModelIndex& index) const {
QVariant CallTreeViewItemModel::GetModuleBuildIdRoleData(const QModelIndex& index) {
ORBIT_CHECK(index.isValid());
auto* item = static_cast<CallTreeNode*>(index.internalPointer());
auto* function_item = dynamic_cast<CallTreeFunction*>(item);
Expand Down
2 changes: 1 addition & 1 deletion src/OrbitQt/TrackTypeItemModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void TrackTypeItemModel::SetTrackManager(orbit_gl::TrackManager* track_manager)
endInsertRows();
}

QString TrackTypeItemModel::GetTrackTypeDisplayName(Track::Type track_type) const {
QString TrackTypeItemModel::GetTrackTypeDisplayName(Track::Type track_type) {
switch (track_type) {
case Track::Type::kSchedulerTrack:
return "Scheduler";
Expand Down
8 changes: 4 additions & 4 deletions src/OrbitQt/include/OrbitQt/CallTreeViewItemModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class CallTreeViewItemModel : public QAbstractItemModel {
private:
[[nodiscard]] QVariant GetDisplayRoleData(const QModelIndex& index) const;
[[nodiscard]] QVariant GetEditRoleData(const QModelIndex& index) const;
[[nodiscard]] QVariant GetToolTipRoleData(const QModelIndex& index) const;
[[nodiscard]] QVariant GetForegroundRoleData(const QModelIndex& index) const;
[[nodiscard]] QVariant GetModulePathRoleData(const QModelIndex& index) const;
[[nodiscard]] QVariant GetModuleBuildIdRoleData(const QModelIndex& index) const;
[[nodiscard]] static QVariant GetToolTipRoleData(const QModelIndex& index);
[[nodiscard]] static QVariant GetForegroundRoleData(const QModelIndex& index);
[[nodiscard]] static QVariant GetModulePathRoleData(const QModelIndex& index);
[[nodiscard]] static QVariant GetModuleBuildIdRoleData(const QModelIndex& index);
[[nodiscard]] QVariant GetCopyableValueRoleData(const QModelIndex& index) const;
[[nodiscard]] static QVariant GetExclusiveCallstackEventsRoleData(const QModelIndex& index);

Expand Down
2 changes: 1 addition & 1 deletion src/OrbitQt/include/OrbitQt/TrackTypeItemModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TrackTypeItemModel : public QAbstractTableModel {
orbit_gl::TrackManager* track_manager_ = nullptr;
std::vector<Track::Type> known_track_types_;

QString GetTrackTypeDisplayName(Track::Type track_type) const;
static QString GetTrackTypeDisplayName(Track::Type track_type);
};

} // namespace orbit_qt
Expand Down
6 changes: 3 additions & 3 deletions src/OrbitQt/include/OrbitQt/orbitmainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class OrbitMainWindow final : public QMainWindow, public orbit_gl::MainWindowInt
void OnNewSelectionBottomUpView(std::unique_ptr<CallTreeView> selection_bottom_up_view);

std::string OnGetSaveFileName(std::string_view extension);
void OnSetClipboard(std::string_view text);
static void OnSetClipboard(std::string_view text);
void OpenCapture(std::string_view filepath);
void OnCaptureCleared();

Expand Down Expand Up @@ -172,8 +172,8 @@ class OrbitMainWindow final : public QMainWindow, public orbit_gl::MainWindowInt
void on_actionHelp_toggled(bool checked);
void on_actionIntrospection_triggered();

void on_actionCheckFalse_triggered();
void on_actionStackOverflow_triggered();
static void on_actionCheckFalse_triggered();
static void on_actionStackOverflow_triggered();
void on_actionServiceCheckFalse_triggered();
void on_actionServiceStackOverflow_triggered();

Expand Down
2 changes: 1 addition & 1 deletion src/OrbitTest/OrbitTestImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class OrbitTestImpl {
void Loop();
void TestFunc(uint32_t depth = 0);
void TestFunc2(uint32_t depth = 0);
void BusyWork(uint64_t microseconds);
static void BusyWork(uint64_t microseconds);
void ManualInstrumentationApiTest();
void OutputOrbitApiState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ConnectToTargetDialog : public QDialog {
[[nodiscard]] ErrorMessageOr<void> DeployOrbitServiceAndSetupProcessManager();

void SetStatusMessage(const QString& message);
void LogAndDisplayError(const ErrorMessage& message);
static void LogAndDisplayError(const ErrorMessage& message);
};

} // namespace orbit_session_setup
Expand Down
2 changes: 1 addition & 1 deletion src/Symbols/SymbolHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ ErrorMessageOr<orbit_grpc_protos::ModuleSymbols> SymbolHelper::LoadFallbackSymbo
}

ErrorMessageOr<fs::path> SymbolHelper::FindDebugInfoFileLocally(
std::string_view filename, uint32_t checksum, absl::Span<const fs::path> directories) const {
std::string_view filename, uint32_t checksum, absl::Span<const fs::path> directories) {
std::set<fs::path> search_paths;
for (const auto& directory : directories) {
search_paths.insert(directory / filename);
Expand Down
4 changes: 2 additions & 2 deletions src/Symbols/include/Symbols/SymbolHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ class SymbolHelper : public SymbolCacheInterface {

[[nodiscard]] static bool IsMatchingDebugInfoFile(const std::filesystem::path& file_path,
uint32_t checksum);
[[nodiscard]] ErrorMessageOr<std::filesystem::path> FindDebugInfoFileLocally(
[[nodiscard]] static ErrorMessageOr<std::filesystem::path> FindDebugInfoFileLocally(
std::string_view filename, uint32_t checksum,
absl::Span<const std::filesystem::path> directories) const;
absl::Span<const std::filesystem::path> directories);

private:
template <typename Verifier>
Expand Down

0 comments on commit 5f13ad7

Please sign in to comment.