Skip to content

Commit

Permalink
Use macro instead of [[maybe_unsued]]
Browse files Browse the repository at this point in the history
Use macro that works both for clang and g++ instead of [[maybe_unused]]
(because g++ produces a warning when [[maybe_unsued]] is present,
and clang -- when isn't)
  • Loading branch information
p-senichenkov committed Nov 27, 2024
1 parent 1463448 commit 3e88939
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/core/algorithms/fd/pyrocommon/model/pli_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ProfilingContext;
#include "cache_eviction_method.h"
#include "caching_method.h"
#include "model/table/column_layout_relation_data.h"
#include "util/maybe_unused.h"

namespace model {

Expand All @@ -29,20 +30,20 @@ class PLICache {
std::unique_ptr<VerticalMap<PositionListIndex>> index_;
// usageCounter - for parallelism

// int saved_intersections_ = 0;
MAYBE_UNUSED int saved_intersections_ = 0;

mutable std::mutex getting_pli_mutex_;

CachingMethod caching_method_;
[[maybe_unused]] CacheEvictionMethod eviction_method_;
[[maybe_unused]] double caching_method_value_;
[[maybe_unused]] long long maximumAvailableMemory_ = 0;
MAYBE_UNUSED CacheEvictionMethod eviction_method_;
MAYBE_UNUSED double caching_method_value_;
// long long maximumAvailableMemory_ = 0;
double maximum_entropy_;
[[maybe_unused]] double mean_entropy_;
[[maybe_unused]] double min_entropy_;
[[maybe_unused]] double median_entropy_;
[[maybe_unused]] double median_gini_;
[[maybe_unused]] double median_inverted_entropy_;
MAYBE_UNUSED double mean_entropy_;
MAYBE_UNUSED double min_entropy_;
MAYBE_UNUSED double median_entropy_;
MAYBE_UNUSED double median_gini_;
MAYBE_UNUSED double median_inverted_entropy_;

std::variant<PositionListIndex*, std::unique_ptr<PositionListIndex>> CachingProcess(
Vertical const& vertical, std::unique_ptr<PositionListIndex> pli,
Expand Down
5 changes: 3 additions & 2 deletions src/core/model/table/vertical_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "fd/pyrocommon/core/vertical_info.h"
#include "fd/pyrocommon/model/agree_set_sample.h"
#include "position_list_index.h"
#include "util/maybe_unused.h"

namespace model {

Expand Down Expand Up @@ -425,7 +426,7 @@ void VerticalMap<Value>::Shrink(double factor, std::function<bool(Entry, Entry)>
key_queue.push(entry);
}
});
[[maybe_unused]] unsigned int num_of_removed = 0;
MAYBE_UNUSED unsigned int num_of_removed = 0;
unsigned int target_size = size_ * factor;
while (!key_queue.empty() && size_ > target_size) {
auto key = key_queue.top().first;
Expand Down Expand Up @@ -467,7 +468,7 @@ void VerticalMap<Value>::Shrink(std::unordered_map<Vertical, unsigned int>& usag
key_queue.push(entry);
}
});
[[maybe_unused]] unsigned int num_of_removed = 0;
MAYBE_UNUSED unsigned int num_of_removed = 0;
while (!key_queue.empty()) {
auto key = key_queue.front().first;
key_queue.pop();
Expand Down
10 changes: 10 additions & 0 deletions src/core/util/maybe_unused.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

// clang produces warning on unused private fields, so they need to be marked as [[maybe_unused]],
// but g++ doesn't recognize [[maybe_unused]] on class fields and produces warning.
// This macro expands to [[maybe_unsued]], when compiler is clang, nop otherwise
#ifdef __clang__
#define MAYBE_UNUSED [[maybe_unused]]
#else
#define MAYBE_UNUSED /* Ignore */
#endif

0 comments on commit 3e88939

Please sign in to comment.