0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-27 22:38:21 +02:00

ircd: Misc fixes for clang.

This commit is contained in:
Jason Volk 2019-06-23 00:28:48 -06:00
parent 2e7f272570
commit cf3b1218c4
20 changed files with 106 additions and 87 deletions

View file

@ -119,7 +119,7 @@ struct ircd::allocator::scope
scope(alloc_closure = {}, realloc_closure = {}, free_closure = {}); scope(alloc_closure = {}, realloc_closure = {}, free_closure = {});
scope(const scope &) = delete; scope(const scope &) = delete;
scope(scope &&) = delete; scope(scope &&) = delete;
~scope(); ~scope() noexcept;
}; };
/// Internal state structure for some of these tools. This is a very small and /// Internal state structure for some of these tools. This is a very small and
@ -290,8 +290,12 @@ struct ircd::allocator::fixed
operator allocator(); operator allocator();
fixed() fixed()
:state{MAX, avail.data()} {
{} static_cast<state &>(*this) =
{
MAX, avail.data()
};
}
}; };
/// The actual allocator template as used by the container. /// The actual allocator template as used by the container.
@ -342,7 +346,7 @@ struct ircd::allocator::fixed<T, SIZE>::allocator
allocate(std::nothrow_t, const size_type &n, const const_pointer &hint = nullptr) allocate(std::nothrow_t, const size_type &n, const const_pointer &hint = nullptr)
{ {
const auto base(reinterpret_cast<pointer>(s->buf.data())); const auto base(reinterpret_cast<pointer>(s->buf.data()));
const uint hintpos(hint? uintptr_t(hint - base) : uintptr_t(-1)); const uint hintpos(hint? uint(hint - base) : uint(-1));
const pointer ret(base + s->state::allocate(std::nothrow, n, hintpos)); const pointer ret(base + s->state::allocate(std::nothrow, n, hintpos));
return s->in_range(ret)? ret : nullptr; return s->in_range(ret)? ret : nullptr;
} }
@ -352,7 +356,7 @@ struct ircd::allocator::fixed<T, SIZE>::allocator
allocate(const size_type &n, const const_pointer &hint = nullptr) allocate(const size_type &n, const const_pointer &hint = nullptr)
{ {
const auto base(reinterpret_cast<pointer>(s->buf.data())); const auto base(reinterpret_cast<pointer>(s->buf.data()));
const uint hintpos(hint? uintptr_t(hint - base) : uintptr_t(-1)); const uint hintpos(hint? uint(hint - base) : uint(-1));
return base + s->state::allocate(n, hintpos); return base + s->state::allocate(n, hintpos);
} }

View file

@ -59,6 +59,7 @@ ircd::js::init::init()
inline inline
ircd::js::init::~init() ircd::js::init::~init()
noexcept
{ {
} }

View file

@ -74,7 +74,7 @@ struct ircd::net::listener_udp::datagram
datagram(const mutable_buffer &buf, datagram(const mutable_buffer &buf,
const enum flag &flag = (enum flag)0); const enum flag &flag = (enum flag)0);
datagram() = default; datagram() {}
}; };
enum ircd::net::listener_udp::flag enum ircd::net::listener_udp::flag

View file

@ -106,7 +106,7 @@ struct ircd::prof::instructions
const uint64_t &at() const; const uint64_t &at() const;
const uint64_t &sample(); const uint64_t &sample();
instructions() noexcept; instructions();
instructions(instructions &&) = delete; instructions(instructions &&) = delete;
instructions(const instructions &) = delete; instructions(const instructions &) = delete;
~instructions() noexcept; ~instructions() noexcept;
@ -207,7 +207,7 @@ struct ircd::prof::system
system(sample_t) noexcept; system(sample_t) noexcept;
system() system()
:array_type{{0}} :array_type{{{0}}}
{} {}
}; };

View file

@ -203,8 +203,11 @@ namespace ircd
using std::chrono::high_resolution_clock; using std::chrono::high_resolution_clock;
using std::chrono::time_point; using std::chrono::time_point;
using namespace std::literals::chrono_literals;
using namespace std::string_literals; using namespace std::string_literals;
using namespace std::chrono_literals;
using namespace std::literals::chrono_literals;
using std::string_literals::operator""s;
using std::chrono_literals::operator""s;
namespace ph = std::placeholders; namespace ph = std::placeholders;

