0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd: Fix attributes for clang.

This commit is contained in:
Jason Volk 2019-06-23 00:05:53 -06:00
parent e4a5a755d0
commit 801f0d57b7
9 changed files with 50 additions and 40 deletions

View file

@ -254,7 +254,11 @@ ircd::buffer::reverse(const mutable_buffer &dst,
}
template<size_t SIZE>
#ifndef __clang__
__attribute__((error
#else
__attribute__((unavailable
#endif
(
"Move source is an array. Is this a string literal? Do you want to move the \\0?"
" Disambiguate this by typing the source string_view or const_buffer."
@ -267,7 +271,11 @@ ircd::buffer::move(const mutable_buffer &dst,
}
template<size_t SIZE>
#ifndef __clang__
__attribute__((error
#else
__attribute__((unavailable
#endif
(
"Copy source is an array. Is this a string literal? Do you want to copy the \\0?"
" Disambiguate this by typing the source string_view or const_buffer."

View file

@ -144,7 +144,11 @@ typename std::enable_if
!std::is_assignable<dst, src>() &&
!std::is_constructible<dst, src>(),
void>::type
#ifdef __clang__
__attribute__((unavailable("Unhandled assignment to json::tuple property")))
#else
__attribute__((error("Unhandled assignment to json::tuple property")))
#endif
_assign(dst &d,
src&& s)
{

View file

@ -95,6 +95,14 @@ namespace ircd
template<> string_view lex_cast(bool, const mutable_buffer &buf);
}
#ifdef __clang__
#define IRCD_LEX_CAST_UNNECESSARY \
__attribute__((deprecated("unnecessary lexical cast")))
#else
#define IRCD_LEX_CAST_UNNECESSARY \
__attribute__((warning("unnecessary lexical cast")))
#endif
/// Convert a native number to a string. The returned value is a view of the
/// string in a static ring buffer. There are LEX_CAST_BUFS number of buffers
/// so you should not hold on to the returned view for very long.
@ -136,7 +144,7 @@ ircd::lex_cast<std::string_view>(const std::string_view &s)
/// because the conversion has to copy the string while no numerical conversion
/// has taken place. The developer should remove the offending lex_cast.
template<>
__attribute__((warning("unnecessary lexical cast")))
IRCD_LEX_CAST_UNNECESSARY
inline std::string
ircd::lex_cast<std::string>(const std::string &s)
{
@ -174,7 +182,7 @@ ircd::lex_cast(std::string &s)
/// marked as unnecessary because no numerical conversion takes place yet
/// data is still copied. (note: warning may be removed; may be intentional)
template<>
__attribute__((warning("unnecessary lexical cast")))
IRCD_LEX_CAST_UNNECESSARY
inline ircd::string_view
ircd::lex_cast(const string_view &s,
const mutable_buffer &buf)
@ -187,7 +195,7 @@ ircd::lex_cast(const string_view &s,
/// marked as unnecessary because no numerical conversion takes place yet
/// data is still copied. (note: warning may be removed; may be intentional)
template<>
__attribute__((warning("unnecessary lexical cast")))
IRCD_LEX_CAST_UNNECESSARY
inline ircd::string_view
ircd::lex_cast(const std::string_view &s,
const mutable_buffer &buf)
@ -200,7 +208,7 @@ ircd::lex_cast(const std::string_view &s,
/// marked as unnecessary because no numerical conversion takes place yet
/// data is still copied. (note: warning may be removed; may be intentional)
template<>
__attribute__((warning("unnecessary lexical cast")))
IRCD_LEX_CAST_UNNECESSARY
inline ircd::string_view
ircd::lex_cast(const std::string &s,
const mutable_buffer &buf)
@ -211,7 +219,7 @@ ircd::lex_cast(const std::string &s,
/// Template basis; if no specialization is matched there is no fallback here
template<class T>
__attribute__((error("unsupported lexical cast")))
IRCD_LEX_CAST_UNNECESSARY
ircd::string_view
ircd::lex_cast(T t,
const mutable_buffer &buf)
@ -222,7 +230,7 @@ ircd::lex_cast(T t,
/// Template basis; if no specialization is matched there is no fallback here
template<class T>
__attribute__((error("unsupported lexical cast")))
IRCD_LEX_CAST_UNNECESSARY
bool
ircd::try_lex_cast(const string_view &s)
{

View file

@ -16,7 +16,7 @@
/// another tool to detect corruption of a context's stack, specifically
/// during yield and resume. This use is not really to provide security; just
/// a kind of extra assertion, so we eliminate its emission during release.
#ifndef NDEBUG
#if !defined(NDEBUG) && !defined(__clang__)
#define IRCD_CTX_STACK_PROTECT __attribute__((stack_protect))
#else
#define IRCD_CTX_STACK_PROTECT

View file

@ -2587,8 +2587,8 @@ noexcept
{
}
[[noreturn]]
rocksdb::Status
__attribute__((noreturn))
ircd::db::database::stats::passthru::Reset()
noexcept
{
@ -2624,16 +2624,16 @@ const noexcept
});
}
[[noreturn]]
uint64_t
__attribute__((noreturn))
ircd::db::database::stats::passthru::getTickerCount(const uint32_t tickerType)
const noexcept
{
throw panic {"Unavailable for passthru"};
}
[[noreturn]]
void
__attribute__((noreturn))
ircd::db::database::stats::passthru::setTickerCount(const uint32_t tickerType,
const uint64_t count)
noexcept
@ -2641,8 +2641,8 @@ noexcept
throw panic {"Unavailable for passthru"};
}
[[noreturn]]
void
__attribute__((noreturn))
ircd::db::database::stats::passthru::histogramData(const uint32_t type,
rocksdb::HistogramData *const data)
const noexcept
@ -2650,8 +2650,8 @@ const noexcept
throw panic {"Unavailable for passthru"};
}
[[noreturn]]
uint64_t
__attribute__((noreturn))
ircd::db::database::stats::passthru::getAndResetTickerCount(const uint32_t tickerType)
noexcept
{

View file

@ -21,7 +21,6 @@ static_assert
"than the one rocksdb has assumed space for."
);
__attribute__((externally_visible))
rocksdb::port::Mutex::Mutex()
noexcept
{
@ -36,14 +35,12 @@ noexcept
#endif
}
__attribute__((externally_visible))
rocksdb::port::Mutex::Mutex(bool adaptive)
noexcept
:Mutex{}
{
}
__attribute__((externally_visible))
rocksdb::port::Mutex::~Mutex()
noexcept
{
@ -59,7 +56,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::Mutex::Lock()
noexcept
{
@ -79,7 +75,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::Mutex::Unlock()
noexcept
{
@ -100,7 +95,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::Mutex::AssertHeld()
noexcept
{
@ -121,7 +115,6 @@ static_assert
"than the one rocksdb has assumed space for."
);
__attribute__((externally_visible))
rocksdb::port::RWMutex::RWMutex()
noexcept
{
@ -136,7 +129,6 @@ noexcept
#endif
}
__attribute__((externally_visible))
rocksdb::port::RWMutex::~RWMutex()
noexcept
{
@ -152,7 +144,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::RWMutex::ReadLock()
noexcept
{
@ -172,7 +163,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::RWMutex::WriteLock()
noexcept
{
@ -192,7 +182,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::RWMutex::ReadUnlock()
noexcept
{
@ -212,7 +201,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::RWMutex::WriteUnlock()
noexcept
{
@ -242,7 +230,6 @@ static_assert
"than the one rocksdb has assumed space for."
);
__attribute__((externally_visible))
rocksdb::port::CondVar::CondVar(Mutex *mu)
noexcept
:mu{mu}
@ -258,7 +245,6 @@ noexcept
#endif
}
__attribute__((externally_visible))
rocksdb::port::CondVar::~CondVar()
noexcept
{
@ -274,7 +260,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::CondVar::Wait()
noexcept
{
@ -296,7 +281,6 @@ noexcept
// Returns true if timeout occurred
bool
__attribute__((externally_visible))
rocksdb::port::CondVar::TimedWait(uint64_t abs_time_us)
noexcept
{
@ -319,7 +303,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::CondVar::Signal()
noexcept
{
@ -335,7 +318,6 @@ noexcept
}
void
__attribute__((externally_visible))
rocksdb::port::CondVar::SignalAll()
noexcept
{

View file

@ -64,7 +64,6 @@
#ifdef STORAGE_ROCKSDB_INCLUDE_DB_H_
uint8_t
__attribute__((externally_visible))
rocksdb::WriteThread::BlockingAwaitState(Writer *const w,
uint8_t goal_mask)
{

View file

@ -17,6 +17,12 @@
#include <boost/chrono/chrono.hpp>
#include <boost/chrono/process_cpu_clocks.hpp>
#ifndef __clang__
#define IRCD_PROF_ALWAYS_OPTIMIZE __attribute__((optimize("s"), flatten))
#else
#define IRCD_PROF_ALWAYS_OPTIMIZE
#endif
namespace ircd::prof
{
std::ostream &debug(std::ostream &, const ::perf_event_mmap_page &);
@ -120,14 +126,14 @@ ircd::prof::reset(group &group)
}
void
__attribute__((optimize("s"), flatten))
IRCD_PROF_ALWAYS_OPTIMIZE
ircd::prof::start(group &group)
{
leader(group).enable(PERF_IOC_FLAG_GROUP);
}
void
__attribute__((optimize("s"), flatten))
IRCD_PROF_ALWAYS_OPTIMIZE
ircd::prof::stop(group &group)
{
auto &leader(*group.front());
@ -136,7 +142,7 @@ ircd::prof::stop(group &group)
}
ircd::prof::event &
__attribute__((optimize("s")))
IRCD_PROF_ALWAYS_OPTIMIZE
ircd::prof::leader(group &group)
{
assert(!group.empty() && group.front());
@ -304,7 +310,7 @@ noexcept
}
const uint64_t &
__attribute__((optimize("s"), flatten))
IRCD_PROF_ALWAYS_OPTIMIZE
ircd::prof::instructions::sample()
{
retired = prof::leader(group).rdpmc();
@ -765,14 +771,14 @@ noexcept
}
inline void
__attribute__((optimize("s")))
IRCD_PROF_ALWAYS_OPTIMIZE
ircd::prof::event::disable(const long &arg)
{
::ioctl(int(fd), PERF_EVENT_IOC_DISABLE, arg);
}
inline void
__attribute__((optimize("s")))
IRCD_PROF_ALWAYS_OPTIMIZE
ircd::prof::event::enable(const long &arg)
{
const int &fd(this->fd);
@ -795,7 +801,7 @@ ircd::prof::event::ioctl(const ulong &req,
}
inline uint64_t
__attribute__((optimize("s")))
IRCD_PROF_ALWAYS_OPTIMIZE
ircd::prof::event::rdpmc()
const
{

View file

@ -20,9 +20,12 @@ __attribute__((visibility("hidden")))
struct ircd::rfc3986::encoder
:karma::grammar<char *, const string_view &>
{
void throw_illegal()
[[noreturn]] void throw_illegal()
{
throw encoding_error("Generator Protection: urlencode");
throw encoding_error
{
"Generator Protection: urlencode"
};
}
karma::rule<char *, const string_view &> url_encoding