Skip to content

Commit

Permalink
merged from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
malkia committed May 30, 2024
2 parents b1671b3 + c42dcca commit 2926f53
Show file tree
Hide file tree
Showing 108 changed files with 520 additions and 345 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ jobs:

format:
name: Format
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: setup
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

name: include-what-you-use

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
iwyu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: setup dependencies
run: |
sudo apt update -y
sudo apt install -y --no-install-recommends --no-install-suggests \
build-essential \
iwyu \
cmake \
ninja-build \
libssl-dev \
libcurl4-openssl-dev \
libprotobuf-dev \
protobuf-compiler \
libgmock-dev \
libgtest-dev \
libbenchmark-dev
- name: Prepare CMake
run: |
TOPDIR=`pwd`
mkdir build && cd build
CC="clang" CXX="clang++" cmake \
-DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \
-DBUILD_TESTING=OFF \
-DBUILD_W3CTRACECONTEXT_TEST=OFF \
..
- name: iwyu_tool
run: |
cd build
make -k 2>&1 | tee -a iwyu.log
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Logs (include-what-you-use)
path: ./build/*.log

- name: count warnings
run: |
cd build
COUNT=`grep -c "Warning:" iwyu.log`
echo "include-what-you-use reported ${COUNT} warning(s)"
13 changes: 13 additions & 0 deletions .iwyu.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# include-what-you-use mapping file

[
# Work around for C++ STL
{ "include": ["<bits/chrono.h>", "private", "<chrono>", "public"] },

# Local opentelemetry-cpp

]

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Increment the:
* [SDK] Update ExemplarFilter and ExemplarReservoir for spec
[#2372](https://github.com/open-telemetry/opentelemetry-cpp/pull/2372)

* [CI] Upgrade to clang-format 18
[#2684](https://github.com/open-telemetry/opentelemetry-cpp/pull/2684)

Notes on experimental features:

* [#2372](https://github.com/open-telemetry/opentelemetry-cpp/issues/2372)
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/common/kv_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class KeyValueProperties
}

// Move contructor and assignment operator
Entry(Entry &&other) = default;
Entry(Entry &&other) = default;
Entry &operator=(Entry &&other) = default;

// Creates an Entry for a given key-value pair.
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/common/spin_lock_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class SpinLockMutex
{
public:
SpinLockMutex() noexcept {}
~SpinLockMutex() noexcept = default;
SpinLockMutex(const SpinLockMutex &) = delete;
~SpinLockMutex() noexcept = default;
SpinLockMutex(const SpinLockMutex &) = delete;
SpinLockMutex &operator=(const SpinLockMutex &) = delete;

static inline void fast_yield() noexcept
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/logs/event_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class EventLogger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void EmitEvent(nostd::string_view event_name, ArgumentType &&... args)
void EmitEvent(nostd::string_view event_name, ArgumentType &&...args)
{
nostd::shared_ptr<Logger> delegate_logger = GetDelegateLogger();
if (!delegate_logger)
Expand Down
16 changes: 8 additions & 8 deletions api/include/opentelemetry/logs/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record, ArgumentType &&... args)
void EmitLogRecord(nostd::unique_ptr<LogRecord> &&log_record, ArgumentType &&...args)
{
if (!log_record)
{
Expand Down Expand Up @@ -97,7 +97,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void EmitLogRecord(ArgumentType &&... args)
void EmitLogRecord(ArgumentType &&...args)
{
nostd::unique_ptr<LogRecord> log_record = CreateLogRecord();

Expand All @@ -120,7 +120,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Trace(ArgumentType &&... args) noexcept
void Trace(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -144,7 +144,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Debug(ArgumentType &&... args) noexcept
void Debug(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -168,7 +168,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Info(ArgumentType &&... args) noexcept
void Info(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -192,7 +192,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Warn(ArgumentType &&... args) noexcept
void Warn(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -216,7 +216,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Error(ArgumentType &&... args) noexcept
void Error(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand All @@ -240,7 +240,7 @@ class Logger
* span<pair<string_view, AttributeValue>> -> attributes(return type of MakeAttributes)
*/
template <class... ArgumentType>
void Fatal(ArgumentType &&... args) noexcept
void Fatal(ArgumentType &&...args) noexcept
{
static_assert(
!detail::LogRecordHasType<Severity, typename std::decay<ArgumentType>::type...>::value,
Expand Down
4 changes: 2 additions & 2 deletions api/include/opentelemetry/logs/provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class Provider
return provider;
}

OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<EventLoggerProvider>
&GetEventProvider() noexcept
OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr<EventLoggerProvider> &
GetEventProvider() noexcept
{
static nostd::shared_ptr<EventLoggerProvider> provider(new NoopEventLoggerProvider);
return provider;
Expand Down
7 changes: 5 additions & 2 deletions api/include/opentelemetry/nostd/detail/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

#include "opentelemetry/version.h"

#define OPENTELEMETRY_RETURN(...) \
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { return __VA_ARGS__; }
#define OPENTELEMETRY_RETURN(...) \
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \
{ \
return __VA_ARGS__; \
}

OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
Expand Down
32 changes: 18 additions & 14 deletions api/include/opentelemetry/nostd/detail/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
#include "opentelemetry/nostd/detail/void.h"
#include "opentelemetry/version.h"

#define OPENTELEMETRY_RETURN(...) \
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) { return __VA_ARGS__; }
#define OPENTELEMETRY_RETURN(...) \
noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \
{ \
return __VA_ARGS__; \
}

OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
Expand All @@ -34,23 +37,23 @@ template <>
struct Invoke<true /* pmf */, 0 /* is_base_of */>
{
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
OPENTELEMETRY_RETURN((std::forward<Arg>(arg).*pmf)(std::forward<Args>(args)...))
};

template <>
struct Invoke<true /* pmf */, 1 /* is_reference_wrapper */>
{
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
OPENTELEMETRY_RETURN((std::forward<Arg>(arg).get().*pmf)(std::forward<Args>(args)...))
};

template <>
struct Invoke<true /* pmf */, 2 /* otherwise */>
{
template <typename R, typename T, typename Arg, typename... Args>
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&... args)
inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args)
OPENTELEMETRY_RETURN(((*std::forward<Arg>(arg)).*pmf)(std::forward<Args>(args)...))
};

