Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Clang support #3195

Merged
merged 21 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
fail-fast: true
matrix:
include:
- name: "clang17"
compiler: "clang-17"
build: unit
build_type: Release

- name: "gcc13"
compiler: "gcc-13"
build: unit
Expand Down
12 changes: 2 additions & 10 deletions build_system/seqan3-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VER
message (FATAL_ERROR "GCC < 10 is not supported. The detected compiler version is ${CMAKE_CXX_COMPILER_VERSION}.")
endif ()

option (SEQAN3_DISABLE_COMPILER_CHECK "Skips the check for supported compilers." OFF)

if (NOT SEQAN3_DISABLE_COMPILER_CHECK)
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message (FATAL_ERROR "Only GCC is supported. "
"The detected compiler version is ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}. "
"You can disable this error by passing -DSEQAN3_DISABLE_COMPILER_CHECK=ON to CMake.")
endif ()
else ()
set (SEQAN3_DEFINITIONS ${SEQAN3_DEFINITIONS} "-DSEQAN3_DISABLE_COMPILER_CHECK")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
message (FATAL_ERROR "Clang < 17 is not supported. The detected compiler version is ${CMAKE_CXX_COMPILER_VERSION}.")
endif ()

# ----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class on_result : private seqan3::pipeable_config_element
{
public:
//!\brief The stored callable which will be invoked with the alignment result.
seqan3::detail::copyable_wrapper_t<callback_t> callback{}; // Allows lambdas with capture blocks.
seqan3::detail::copyable_wrapper_t<callback_t> callback; // Allows lambdas with capture blocks.

/*!\name Constructors, destructor and assignment
* \{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class trace_matrix_full<trace_t>::iterator::column_proxy : public std::ranges::v
{
private:
//!\brief The represented column.
matrix_column_type column{};
matrix_column_type column;

public:
/*!\name Constructor, assignment and destructor
Expand Down
1 change: 0 additions & 1 deletion include/seqan3/alignment/pairwise/alignment_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ class alignment_algorithm :
// if traceback is enabled.
if constexpr (traits_t::compute_sequence_alignment)
{
auto trace_matrix_it = trace_debug_matrix.begin() + offset;
std::ranges::copy(
column
| std::views::transform(
Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/alignment/pairwise/alignment_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace seqan3::detail

// forward declaration for friend declaration in alignment_result.
template <typename configuration_t>
requires is_type_specialisation_of_v<configuration_t, configuration>
requires seqan3::detail::is_type_specialisation_of_v<configuration_t, configuration>
class policy_alignment_result_builder;

/*!\brief A struct that contains the actual alignment result data.
Expand Down Expand Up @@ -170,7 +170,7 @@ class alignment_result

//!\brief Befriend alignment result builder.
template <typename configuration_t>
requires detail::is_type_specialisation_of_v<configuration_t, configuration>
requires seqan3::detail::is_type_specialisation_of_v<configuration_t, configuration>
friend class detail::policy_alignment_result_builder;

public:
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alignment/pairwise/detail/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ concept indexed_sequence_pair_range =
//!\cond
template <typename t>
concept align_pairwise_single_input =
sequence_pair<std::remove_reference_t<t>> && std::is_lvalue_reference_v<t>
(sequence_pair<std::remove_reference_t<t>> && std::is_lvalue_reference_v<t>)
|| (std::ranges::viewable_range<std::tuple_element_t<0, std::remove_reference_t<t>>>
&& std::ranges::viewable_range<std::tuple_element_t<1, std::remove_reference_t<t>>>);
//!\endcond
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace seqan3::detail
* Implements the interfaces to build the alignment result based on the previously selected output configurations.
*/
template <typename alignment_configuration_t>
requires is_type_specialisation_of_v<alignment_configuration_t, configuration>
requires seqan3::detail::is_type_specialisation_of_v<alignment_configuration_t, configuration>
class policy_alignment_result_builder
{
protected:
Expand Down
43 changes: 30 additions & 13 deletions include/seqan3/alphabet/composite/alphabet_variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include <array>
#include <cassert>
#include <span>
#include <utility>
#include <variant>

Expand All @@ -28,6 +29,17 @@
namespace seqan3::detail
{

//!\brief Helper to determine whether a type is a std::span.
template <typename t, size_t extent = std::dynamic_extent>
struct is_span : std::false_type
{};

//!\cond
template <typename t, size_t extent>
struct is_span<std::span<t, extent>> : std::true_type
{};
//!\endcond

//!\brief Prevents wrong instantiations of std::alphabet_variant's constructors.
template <typename other_t, typename... alternative_types>
inline constexpr bool variant_general_guard =
Expand Down Expand Up @@ -193,7 +205,7 @@ class alphabet_variant :
* \stableapi{Since version 3.1.}
*/
template <typename alternative_t>
requires (!std::same_as<alternative_t, alphabet_variant>)
requires (!std::same_as<alternative_t, alphabet_variant>) && (!detail::is_span<alternative_t>::value)
&& (!std::is_base_of_v<alphabet_variant, alternative_t>)
&& (!list_traits::contains<
alphabet_variant,
Expand Down Expand Up @@ -223,10 +235,11 @@ class alphabet_variant :
* \experimentalapi{Experimental since version 3.1.}
*/
template <typename indirect_alternative_t>
requires (
(detail::instantiate_if_v<detail::lazy<std::is_convertible, indirect_alternative_t, alternative_types>,
detail::variant_general_guard<indirect_alternative_t, alternative_types...>>
|| ...))
requires (!detail::is_span<indirect_alternative_t>::value)
&& ((
detail::instantiate_if_v<detail::lazy<std::is_convertible, indirect_alternative_t, alternative_types>,
detail::variant_general_guard<indirect_alternative_t, alternative_types...>>
|| ...))
constexpr alphabet_variant(indirect_alternative_t const rhs) noexcept
{
using alternative_predicate = detail::implicitly_convertible_from<indirect_alternative_t>;
Expand Down Expand Up @@ -403,10 +416,12 @@ class alphabet_variant :
* \stableapi{Since version 3.1.}
*/
template <typename alphabet_variant_t, typename indirect_alternative_type>
friend constexpr auto
operator==(alphabet_variant_t const lhs, indirect_alternative_type const rhs) noexcept -> std::enable_if_t<
detail::variant_comparison_guard<alphabet_variant_t, indirect_alternative_type, false, alternative_types...>,
bool>
requires (!detail::is_span<alphabet_variant_t>::value)
&& (detail::variant_comparison_guard<alphabet_variant_t,
indirect_alternative_type,
false,
alternative_types...>)
friend constexpr bool operator==(alphabet_variant_t const lhs, indirect_alternative_type const rhs) noexcept
{
using alternative_predicate = detail::weakly_equality_comparable_with_<indirect_alternative_type>;
constexpr auto alternative_position =
Expand All @@ -428,10 +443,12 @@ class alphabet_variant :

//!\copydoc operator==(alphabet_variant_t const lhs, indirect_alternative_type const rhs)
template <typename alphabet_variant_t, typename indirect_alternative_type, typename = void>
friend constexpr auto operator==(indirect_alternative_type const lhs, alphabet_variant_t const rhs) noexcept
-> std::enable_if_t<
detail::variant_comparison_guard<alphabet_variant_t, indirect_alternative_type, true, alternative_types...>,
bool>
requires (!detail::is_span<alphabet_variant_t>::value)
&& (detail::variant_comparison_guard<alphabet_variant_t,
indirect_alternative_type,
true,
alternative_types...>)
friend constexpr bool operator==(indirect_alternative_type const lhs, alphabet_variant_t const rhs) noexcept
{
return rhs == lhs;
}
Expand Down
10 changes: 6 additions & 4 deletions include/seqan3/alphabet/composite/semialphabet_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ class semialphabet_any : public alphabet_base<semialphabet_any<size>, size, void
* \details
* \stableapi{Since version 3.1.}
*/
template <semialphabet other_alph_t>
requires (alphabet_size<other_alph_t> == size)
template <typename other_alph_t>
requires (!std::same_as<other_alph_t, semialphabet_any>)
&& semialphabet<other_alph_t> && (alphabet_size<other_alph_t> == size)
explicit semialphabet_any(other_alph_t const other)
{
assign_rank(seqan3::to_rank(other));
Expand All @@ -83,8 +84,9 @@ class semialphabet_any : public alphabet_base<semialphabet_any<size>, size, void
* \details
* \stableapi{Since version 3.1.}
*/
template <semialphabet other_alph_t>
requires ((alphabet_size<other_alph_t> == size) && std::regular<other_alph_t>)
template <typename other_alph_t>
requires (!std::same_as<other_alph_t, semialphabet_any>)
&& semialphabet<other_alph_t> && (alphabet_size<other_alph_t> == size) && std::regular<other_alph_t>
explicit operator other_alph_t() const
{
other_alph_t other{};
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/alphabet/views/translate_join.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class view_translate_join : public std::ranges::view_base
//!\}

//!\brief Befriend the following class s.t. iterator and const_iterator can be defined for this type.
template <typename, template <typename...> typename>
template <typename range_type, template <typename...> typename derived_t_template, typename... args_t>
friend class detail::random_access_iterator_base;

public:
Expand Down
12 changes: 6 additions & 6 deletions include/seqan3/argument_parser/argument_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ class argument_parser
/*!\name Constructors, destructor and assignment
* \{
*/
argument_parser() = delete; //!< Deleted.
argument_parser(argument_parser const &) = default; //!< Defaulted.
argument_parser & operator=(argument_parser const &) = default; //!< Defaulted.
argument_parser(argument_parser &&) = default; //!< Defaulted.
argument_parser & operator=(argument_parser &&) = default; //!< Defaulted.
argument_parser() = delete; //!< Deleted.
argument_parser(argument_parser const &) = delete; //!< Deleted. Holds std::future.
argument_parser & operator=(argument_parser const &) = delete; //!< Deleted. Holds std::future.
argument_parser(argument_parser &&) = default; //!< Defaulted.
argument_parser & operator=(argument_parser &&) = default; //!< Defaulted.

/*!\brief Initializes an seqan3::argument_parser object from the command line arguments.
*
Expand Down Expand Up @@ -773,7 +773,7 @@ class argument_parser
{
if (argv_len <= i + 1)
throw too_few_arguments{"Option --export-help must be followed by a value."};
export_format = {argv[i + 1]};
export_format = argv[i + 1];
}

if (export_format == "html")
Expand Down
5 changes: 1 addition & 4 deletions include/seqan3/argument_parser/detail/format_parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ class format_parse : public format_base
~format_parse() = default; //!< Defaulted.

/*!\brief The constructor of the parse format.
* \param[in] argc_ The number of command line arguments.
* \param[in] argv_ The command line arguments to parse.
*/
format_parse(int const argc_, std::vector<std::string> argv_) : argc{argc_ - 1}, argv{std::move(argv_)}
format_parse(int const, std::vector<std::string> argv_) : argv{std::move(argv_)}
{}
//!\}

Expand Down Expand Up @@ -822,8 +821,6 @@ class format_parse : public format_base
std::vector<std::function<void()>> positional_option_calls;
//!\brief Keeps track of the number of specified positional options.
unsigned positional_option_count{0};
//!\brief Number of command line arguments.
int argc;
//!\brief Vector of command line arguments.
std::vector<std::string> argv;
//!\brief Artificial end of argv if \-- was seen.
Expand Down
3 changes: 0 additions & 3 deletions include/seqan3/contrib/parallel/serialised_resource_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ struct ResourcePool
{
unlockWriting(recycled);
TValue * ptr = NULL;
unsigned count = 0;
while (popBack(ptr, recycled))
{
if (ptr != NULL)
count++;
delete ptr;
}
}
Expand Down
3 changes: 1 addition & 2 deletions include/seqan3/contrib/stream/bz2_ostream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool basic_bz2_ostreambuf<
std::streamsize buffer_size_
)
{
std::streamsize written_byte_size=0, total_written_byte_size = 0;
std::streamsize written_byte_size=0;

m_bzip2_stream.next_in=(byte_buffer_type)buffer_;
m_bzip2_stream.avail_in=buffer_size_*sizeof(char_type);
Expand All @@ -248,7 +248,6 @@ bool basic_bz2_ostreambuf<
if (m_err == BZ_RUN_OK || m_err == BZ_STREAM_END)
{
written_byte_size= static_cast<std::streamsize>(m_output_buffer.size()) - m_bzip2_stream.avail_out;
total_written_byte_size+=written_byte_size;
// output buffer is full, dumping to ostream
m_ostream.write(
(const char_type*) &(m_output_buffer[0]),
Expand Down
3 changes: 1 addition & 2 deletions include/seqan3/contrib/stream/gz_ostream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ bool basic_gz_ostreambuf<Elem, Tr, ElemA, ByteT, ByteAT>::zip_to_stream(
typename basic_gz_ostreambuf<Elem, Tr, ElemA, ByteT, ByteAT>::char_type * buffer_,
std::streamsize buffer_size_)
{
std::streamsize written_byte_size = 0, total_written_byte_size = 0;
std::streamsize written_byte_size = 0;

m_zip_stream.next_in = (byte_buffer_type)buffer_;
m_zip_stream.avail_in = static_cast<uInt>(buffer_size_ * sizeof(char_type));
Expand All @@ -236,7 +236,6 @@ bool basic_gz_ostreambuf<Elem, Tr, ElemA, ByteT, ByteAT>::zip_to_stream(
if (m_err == Z_OK || m_err == Z_STREAM_END)
{
written_byte_size = static_cast<std::streamsize>(m_output_buffer.size()) - m_zip_stream.avail_out;
total_written_byte_size += written_byte_size;

// output buffer is full, dumping to ostream
m_ostream.write((const char_type *) &(m_output_buffer[0]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ class execution_handler_parallel
{
public:
/*!\name Constructors, destructor and assignment
* \brief Instances of this class are not copyable.
* \brief Instances of this class are not copyable and not movable.
* \{
*/
internal_state() = default; //!< Defaulted.
internal_state(internal_state const &) = delete; //!< Deleted.
internal_state(internal_state &&) = default; //!< Defaulted.
internal_state(internal_state &&) = delete; //!< Deleted.
internal_state & operator=(internal_state const &) = delete; //!< Deleted.
internal_state & operator=(internal_state &&) = default; //!< Defaulted.
internal_state & operator=(internal_state &&) = delete; //!< Deleted.

//!\brief Waits for threads to finish.
~internal_state()
Expand Down
12 changes: 10 additions & 2 deletions include/seqan3/core/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,21 @@
# endif // (__GNUC__ > 13)
# endif // SEQAN3_DISABLE_NEWER_COMPILER_DIAGNOSTIC

// ============================================================================
// Compiler support Clang
// ============================================================================

#elif defined(__clang__)
# if __clang_major__ < 17
# error "Only Clang >= 17 is supported."
# endif

// ============================================================================
// Compiler support other
// ============================================================================

#elif !defined(SEQAN3_DISABLE_COMPILER_CHECK)
# error \
"Your compiler is not supported. Currently, only GCC is known to work. You can disable this error by setting -DSEQAN3_DISABLE_COMPILER_CHECK."
# error "Your compiler is not supported. You can disable this error by setting -DSEQAN3_DISABLE_COMPILER_CHECK."
#endif // SEQAN3_COMPILER_IS_GCC

// ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion include/seqan3/io/sam_file/detail/format_sam_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ inline void format_sam_base::read_header(stream_view_type && stream_view,
read_forward_range_field(string_buffer, value);
};

auto print_cerr_of_unspported_tag = [&it](char const * const header_tag, std::array<char, 2> raw_tag)
auto print_cerr_of_unspported_tag = [](char const * const header_tag, std::array<char, 2> raw_tag)
{
std::cerr << "Unsupported SAM header tag in @" << header_tag << ": " << raw_tag[0] << raw_tag[1] << '\n';
};
Expand Down
15 changes: 6 additions & 9 deletions include/seqan3/io/sam_file/format_sam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ class format_sam : protected detail::format_sam_base
* \{
*/
// construction cannot be noexcept because this class has a std::string variable as a quality string buffer.
format_sam() = default; //!< Defaulted.
format_sam(format_sam const &) = default; //!< Defaulted.
format_sam & operator=(format_sam const &) = default; //!< Defaulted.
format_sam(format_sam &&) = default; //!< Defaulted.
format_sam & operator=(format_sam &&) = default; //!< Defaulted.
~format_sam() = default; //!< Defaulted.
format_sam() = default; //!< Defaulted.
format_sam(format_sam const &) = delete; //!< Deleted. Header holds a unique_ptr.
format_sam & operator=(format_sam const &) = delete; //!< Deleted. Header holds a unique_ptr.
format_sam(format_sam &&) = default; //!< Defaulted.
format_sam & operator=(format_sam &&) = default; //!< Defaulted.
~format_sam() = default; //!< Defaulted.

//!\}

Expand Down Expand Up @@ -224,9 +224,6 @@ class format_sam : protected detail::format_sam_base
//!\brief The default header for the alignment format.
sam_file_header<> default_header{};

//!\brief Tracks whether reference information (\@SR tag) were found in the SAM header
bool ref_info_present_in_header{false};

//!\brief A buffer to store a raw record pointing into the stream buffer of the input.
std::array<std::string_view, 11> raw_record{};

Expand Down
Loading