diff --git a/include/ircd/buffer/buffer.h b/include/ircd/buffer/buffer.h index e10dd1ccf..0b85e4b8c 100644 --- a/include/ircd/buffer/buffer.h +++ b/include/ircd/buffer/buffer.h @@ -254,7 +254,11 @@ ircd::buffer::reverse(const mutable_buffer &dst, } template +#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 +#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." diff --git a/include/ircd/json/tuple/set.h b/include/ircd/json/tuple/set.h index bfbd2093b..1c0e9d07e 100644 --- a/include/ircd/json/tuple/set.h +++ b/include/ircd/json/tuple/set.h @@ -144,7 +144,11 @@ typename std::enable_if !std::is_assignable() && !std::is_constructible(), 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) { diff --git a/include/ircd/lex_cast.h b/include/ircd/lex_cast.h index 955ad19fa..bdb5ad14e 100644 --- a/include/ircd/lex_cast.h +++ b/include/ircd/lex_cast.h @@ -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(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(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 -__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 -__attribute__((error("unsupported lexical cast"))) +IRCD_LEX_CAST_UNNECESSARY bool ircd::try_lex_cast(const string_view &s) { diff --git a/ircd/ctx.cc b/ircd/ctx.cc index d8757e3ef..d97a7e4f9 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -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 diff --git a/ircd/db.cc b/ircd/db.cc index dff47f903..03a246a0b 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -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 { diff --git a/ircd/db_port.cc b/ircd/db_port.cc index a7ba40602..6b491ca9b 100644 --- a/ircd/db_port.cc +++ b/ircd/db_port.cc @@ -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 { diff --git a/ircd/db_write_thread.cc b/ircd/db_write_thread.cc index 0269f8afa..d5f1f0bdb 100644 --- a/ircd/db_write_thread.cc +++ b/ircd/db_write_thread.cc @@ -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) { diff --git a/ircd/prof.cc b/ircd/prof.cc index 0927d5ddf..7195ac5bc 100644 --- a/ircd/prof.cc +++ b/ircd/prof.cc @@ -17,6 +17,12 @@ #include #include +#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 { diff --git a/ircd/rfc3986.cc b/ircd/rfc3986.cc index 147fc3148..af6a878bb 100644 --- a/ircd/rfc3986.cc +++ b/ircd/rfc3986.cc @@ -20,9 +20,12 @@ __attribute__((visibility("hidden"))) struct ircd::rfc3986::encoder :karma::grammar { - void throw_illegal() + [[noreturn]] void throw_illegal() { - throw encoding_error("Generator Protection: urlencode"); + throw encoding_error + { + "Generator Protection: urlencode" + }; } karma::rule url_encoding