Expand Down Expand Up @@ -79,20 +82,21 @@ struct Invoke<false /* pmo */, 2 /* otherwise */>
};

template <typename R, typename T, typename Arg, typename... Args>
inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&... args)
OPENTELEMETRY_RETURN(Invoke<std::is_function<R>::value,
(std::is_base_of<T, decay_t<Arg>>::value
? 0
: is_reference_wrapper<decay_t<Arg>>::value ? 1 : 2)>::
invoke(f, std::forward<Arg>(arg), std::forward<Args>(args)...))
inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN(
Invoke<std::is_function<R>::value,
(std::is_base_of<T, decay_t<Arg>>::value ? 0
: is_reference_wrapper<decay_t<Arg>>::value ? 1
: 2)>::invoke(f,
std::forward<Arg>(arg),
std::forward<Args>(args)...))

#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable : 4100)
#endif
template <typename F, typename... Args>
inline constexpr auto invoke_impl(F &&f, Args &&... args)
OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...))
template <typename F, typename... Args>
inline constexpr auto invoke_impl(F &&f, Args &&...args)
OPENTELEMETRY_RETURN(std::forward<F>(f)(std::forward<Args>(args)...))
#ifdef _MSC_VER
# pragma warning(pop)
#endif
Expand Down
6 changes: 3 additions & 3 deletions api/include/opentelemetry/nostd/detail/trait.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ template <typename T,
class IsAvailable>
inline constexpr Trait trait()
{
return IsTriviallyAvailable<T>::value
? Trait::TriviallyAvailable
: IsAvailable<T>::value ? Trait::Available : Trait::Unavailable;
return IsTriviallyAvailable<T>::value ? Trait::TriviallyAvailable
: IsAvailable<T>::value ? Trait::Available
: Trait::Unavailable;
}

