Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: emil-e/rapidcheck
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: swift-nav/rapidcheck
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 14 commits
  • 7 files changed
  • 6 contributors

Commits on Feb 22, 2017

  1. Disable -Werror

    peddie committed Feb 22, 2017
    Copy the full SHA
    00594ac View commit details

Commits on Jan 8, 2018

  1. Implement inRange for floating-point types

    Previously calling `gen::inRange<double>()` wouldn't compile.  This
    commit applies the suggested fix from
    #134 (comment)
    to allow it to build and run.
    peddie committed Jan 8, 2018
    Copy the full SHA
    92fce9f View commit details

Commits on Aug 16, 2020

  1. Merge pull request #1 from swift-nav/in-range-fixup

    Implement `inRange` for floating-point types
    akleeman authored Aug 16, 2020
    Copy the full SHA
    f79c84f View commit details

Commits on Oct 2, 2021

  1. Copy the full SHA
    fec592c View commit details

Commits on Nov 13, 2021

  1. Merge pull request #3 from swift-nav/upstream-master

    Merge upstream master
    jbangelo authored Nov 13, 2021
    Copy the full SHA
    1b7d4dd View commit details

Commits on Dec 8, 2022

  1. Disable ubsan for functions which are throwing errors when used in st…

    …arling-core
    Matt Woodward committed Dec 8, 2022
    Copy the full SHA
    63eee46 View commit details
  2. Protect attributes with preprocessor check for clang

    Matt Woodward committed Dec 8, 2022
    Copy the full SHA
    8a7ecb7 View commit details
  3. Merge pull request #5 from swift-nav/woodfell/disable_ubsan

    Disable specific ubsan checks for a handful of functions
    woodfell authored Dec 8, 2022
    Copy the full SHA
    40f05f8 View commit details

Commits on Dec 9, 2022

  1. Add another ubsan exception

    Matt Woodward committed Dec 9, 2022
    Copy the full SHA
    4a3e753 View commit details

Commits on Dec 10, 2022

  1. Merge pull request #6 from swift-nav/woodfell/add_another_ubsan_excep…

    …tion
    
    Add another ubsan exception
    woodfell authored Dec 10, 2022
    Copy the full SHA
    a79fd09 View commit details

Commits on Jul 12, 2023

  1. Merge pull request #7 from emil-e/master

    Merge upstream master
    woodfell authored Jul 12, 2023
    Copy the full SHA
    b8f11ac View commit details

Commits on Aug 1, 2023

  1. GCC 13.1.X fix (#8)

    RReichert authored Aug 1, 2023
    Copy the full SHA
    97ccd0e View commit details

Commits on Mar 4, 2024

  1. UBSAN protection

    Matt Woodward committed Mar 4, 2024
    Copy the full SHA
    336c5f8 View commit details

Commits on Mar 13, 2024

  1. Copy the full SHA
    b9c6c12 View commit details
8 changes: 7 additions & 1 deletion include/rapidcheck/detail/BitStream.hpp
Original file line number Diff line number Diff line change
@@ -38,7 +38,13 @@ T BitStream<Source>::next(int /*nbits*/, std::true_type) {

template <typename Source>
template <typename T>
T BitStream<Source>::next(int nbits, std::false_type) {
T BitStream<Source>::next(int nbits, std::false_type)
#ifdef __clang__
__attribute__((no_sanitize("implicit-signed-integer-truncation")))
__attribute__((no_sanitize("implicit-integer-sign-change")))
__attribute__((no_sanitize("shift-exponent")))
#endif
{
using SourceType = decltype(m_source.next());
nbits = std::min(nbits, numBits<T>());

2 changes: 2 additions & 0 deletions include/rapidcheck/detail/Results.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <cstdint>

namespace rc {
namespace detail {

6 changes: 5 additions & 1 deletion include/rapidcheck/detail/Utility.h
Original file line number Diff line number Diff line change
@@ -96,7 +96,11 @@ inline uint64_t avalanche(uint64_t x) {
/// Returns a bitmask of the given type with the lowest `nbits` bits set to 1
/// and the rest set to 0.
template <typename T>
constexpr T bitMask(int nbits) {
constexpr T bitMask(int nbits)
#ifdef __clang__
__attribute__((no_sanitize("unsigned-shift-base")))
#endif
{
using UT = typename std::make_unsigned<T>::type;
using UTP = typename std::common_type<UT, unsigned>::type;
// There are two pieces of undefined behavior we're avoiding here,
15 changes: 13 additions & 2 deletions include/rapidcheck/gen/Numeric.hpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
#include "rapidcheck/shrink/Shrink.h"
#include "rapidcheck/gen/Transform.h"
#include "rapidcheck/gen/detail/ScaleInteger.h"
#include <cstring>

namespace rc {
namespace gen {
@@ -88,6 +89,9 @@ struct DefaultArbitrary<bool> {
} // namespace detail

template <typename T>
#if defined(__clang__)
__attribute__((no_sanitize("undefined")))
#endif
Gen<T> inRange(T min, T max) {
return [=](const Random &random, int size) {
if (max <= min) {
@@ -97,9 +101,16 @@ Gen<T> inRange(T min, T max) {
throw GenerationFailure(msg);
}

int64_t i_min = static_cast<int64_t>(min);
Random::Number u_min;
memcpy(&u_min, &i_min, sizeof(u_min));
int64_t i_max = static_cast<int64_t>(max);
Random::Number u_max;
memcpy(&u_max, &i_max, sizeof(u_max));

const auto rangeSize =
detail::scaleInteger(static_cast<Random::Number>(max) -
static_cast<Random::Number>(min) - 1,
detail::scaleInteger(u_max -
u_min - 1,
size) +
1;
const auto value =
31 changes: 30 additions & 1 deletion include/rapidcheck/shrink/Shrink.hpp
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ namespace rc {
namespace shrink {
namespace detail {

template <typename T>
template <typename T, typename Enable = void>
class TowardsSeq {
public:
using UInt = typename std::make_unsigned<T>::type;
@@ -37,6 +37,35 @@ class TowardsSeq {
bool m_down;
};

template <typename T>
class TowardsSeq<
T,
typename std::enable_if<std::is_floating_point<T>::value>::type> {
public:
TowardsSeq(T value, T target)
: m_value(value)
, m_target(target) {}

Maybe<T> operator()() {
if (m_value == m_target) {
return Nothing;
}

T new_value = (m_value / 2) + (m_target / 2);

if (new_value == m_value) {
new_value = m_target;
}

m_value = new_value;
return m_value;
}

private:
T m_value;
T m_target;
};

template <typename Container>
class RemoveChunksSeq {
public:
6 changes: 5 additions & 1 deletion src/Random.cpp
Original file line number Diff line number Diff line change
@@ -67,7 +67,11 @@ void Random::append(bool x) {
m_bitsi++;
}

void Random::mash(Block &output) {
void Random::mash(Block &output)
#ifdef __clang__
__attribute__((no_sanitize("unsigned-shift-base")))
#endif
{
// Input
uint64_t b0 = m_bits;
uint64_t b1 = m_counter;
3 changes: 3 additions & 0 deletions src/gen/detail/ScaleInteger.cpp
Original file line number Diff line number Diff line change
@@ -46,6 +46,9 @@ uint64_t mulDiv(uint64_t a, uint32_t b, uint32_t c) {

} // namespace

#if defined(__clang__)
__attribute__((no_sanitize("undefined")))
#endif
uint64_t scaleInteger(uint64_t x, int size) {
const auto clampedSize = std::min(kNominalSize, size);
return mulDiv(x, clampedSize, kNominalSize);