Skip to content
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
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
Language: Cpp
Standard: Latest
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
Expand Down Expand Up @@ -117,7 +118,6 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
AttributeMacros: [SQLITE_ORM_CPP_LIKELY, SQLITE_ORM_CPP_UNLIKELY, SQLITE_ORM_EXPORT]
StatementMacros:
- __pragma
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clang-format-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: clang-format lint
uses: d-griet/clang-format-lint-action@99a106be2f3f1a92d9783ea7c744fde62d8ce1fa
uses: DoozyX/clang-format-lint-action@8b8bbdd8669eec54682e720ebe2fb19d9387fdb0
with:
clangFormatVersion: 19
clangFormatVersion: 20
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_VERBOSE_MAKEFILE ON)

message(STATUS "Configuring ${PROJECT_NAME} ${sqlite_orm_VERSION}")
message(STATUS "Configuring ${PROJECT_NAME} ${sqlite_orm_VERSION} for ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

Expand Down
10 changes: 5 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ environment:
cmake_build_parallel: ""

- job_name: clang, C++17
appveyor_build_worker_image: Ubuntu
appveyor_build_worker_image: Ubuntu1804
CC: clang
CXX: clang++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
# clang was stuck with a parallel build
cmake_build_parallel: ""

- job_name: gcc, C++17
appveyor_build_worker_image: Ubuntu
appveyor_build_worker_image: Ubuntu1804
CC: gcc
CXX: g++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
cmake_build_parallel: ""

- job_name: clang, C++20 (with examples)
appveyor_build_worker_image: Ubuntu
appveyor_build_worker_image: Ubuntu1804
CC: clang
CXX: clang++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"
Expand All @@ -65,7 +65,7 @@ environment:
cmake_build_examples: "-DBUILD_EXAMPLES=ON"

- job_name: gcc, C++20
appveyor_build_worker_image: Ubuntu
appveyor_build_worker_image: Ubuntu1804
CC: gcc
CXX: g++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"
Expand Down Expand Up @@ -131,7 +131,7 @@ for:
# Linux
matrix:
only:
- appveyor_build_worker_image: Ubuntu
- appveyor_build_worker_image: Ubuntu1804
- appveyor_build_worker_image: Ubuntu2204
init:
- |-
Expand Down
8 changes: 4 additions & 4 deletions dev/alias.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
*/
template<class T>
internal::alias_holder<T> get() {
static_assert(internal::is_column_alias_v<T>, "");
static_assert(internal::is_column_alias_v<T>);
return {};
}

Expand Down Expand Up @@ -469,7 +469,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
* constexpr orm_table_alias auto z_alias = "z"_alias.for_<User>();
*/
template<internal::cstring_literal name>
[[nodiscard]] consteval auto operator"" _alias() {
[[nodiscard]] consteval auto operator""_alias() {
return internal::explode_into<internal::recordset_alias_builder, name>(
std::make_index_sequence<name.size()>{});
}
Expand All @@ -479,7 +479,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
* E.g. "a"_col, "b"_col
*/
template<internal::cstring_literal name>
[[nodiscard]] consteval auto operator"" _col() {
[[nodiscard]] consteval auto operator""_col() {
return internal::explode_into<internal::column_alias, name>(std::make_index_sequence<name.size()>{});
}
}
Expand All @@ -492,7 +492,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
* E.g. 1_colalias, 2_colalias
*/
template<char... Chars>
[[nodiscard]] SQLITE_ORM_CONSTEVAL auto operator"" _colalias() {
[[nodiscard]] SQLITE_ORM_CONSTEVAL auto operator""_colalias() {
// numeric identifiers are used for automatically assigning implicit aliases to unaliased column expressions,
// which start at "1".
static_assert(std::array{Chars...}[0] > '0');
Expand Down
2 changes: 1 addition & 1 deletion dev/cte_column_names_collector.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace sqlite_orm {
// 3. fill in blanks with numerical column identifiers
{
#ifdef SQLITE_ORM_INITSTMT_RANGE_BASED_FOR_SUPPORTED
for (size_t n = 1; std::string & name: columnNames) {
for (size_t n = 1; std::string& name: columnNames) {
if (name.empty()) {
name = std::to_string(n);
}
Expand Down
4 changes: 2 additions & 2 deletions dev/cte_moniker.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
* E.g. 1_ctealias, 2_ctealias
*/
template<char... Chars>
[[nodiscard]] SQLITE_ORM_CONSTEVAL auto operator"" _ctealias() {
[[nodiscard]] SQLITE_ORM_CONSTEVAL auto operator""_ctealias() {
return internal::cte_moniker<Chars...>{};
}

Expand All @@ -86,7 +86,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
* E.g. "1"_cte, "2"_cte
*/
template<internal::cstring_literal moniker>
[[nodiscard]] consteval auto operator"" _cte() {
[[nodiscard]] consteval auto operator""_cte() {
return internal::explode_into<internal::cte_moniker, moniker>(std::make_index_sequence<moniker.size()>{});
}
#endif
Expand Down
3 changes: 1 addition & 2 deletions dev/cte_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ namespace sqlite_orm {

template<class Mapper, class... Cs>
cte_table<Mapper, Cs...> make_cte_table(std::string name, Cs... args) {
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(args)...)});
return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(args)...)};
}

// aliased column expressions, explicit or implicitly numbered
Expand Down
2 changes: 1 addition & 1 deletion dev/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
* auto rows = storage.select(equal_to_int_3_f(1, 1));
*/
template<internal::quoted_function_builder builder>
[[nodiscard]] consteval auto operator"" _scalar() {
[[nodiscard]] consteval auto operator""_scalar() {
return builder;
}
}
Expand Down
6 changes: 6 additions & 0 deletions dev/functional/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#include <version>
#endif

#if !defined(SQLITE_ORM_MS_MSVC) || (_MSC_VER >= 1920)
#define SQLITE_ORM_SWITCH_MAYBE_UNUSED [[maybe_unused]]
#else
#define SQLITE_ORM_SWITCH_MAYBE_UNUSED
#endif

#if __cpp_lib_constexpr_functional >= 201907L
#define SQLITE_ORM_CONSTEXPR_CPP20 constexpr
#else
Expand Down
2 changes: 1 addition & 1 deletion dev/functional/cxx_check_prerequisites.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#endif

#if (!defined(__has_include)) || \
((__cpp_noexcept_function_type < 201510L) || \
((__cpp_static_assert < 201411L) || (__cpp_noexcept_function_type < 201510L) || \
(__cpp_fold_expressions < 201603L || __cpp_constexpr < 201603L || __cpp_aggregate_bases < 201603L || \
__cpp_range_based_for < 201603L) || \
(__cpp_if_constexpr < 201606L || __cpp_inline_variables < 201606L || __cpp_structured_bindings < 201606L) || \
Expand Down
27 changes: 12 additions & 15 deletions dev/functional/cxx_compiler_quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,32 @@
SQLITE_ORM_DO_PRAGMA(clang diagnostic ignored warnoption) \
__VA_ARGS__ \
SQLITE_ORM_DO_PRAGMA(clang diagnostic pop)

#else
#define SQLITE_ORM_CLANG_SUPPRESS(warnoption, ...) __VA_ARGS__
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#define SQLITE_ORM_MS_MSVC
#endif

#if defined(__clang__) && defined(_MSC_VER)
#define SQLITE_ORM_CLANG_MSVC
#endif

#ifdef SQLITE_ORM_MS_MSVC
#define SQLITE_ORM_DO_PRAGMA(...) __pragma(__VA_ARGS__)
#endif

#if defined(_MSC_VER) && !defined(__clang__)
#ifdef SQLITE_ORM_MS_MSVC
#define SQLITE_ORM_MSVC_SUPPRESS(warncode, ...) SQLITE_ORM_DO_PRAGMA(warning(suppress : warncode))
#else
#define SQLITE_ORM_MSVC_SUPPRESS(warcode, ...) __VA_ARGS__
#define SQLITE_ORM_MSVC_SUPPRESS(warncode, ...) __VA_ARGS__
#endif

// clang has the bad habit of diagnosing missing brace-init-lists when constructing aggregates with base classes.
// This is a false positive, since the C++ standard is quite clear that braces for nested or base objects may be omitted,
// see https://en.cppreference.com/w/cpp/language/aggregate_initialization:
// "The braces around the nested initializer lists may be elided (omitted),
// in which case as many initializer clauses as necessary are used to initialize every member or element of the corresponding subaggregate,
// and the subsequent initializer clauses are used to initialize the following members of the object."
// In this sense clang should only warn about missing field initializers.
// Because we know what we are doing, we suppress the diagnostic message
#define SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(...) SQLITE_ORM_CLANG_SUPPRESS("-Wmissing-braces", __VA_ARGS__)

// msvc has the bad habit of diagnosing overalignment of types with an explicit alignment specifier.
#define SQLITE_ORM_MSVC_SUPPRESS_OVERALIGNMENT(...) SQLITE_ORM_MSVC_SUPPRESS(4324, __VA_ARGS__)

#if defined(_MSC_VER) && (_MSC_VER < 1920)
#if defined(SQLITE_ORM_MS_MSVC) && (_MSC_VER < 1920)
#define SQLITE_ORM_BROKEN_VARIADIC_PACK_EXPANSION
// Type replacement may fail if an alias template has a non-type template parameter from a dependent expression in it,
// `e.g. template<class T> using is_something = std::bool_constant<is_something_v<T>>;`
Expand All @@ -59,7 +56,7 @@
// In these cases we have to use helper structures to break down the type alias.
// Note that the detection of specific compilers is so complicated because some compilers emulate other compilers,
// so we simply exclude all compilers that do not support C++20, even though this test is actually inaccurate.
#if (defined(_MSC_VER) && (_MSC_VER < 1920)) || (!defined(_MSC_VER) && (__cplusplus < 202002L))
#if (defined(SQLITE_ORM_MS_MSVC) && (_MSC_VER < 1920)) || (!defined(SQLITE_ORM_MS_MSVC) && (__cplusplus < 202002L))
#define SQLITE_ORM_BROKEN_ALIAS_TEMPLATE_DEPENDENT_EXPR_SFINAE
#endif

Expand Down
15 changes: 14 additions & 1 deletion dev/functional/start_macros.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
#pragma once

// Clang has the annoying habit of warning about future C++ features that it claims to support through a feature macro.
#ifdef __clang__
#pragma clang diagnostic push
// Clang has the annoying habit of warning about future C++ features that it claims to support through a feature macro.
#pragma clang diagnostic ignored "-Wc++20-extensions"
#pragma clang diagnostic ignored "-Wc++23-extensions"
#pragma clang diagnostic ignored "-Wc++26-extensions"

// clang has the bad habit of diagnosing missing brace-init-lists when constructing aggregates with base classes.
// This is a false positive, since the C++ standard is quite clear that braces for nested or base objects may be omitted,
// see https://en.cppreference.com/w/cpp/language/aggregate_initialization:
// "The braces around the nested initializer lists may be elided (omitted),
// in which case as many initializer clauses as necessary are used to initialize every member or element of the corresponding subaggregate,
// and the subsequent initializer clauses are used to initialize the following members of the object."
// In this sense clang should only warn about missing field initializers.
// Because we know what we are doing, we suppress the diagnostic message
#pragma clang diagnostic ignored "-Wmissing-braces"

// Unused lambda captures are common in generic code that involves `if contexpr` or `this`-capture.
#pragma clang diagnostic ignored "-Wunused-lambda-capture"
#endif

#if defined(_MSC_VER)
Expand Down
2 changes: 1 addition & 1 deletion dev/pointer_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
inline namespace literals {
template<internal::cstring_literal tag>
[[nodiscard]] consteval auto operator"" _pointer_type() {
[[nodiscard]] consteval auto operator""_pointer_type() {
return internal::explode_into<internal::pointer_type, tag>(std::make_index_sequence<tag.size()>{});
}
}
Expand Down
10 changes: 10 additions & 0 deletions dev/prepared_statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ namespace sqlite_orm {
#if SQLITE_VERSION_NUMBER >= 3014000
std::string expanded_sql() const {
// note: must check return value due to SQLITE_OMIT_TRACE
#ifndef SQLITE_ORM_CLANG_MSVC
using char_ptr = std::unique_ptr<char[], std::integral_constant<decltype(&sqlite3_free), sqlite3_free>>;
#else
struct sqlite3_memory_deleter {
SQLITE_ORM_STATIC_CALLOP void operator()(void* mem) SQLITE_ORM_OR_CONST_CALLOP noexcept {
sqlite3_free(mem);
}
};
using char_ptr = std::unique_ptr<char[], sqlite3_memory_deleter>;
#endif

if (char_ptr sql{sqlite3_expanded_sql(this->stmt)}) {
return sql.get();
} else {
Expand Down
12 changes: 4 additions & 8 deletions dev/schema/column.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ namespace sqlite_orm {

// attention: do not use `std::make_tuple()` for constructing the tuple member `[[no_unique_address]] column_constraints::constraints`,
// as this will lead to UB with Clang on MinGW!
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), memberPointer, {}, std::tuple<Op...>{std::move(constraints)...}});
return {std::move(name), memberPointer, {}, std::tuple<Op...>{std::move(constraints)...}};
}
#endif
}
Expand All @@ -193,8 +192,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {

// attention: do not use `std::make_tuple()` for constructing the tuple member `[[no_unique_address]] column_constraints::constraints`,
// as this will lead to UB with Clang on MinGW!
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), memberPointer, {}, std::tuple<Op...>{std::move(constraints)...}});
return {std::move(name), memberPointer, {}, std::tuple<Op...>{std::move(constraints)...}};
}

/**
Expand All @@ -212,8 +210,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {

// attention: do not use `std::make_tuple()` for constructing the tuple member `[[no_unique_address]] column_constraints::constraints`,
// as this will lead to UB with Clang on MinGW!
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), getter, setter, std::tuple<Op...>{std::move(constraints)...}});
return {std::move(name), getter, setter, std::tuple<Op...>{std::move(constraints)...}};
}

/**
Expand All @@ -231,7 +228,6 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {

// attention: do not use `std::make_tuple()` for constructing the tuple member `[[no_unique_address]] column_constraints::constraints`,
// as this will lead to UB with Clang on MinGW!
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), getter, setter, std::tuple<Op...>{std::move(constraints)...}});
return {std::move(name), getter, setter, std::tuple<Op...>{std::move(constraints)...}};
}
}
9 changes: 3 additions & 6 deletions dev/schema/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
using cols_tuple = std::tuple<Cols...>;
static_assert(internal::count_tuple<cols_tuple, internal::is_where>::value <= 1,
"amount of where arguments can be 0 or 1");
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), false, std::make_tuple(internal::make_indexed_column(std::move(cols))...)});
return {std::move(name), false, std::make_tuple(internal::make_indexed_column(std::move(cols))...)};
}

template<class... Cols>
Expand All @@ -48,8 +47,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
using cols_tuple = std::tuple<Cols...>;
static_assert(internal::count_tuple<cols_tuple, internal::is_where>::value <= 1,
"amount of where arguments can be 0 or 1");
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), false, std::make_tuple(internal::make_indexed_column(std::move(cols))...)});
return {std::move(name), false, std::make_tuple(internal::make_indexed_column(std::move(cols))...)};
}

template<class... Cols>
Expand All @@ -59,7 +57,6 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
using cols_tuple = std::tuple<Cols...>;
static_assert(internal::count_tuple<cols_tuple, internal::is_where>::value <= 1,
"amount of where arguments can be 0 or 1");
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), true, std::make_tuple(internal::make_indexed_column(std::move(cols))...)});
return {std::move(name), true, std::make_tuple(internal::make_indexed_column(std::move(cols))...)};
}
}
6 changes: 2 additions & 4 deletions dev/schema/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
static_assert(polyfill::conjunction_v<internal::is_base_table_element_or_constraint<Cs>...>,
"Incorrect table elements or constraints");

SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(definition)...)});
return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(definition)...)};
}

/**
Expand All @@ -145,8 +144,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {
static_assert(polyfill::conjunction_v<internal::is_base_table_element_or_constraint<Cs>...>,
"Incorrect table elements or constraints");

SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(definition)...)});
return {std::move(name), std::make_tuple<Cs...>(std::forward<Cs>(definition)...)};
}

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
Expand Down
3 changes: 1 addition & 2 deletions dev/schema/triggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ SQLITE_ORM_EXPORT namespace sqlite_orm {

template<class T, class... S>
internal::trigger_t<T, S...> make_trigger(std::string name, const internal::partial_trigger_t<T, S...>& part) {
SQLITE_ORM_CLANG_SUPPRESS_MISSING_BRACES(
return {std::move(name), std::move(part.base), std::move(part.statements)});
return {std::move(name), std::move(part.base), std::move(part.statements)};
}

inline internal::trigger_timing_t before() {
Expand Down
Loading