inline constexpr Trait common_trait_impl(Trait result)
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/nostd/unique_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class unique_ptr
return *this;
}

operator std::unique_ptr<T>() &&noexcept { return std::unique_ptr<T>{release()}; }
operator std::unique_ptr<T>() && noexcept { return std::unique_ptr<T>{release()}; }

operator bool() const noexcept { return ptr_ != nullptr; }

Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/nostd/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
}

template <class T, size_t N>
size_t size(T (&/* array */)[N]) noexcept
size_t size(T (& /* array */)[N]) noexcept
{
return N;
}
Expand Down
14 changes: 7 additions & 7 deletions api/include/opentelemetry/plugin/hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* library and a dynamically loaded plugin. The weak linkage allows for multiple implementations to
* be linked in without getting multiple definition errors.
*/
# define OPENTELEMETRY_DEFINE_PLUGIN_HOOK(X) \
extern "C" { \
extern __declspec(dllexport) \
opentelemetry::plugin::OpenTelemetryHook const OpenTelemetryMakeFactoryImpl; \
\
__declspec(selectany) \
opentelemetry::plugin::OpenTelemetryHook const OpenTelemetryMakeFactoryImpl = X; \
# define OPENTELEMETRY_DEFINE_PLUGIN_HOOK(X) \
extern "C" { \
extern __declspec(dllexport) opentelemetry::plugin::OpenTelemetryHook const \
OpenTelemetryMakeFactoryImpl; \
\
__declspec(selectany) opentelemetry::plugin::OpenTelemetryHook const \
OpenTelemetryMakeFactoryImpl = X; \
} // extern "C"

#else
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/std/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
}

template <class T, std::size_t N>
std::size_t size(T (&/* array */)[N]) noexcept
std::size_t size(T (& /* array */)[N]) noexcept
{
return N;
}
Expand Down
10 changes: 4 additions & 6 deletions api/include/opentelemetry/std/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class bad_variant_access : public std::exception
// nostd::get<...> for Apple Clang
//
template <typename T, class... Types>
constexpr auto get_type = [](auto &&t) constexpr -> decltype(auto)
{
constexpr auto get_type = [](auto &&t) constexpr -> decltype(auto) {
auto v = t;
auto result = std::get_if<T>(&v); // TODO: optimize with std::forward(t) if t is not rvalue
if (result)
Expand All @@ -69,8 +68,7 @@ constexpr auto get_type = [](auto &&t) constexpr -> decltype(auto)
};

template <std::size_t I, class... Types>
constexpr auto get_index = [](auto &&t) constexpr -> decltype(auto)
{
constexpr auto get_index = [](auto &&t) constexpr -> decltype(auto) {
auto v = t;
auto result = std::get_if<I>(&v); // TODO: optimize with std::forward(t) if t is not rvalue
if (result)
Expand Down Expand Up @@ -132,7 +130,7 @@ constexpr const T &&get(const std::variant<Types...> &&v)
};

template <class _Callable, class... _Variants>
constexpr auto visit(_Callable &&_Obj, _Variants &&... _Args)
constexpr auto visit(_Callable &&_Obj, _Variants &&..._Args)
{
// Ref:
// https://stackoverflow.com/questions/52310835/xcode-10-call-to-unavailable-function-stdvisit
Expand Down Expand Up @@ -193,7 +191,7 @@ constexpr const T &&get(const std::variant<Types...> &&v)
}

template <class _Callable, class... _Variants>
constexpr auto visit(_Callable &&_Obj, _Variants &&... _Args)
constexpr auto visit(_Callable &&_Obj, _Variants &&..._Args)
{
return std::visit<_Callable, _Variants...>(static_cast<_Callable &&>(_Obj),
static_cast<_Variants &&>(_Args)...);
Expand Down
Loading

0 comments on commit 2926f53

Please sign in to comment.