Skip to content

Commit

Permalink
Run LLVM sanitizers on CI
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Feb 9, 2024
1 parent e7e5c06 commit 377fcd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ jobs:
# cc: gcc
# cxx: g++
- os: windows-latest
# TODO: Enable sanitizers

# Sanitizers
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
options: -DJSONBINPACK_ADDRESS_SANITIZER:BOOL=ON
- os: ubuntu-latest
cc: clang
cxx: clang++
type: static
options: -DJSONBINPACK_UNDEFINED_SANITIZER:BOOL=ON

runs-on: ${{ matrix.platform.os }}
env:
Expand Down Expand Up @@ -64,6 +75,7 @@ jobs:
-DJSONBINPACK_DOCS:BOOL=OFF
-DBUILD_SHARED_LIBS:BOOL=OFF
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON
${{ matrix.platform.options }}
- run: cmake --build ./build --config Release --target clang_format_test
- run: cmake --build ./build --config Release --parallel 4
- run: >
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/include/sourcemeta/jsonbinpack/runtime_varint.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ auto varint_encode(std::basic_ostream<CharT, Traits> &stream,
std::uint64_t accumulator = value;

while (accumulator > LEAST_SIGNIFICANT_BITS) {
stream.put(static_cast<std::uint8_t>(
(accumulator & LEAST_SIGNIFICANT_BITS) | MOST_SIGNIFICANT_BIT));
stream.put(static_cast<CharT>((accumulator & LEAST_SIGNIFICANT_BITS) |
MOST_SIGNIFICANT_BIT));
accumulator >>= SHIFT;
}

stream.put(static_cast<std::uint8_t>(accumulator));
stream.put(static_cast<CharT>(accumulator));
return stream;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ constexpr auto zigzag_encode(const std::int64_t value) noexcept
return value * 2;
}

return (std::abs(value) * 2) - 1;
return (static_cast<std::uint64_t>(std::abs(value)) * 2) - 1;
}

constexpr auto zigzag_decode(const std::uint64_t value) noexcept
Expand Down

0 comments on commit 377fcd7

Please sign in to comment.