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

changes to support newer clang-tidy errors #1898

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ jobs:
git
base-devel
pacboy: >-
cc:p
cmake:p
gcc:p
llvm:p
ninja:p

- name: configure cmake
Expand Down
74 changes: 64 additions & 10 deletions include/benchmark/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
// This _MSC_VER check should detect VS 2017 v15.3 and newer.
#if __cplusplus >= 201703L || \
(defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L)
// CXX17 implies CXX11
#define BENCHMARK_HAS_CXX11
#define BENCHMARK_HAS_CXX17
#endif

Expand Down Expand Up @@ -403,7 +405,16 @@ RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter,

// TimeUnit is passed to a benchmark in order to specify the order of magnitude
// for the measured time.
enum TimeUnit { kNanosecond, kMicrosecond, kMillisecond, kSecond };
enum TimeUnit
#if defined(BENCHMARK_HAS_CXX11)
: uint8_t
#endif
{
kNanosecond,
kMicrosecond,
kMillisecond,
kSecond
};

BENCHMARK_EXPORT TimeUnit GetDefaultTimeUnit();

Expand Down Expand Up @@ -698,7 +709,11 @@ class Counter {
kInvert = 1 << 31
};

enum OneK {
enum OneK
#if defined(BENCHMARK_HAS_CXX11)
: uint16_t
#endif
{
// 1'000 items per 1k
kIs1000 = 1000,
// 1'024 items per 1k
Expand Down Expand Up @@ -732,13 +747,34 @@ typedef std::map<std::string, Counter> UserCounters;
// computational
// complexity for the benchmark. In case oAuto is selected, complexity will be
// calculated automatically to the best fit.
enum BigO { oNone, o1, oN, oNSquared, oNCubed, oLogN, oNLogN, oAuto, oLambda };
enum BigO
#if defined(BENCHMARK_HAS_CXX11)
: uint8_t
#endif
{
oNone,
o1,
oN,
oNSquared,
oNCubed,
oLogN,
oNLogN,
oAuto,
oLambda
};

typedef int64_t ComplexityN;

typedef int64_t IterationCount;

enum StatisticUnit { kTime, kPercentage };
enum StatisticUnit
#if defined(BENCHMARK_HAS_CXX11)
: uint8_t
#endif
{
kTime,
kPercentage
};

// BigOFunc is passed to a benchmark in order to specify the asymptotic
// computational complexity for the benchmark.
Expand Down Expand Up @@ -766,8 +802,7 @@ class PerfCountersMeasurement;

enum AggregationReportMode
#if defined(BENCHMARK_HAS_CXX11)
: unsigned
#else
: uint8_t
#endif
{
// The mode has not been manually specified
Expand All @@ -786,7 +821,7 @@ enum AggregationReportMode

enum Skipped
#if defined(BENCHMARK_HAS_CXX11)
: unsigned
: uint8_t
#endif
{
NotSkipped = 0,
Expand Down Expand Up @@ -1789,7 +1824,15 @@ struct BENCHMARK_EXPORT CPUInfo {
int num_sharing;
};

enum Scaling { UNKNOWN, ENABLED, DISABLED };
enum Scaling
#if defined(BENCHMARK_HAS_CXX11)
: uint8_t
#endif
{
UNKNOWN,
ENABLED,
DISABLED
};

int num_cpus;
Scaling scaling;
Expand Down Expand Up @@ -1850,7 +1893,14 @@ class BENCHMARK_EXPORT BenchmarkReporter {

struct BENCHMARK_EXPORT Run {
static const int64_t no_repetition_index = -1;
enum RunType { RT_Iteration, RT_Aggregate };
enum RunType
#if defined(BENCHMARK_HAS_CXX11)
: uint8_t
#endif
{
RT_Iteration,
RT_Aggregate
};

Run()
: run_type(RT_Iteration),
Expand Down Expand Up @@ -2006,7 +2056,11 @@ class BENCHMARK_EXPORT BenchmarkReporter {
// default reporter used by RunSpecifiedBenchmarks().
class BENCHMARK_EXPORT ConsoleReporter : public BenchmarkReporter {
public:
enum OutputOptions {
enum OutputOptions
#if defined(BENCHMARK_HAS_CXX11)
: uint8_t
#endif
{
OO_None = 0,
OO_Color = 1,
OO_Tabular = 2,
Expand Down
8 changes: 8 additions & 0 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
#define BENCHMARK_HAS_CXX11
#endif

// This _MSC_VER check should detect VS 2017 v15.3 and newer.
#if __cplusplus >= 201703L || \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only defined if the Zc:__cplusplus flag is enabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on msvc, yes, which is why we have the rest of the check.

(defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L)
// CXX17 implies CXX11
#define BENCHMARK_HAS_CXX11
#define BENCHMARK_HAS_CXX17
#endif

namespace benchmark {
namespace internal {

Expand Down
Loading