View file

@ -409,7 +409,7 @@ template<size_t index,
off_t off_t
tuple_offset(const tuple &t) tuple_offset(const tuple &t)
{ {
return return off_t
{ {
reinterpret_cast<const uint8_t *>(std::addressof(std::get<index>(t))) - reinterpret_cast<const uint8_t *>(std::addressof(std::get<index>(t))) -
reinterpret_cast<const uint8_t *>(std::addressof(t)) reinterpret_cast<const uint8_t *>(std::addressof(t))

View file

@ -158,7 +158,7 @@ at(It &&start,
{ {
for(; start != stop; --i, std::advance(start, 1)) for(; start != stop; --i, std::advance(start, 1))
if(!i) if(!i)
return start; return std::move(start);
throw std::out_of_range throw std::out_of_range
{ {

View file

@ -34,6 +34,8 @@ __assert_perror_fail(int __errnum,
#endif #endif
#if !defined(NDEBUG) && defined(RB_ASSERT) #if !defined(NDEBUG) && defined(RB_ASSERT)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"
void void
__assert_fail(const char *__assertion, __assert_fail(const char *__assertion,
const char *__file, const char *__file,
@ -89,6 +91,7 @@ __assert_fail(const char *__assertion,
else __builtin_trap(); else __builtin_trap();
} }
#pragma clang diagnostic pop
#endif #endif
void void

View file

@ -789,7 +789,7 @@ noexcept
assert(bool(*this)); assert(bool(*this));
#ifdef HAVE_CXXABI_H #ifdef HAVE_CXXABI_H
__cxa_end_catch(); __cxxabiv1::__cxa_end_catch();
#endif #endif
// We don't yet support more levels of exceptions; after ending this // We don't yet support more levels of exceptions; after ending this
@ -1533,7 +1533,7 @@ try
{ {
const auto func const auto func
{ {
std::move(q.pop()) q.pop()
}; };
const scope_count working const scope_count working
@ -2146,21 +2146,16 @@ noexcept
} }
ircd::ctx::promise_base::~promise_base() ircd::ctx::promise_base::~promise_base()
noexcept try noexcept
{ {
if(!valid()) if(!valid())
return; return;
if(refcount(state()) == 1) if(refcount(state()) == 1)
throw broken_promise{}; set_exception(make_exception_ptr<broken_promise>());
else else
remove(state(), *this); remove(state(), *this);
} }
catch(const std::exception &e)
{
set_exception(std::current_exception());
return;
}
void void
ircd::ctx::promise_base::set_exception(std::exception_ptr eptr) ircd::ctx::promise_base::set_exception(std::exception_ptr eptr)

View file

@ -1243,11 +1243,11 @@ try
existing.erase(descriptor.name); existing.erase(descriptor.name);
} }
for(const auto &remain : existing) if(!existing.empty())
throw error throw error
{ {
"Failed to describe existing column '%s' (and %zd others...)", "Failed to describe existing column '%s' (and %zd others...)",
remain, *begin(existing),
existing.size() - 1 existing.size() - 1
}; };
@ -1427,7 +1427,7 @@ catch(const error &e)
log::error log::error
{ {
"Error opening db '%s': %s", "Error opening db '%s': %s",
this->name, name,
e.what() e.what()
}; };
@ -1438,14 +1438,14 @@ catch(const std::exception &e)
log::error log::error
{ {
"Error opening db '%s': %s", "Error opening db '%s': %s",
this->name, name,
e.what() e.what()
}; };
throw error throw error
{ {
"Failed to open db '%s': %s", "Failed to open db '%s': %s",
this->name, name,
e.what() e.what()
}; };
} }
@ -1522,8 +1522,7 @@ catch(const std::exception &e)
{ {
log::error log::error
{ {
log, "'%s': Error closing database(%p) :%s", log, "Error closing database(%p) :%s",
name,
this, this,
e.what() e.what()
}; };
@ -1534,8 +1533,7 @@ catch(...)
{ {
log::critical log::critical
{ {
log, "'%s': Unknown error closing database(%p)", log, "Unknown error closing database(%p)",
name,
this this
}; };
@ -2191,6 +2189,8 @@ noexcept
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" #pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
void void
ircd::db::database::logger::Logv(const rocksdb::InfoLogLevel level_, ircd::db::database::logger::Logv(const rocksdb::InfoLogLevel level_,
const char *const fmt, const char *const fmt,
@ -2225,6 +2225,7 @@ noexcept
rog(level, "'%s': %s", d->name, str); rog(level, "'%s': %s", d->name, str);
} }
#pragma clang diagnostic pop
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -3955,6 +3956,7 @@ catch(const std::exception &e)
}; };
ircd::terminate(); ircd::terminate();
__builtin_unreachable();
} }
rocksdb::Status rocksdb::Status

View file

@ -282,7 +282,12 @@ const noexcept
ircd::terminate::terminate() ircd::terminate::terminate()
noexcept noexcept
{ {
terminate(std::current_exception()); ircd::terminate
{
std::current_exception()
};
__builtin_unreachable();
} }
ircd::terminate::terminate(const string_view &str) ircd::terminate::terminate(const string_view &str)

View file

@ -910,6 +910,8 @@ catch(const std::exception &e)
qcount, qcount,
e.what() e.what()
}}; }};
__builtin_unreachable();
} }
size_t size_t

View file

@ -106,7 +106,11 @@ ircd::ios::descriptor::default_deallocator(handler &handler,
void *const &ptr, void *const &ptr,
const size_t &size) const size_t &size)
{ {
#ifdef __clang__
::operator delete(ptr);
#else
::operator delete(ptr, size); ::operator delete(ptr, size);
#endif
} }
void * void *

