💚 add trait for 128 bit integers
This commit is contained in:
parent
e3aace6dac
commit
0f1f5052bf
6
Makefile
6
Makefile
@ -468,7 +468,7 @@ cppcheck:
|
||||
clang_analyze:
|
||||
rm -fr clang_analyze_build
|
||||
mkdir clang_analyze_build
|
||||
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On
|
||||
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On -DJSON_MultipleHeaders=On
|
||||
cd clang_analyze_build ; \
|
||||
$(COMPILER_DIR)/scan-build \
|
||||
-enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \
|
||||
@ -490,7 +490,7 @@ clang_tidy:
|
||||
pvs_studio:
|
||||
rm -fr pvs_studio_build
|
||||
mkdir pvs_studio_build
|
||||
cd pvs_studio_build ; cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=On
|
||||
cd pvs_studio_build ; cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DJSON_MultipleHeaders=On
|
||||
cd pvs_studio_build ; pvs-studio-analyzer analyze -j 10
|
||||
cd pvs_studio_build ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
|
||||
open pvs_studio_build/pvs/index.html
|
||||
@ -499,7 +499,7 @@ pvs_studio:
|
||||
infer:
|
||||
rm -fr infer_build
|
||||
mkdir infer_build
|
||||
cd infer_build ; infer compile -- cmake .. ; infer run -- make -j 4
|
||||
cd infer_build ; infer compile -- cmake .. -DJSON_MultipleHeaders=On ; infer run -- make -j 4
|
||||
|
||||
# call OCLint <http://oclint.org> static analyzer
|
||||
oclint:
|
||||
|
@ -353,6 +353,17 @@ struct is_compatible_integer_type_impl <
|
||||
RealLimits::is_signed == CompatibleLimits::is_signed;
|
||||
};
|
||||
|
||||
// second version for 128 bit integers that fail std::is_integral test
|
||||
template<typename RealIntegerType, typename CompatibleNumberIntegerType>
|
||||
struct is_compatible_integer_type_impl < RealIntegerType, CompatibleNumberIntegerType,
|
||||
enable_if_t < std::is_same<RealIntegerType, CompatibleNumberIntegerType>::value&&
|
||||
!std::is_integral<CompatibleNumberIntegerType>::value&&
|
||||
(std::is_unsigned<RealIntegerType>::value&& std::is_convertible<std::uint64_t, RealIntegerType>::value || !std::is_unsigned<RealIntegerType>::value&& std::is_convertible<std::int64_t, RealIntegerType>::value)&&
|
||||
!is_64_bit<RealIntegerType>::value >>
|
||||
{
|
||||
static constexpr auto value = true;
|
||||
};
|
||||
|
||||
template<typename RealIntegerType, typename CompatibleNumberIntegerType>
|
||||
struct is_compatible_integer_type
|
||||
: is_compatible_integer_type_impl<RealIntegerType,
|
||||
|
@ -3168,6 +3168,17 @@ struct is_compatible_integer_type_impl <
|
||||
RealLimits::is_signed == CompatibleLimits::is_signed;
|
||||
};
|
||||
|
||||
// second version for 128 bit integers that fail std::is_integral test
|
||||
template<typename RealIntegerType, typename CompatibleNumberIntegerType>
|
||||
struct is_compatible_integer_type_impl < RealIntegerType, CompatibleNumberIntegerType,
|
||||
enable_if_t < std::is_same<RealIntegerType, CompatibleNumberIntegerType>::value&&
|
||||
!std::is_integral<CompatibleNumberIntegerType>::value&&
|
||||
(std::is_unsigned<RealIntegerType>::value&& std::is_convertible<std::uint64_t, RealIntegerType>::value || !std::is_unsigned<RealIntegerType>::value&& std::is_convertible<std::int64_t, RealIntegerType>::value)&&
|
||||
!is_64_bit<RealIntegerType>::value >>
|
||||
{
|
||||
static constexpr auto value = true;
|
||||
};
|
||||
|
||||
template<typename RealIntegerType, typename CompatibleNumberIntegerType>
|
||||
struct is_compatible_integer_type
|
||||
: is_compatible_integer_type_impl<RealIntegerType,
|
||||
|
@ -101,17 +101,6 @@ TEST_CASE("Alternative number types")
|
||||
|
||||
// 128-bit arithmetic does not work with sanitizers
|
||||
#if defined(__SIZEOF_INT128__) && !defined(__SANITIZE_ADDRESS__)
|
||||
SECTION("type traits")
|
||||
{
|
||||
CHECK(std::is_integral<__int128_t>::value);
|
||||
CHECK(std::is_integral<__uint128_t>::value);
|
||||
CHECK(std::numeric_limits<__int128_t>::is_integer);
|
||||
CHECK(std::numeric_limits<__uint128_t>::is_integer);
|
||||
CHECK(std::is_convertible<std::int64_t, __int128_t>::value);
|
||||
CHECK(std::is_convertible<std::uint64_t, __uint128_t>::value);
|
||||
}
|
||||
|
||||
/*
|
||||
SECTION("128 bit integers")
|
||||
{
|
||||
using json128 = nlohmann::basic_json<std::map, std::vector, std::string, bool, __int128_t, __uint128_t>;
|
||||
@ -136,6 +125,5 @@ TEST_CASE("Alternative number types")
|
||||
CHECK(json128::parse(j_signed_min.dump()) == j_signed_min);
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user