0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-31 19:08:59 +01: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(const scope &) = delete;
scope(scope &&) = delete;
~scope();
~scope() noexcept;
};
/// Internal state structure for some of these tools. This is a very small and
@ -290,8 +290,12 @@ struct ircd::allocator::fixed
operator allocator();
fixed()
:state{MAX, avail.data()}
{}
{
static_cast<state &>(*this) =
{
MAX, avail.data()
};
}
};
/// 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)
{
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));
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)
{
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);
}

View file

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

View file

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

View file

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

View file

@ -203,8 +203,11 @@ namespace ircd
using std::chrono::high_resolution_clock;
using std::chrono::time_point;
using namespace std::literals::chrono_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;

View file

@ -409,7 +409,7 @@ template<size_t index,
off_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(t))

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3353,14 +3353,14 @@ ircd::json::serialized(const value &v)
size_t
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;

View file

@ -690,6 +690,11 @@ ircd::m::sync::stats_info
{ "default", false },
};
template<>
decltype(ircd::m::sync::item::instance_multimap::map)
ircd::m::sync::item::instance_multimap::map
{};
bool
ircd::m::sync::for_each(const item_closure_bool &closure)
{
@ -875,11 +880,6 @@ noexcept
// item
//
template<>
decltype(ircd::m::sync::item::instance_multimap::map)
ircd::m::sync::item::instance_multimap::map
{};
//
// item::item
//
@ -4598,6 +4598,32 @@ namespace ircd::m
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
//
@ -4757,19 +4783,6 @@ const
// 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
ircd::m::hook::base::base(const json::members &members)
try
@ -4850,19 +4863,6 @@ catch(const std::out_of_range &e)
// 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
//

View file

@ -3170,7 +3170,7 @@ bool
ircd::m::verify_hash(const event &event,
const sha256::buf &hash)
{
static const size_t hashb64sz
static constexpr size_t hashb64sz
{
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();
return ret;
return std::move(ret);
}
///////////////////////////////////////////////////////////////////////////////

View file

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

View file

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

View file

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