View file

@ -3353,14 +3353,14 @@ ircd::json::serialized(const value &v)
size_t size_t
ircd::json::serialized(const bool &b) ircd::json::serialized(const bool &b)
{ {
constexpr const size_t t static constexpr const size_t t
{ {
strlen("true") _constexpr_strlen("true")
}; };
constexpr const size_t f static constexpr const size_t f
{ {
strlen("false") _constexpr_strlen("false")
}; };
return b? t : f; return b? t : f;

View file

@ -690,6 +690,11 @@ ircd::m::sync::stats_info
{ "default", false }, { "default", false },
}; };
template<>
decltype(ircd::m::sync::item::instance_multimap::map)
ircd::m::sync::item::instance_multimap::map
{};
bool bool
ircd::m::sync::for_each(const item_closure_bool &closure) ircd::m::sync::for_each(const item_closure_bool &closure)
{ {
@ -875,11 +880,6 @@ noexcept
// item // item
// //
template<>
decltype(ircd::m::sync::item::instance_multimap::map)
ircd::m::sync::item::instance_multimap::map
{};
// //
// item::item // item::item
// //
@ -4598,6 +4598,32 @@ namespace ircd::m
static json::strung _hook_make_feature(const json::members &); static json::strung _hook_make_feature(const json::members &);
} }
/// Instance list linkage for all hook sites
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base::site>::allocator)
ircd::util::instance_list<ircd::m::hook::base::site>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base::site>::list)
ircd::util::instance_list<ircd::m::hook::base::site>::list
{
allocator
};
/// Instance list linkage for all hooks
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base>::allocator)
ircd::util::instance_list<ircd::m::hook::base>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base>::list)
ircd::util::instance_list<ircd::m::hook::base>::list
{
allocator
};
// //
// hook::maps // hook::maps
// //
@ -4757,19 +4783,6 @@ const
// hook::base // hook::base
// //
/// Instance list linkage for all hooks
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base>::allocator)
ircd::util::instance_list<ircd::m::hook::base>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base>::list)
ircd::util::instance_list<ircd::m::hook::base>::list
{
allocator
};
/// Primary hook ctor /// Primary hook ctor
ircd::m::hook::base::base(const json::members &members) ircd::m::hook::base::base(const json::members &members)
try try
@ -4850,19 +4863,6 @@ catch(const std::out_of_range &e)
// hook::site // hook::site
// //
/// Instance list linkage for all hook sites
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base::site>::allocator)
ircd::util::instance_list<ircd::m::hook::base::site>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::m::hook::base::site>::list)
ircd::util::instance_list<ircd::m::hook::base::site>::list
{
allocator
};
// //
// hook::site::site // hook::site::site
// //

View file

@ -3170,7 +3170,7 @@ bool
ircd::m::verify_hash(const event &event, ircd::m::verify_hash(const event &event,
const sha256::buf &hash) const sha256::buf &hash)
{ {
static const size_t hashb64sz static constexpr size_t hashb64sz
{ {
size_t(hash.size() * 1.34) + 1 size_t(hash.size() * 1.34) + 1
}; };

View file

@ -795,7 +795,7 @@ ircd::mods::make_target_name(const string_view &name,
}}; }};
ret.shrink_to_fit(); ret.shrink_to_fit();
return ret; return std::move(ret);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View file

@ -356,7 +356,7 @@ size_t
ircd::net::discard_all(socket &socket, ircd::net::discard_all(socket &socket,
const size_t &len) const size_t &len)
{ {
static char buffer[512] alignas(16); static char buffer[512];
size_t remain{len}; while(remain) size_t remain{len}; while(remain)
{ {
@ -380,7 +380,7 @@ size_t
ircd::net::discard_any(socket &socket, ircd::net::discard_any(socket &socket,
const size_t &len) const size_t &len)
{ {
static char buffer[512] alignas(16); static char buffer[512];
size_t remain{len}; while(remain) size_t remain{len}; while(remain)
{ {
@ -3047,7 +3047,7 @@ try
case ready::READ: case ready::READ:
{ {
static char buf[1] alignas(16); static char buf[1];
static const ilist<mutable_buffer> bufs{buf}; static const ilist<mutable_buffer> bufs{buf};
static ios::descriptor desc static ios::descriptor desc
{ {
@ -3112,7 +3112,7 @@ noexcept
{ {
assert(type == ready::ERROR); assert(type == ready::ERROR);
static char buf[1] alignas(16); static char buf[1];
static const ilist<mutable_buffer> bufs{buf}; static const ilist<mutable_buffer> bufs{buf};
static const std::error_code eof static const std::error_code eof
{ {

View file

@ -1658,6 +1658,7 @@ ircd::openssl::init::init()
} }
ircd::openssl::init::~init() ircd::openssl::init::~init()
noexcept
{ {
ec_fini(); ec_fini();

View file

@ -66,6 +66,18 @@ struct ircd::prof::event
~event() noexcept; ~event() noexcept;
}; };
template<>
decltype(ircd::util::instance_list<ircd::prof::event>::allocator)
ircd::util::instance_list<ircd::prof::event>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::prof::event>::list)
ircd::util::instance_list<ircd::prof::event>::list
{
allocator
};
decltype(ircd::prof::enable) decltype(ircd::prof::enable)
ircd::prof::enable ircd::prof::enable
{ {
@ -105,7 +117,7 @@ catch(const std::exception &e)
e.what() e.what()
}; };
this->~init(); system::group.clear();
throw; throw;
} }
@ -200,7 +212,7 @@ namespace ircd::prof::vg
} }
// //
// prof::vg::enable // prof::vg::enable
// //
ircd::prof::vg::enable::enable() ircd::prof::vg::enable::enable()
@ -216,7 +228,7 @@ noexcept
} }
// //
// prof::vg::disable // prof::vg::disable
// //
ircd::prof::vg::disable::disable() ircd::prof::vg::disable::disable()
@ -292,7 +304,6 @@ ircd::prof::vg::enabled()
// //
ircd::prof::instructions::instructions() ircd::prof::instructions::instructions()
noexcept
{ {
if(!create(this->group, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, true, false)) if(!create(this->group, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS, true, false))
throw error throw error
@ -642,18 +653,6 @@ noexcept
// event // event
// //
template<>
decltype(ircd::util::instance_list<ircd::prof::event>::allocator)
ircd::util::instance_list<ircd::prof::event>::allocator
{};
template<>
decltype(ircd::util::instance_list<ircd::prof::event>::list)
ircd::util::instance_list<ircd::prof::event>::list
{
allocator
};
// //
// event::event // event::event
// //