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
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,14 @@ private static void generateGroupHeaderFunctions(

"SBE_ONE_DEF uint64_t %3$s_sbe_position(const struct %3$s *const codec)\n" +
"{\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" return *codec->position_ptr;\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
"}\n\n" +

"SBE_ONE_DEF bool %3$s_set_sbe_position(struct %3$s *const codec, const uint64_t position)\n" +
Expand All @@ -358,14 +365,28 @@ private static void generateGroupHeaderFunctions(

"SBE_ONE_DEF bool %3$s_has_next(const struct %3$s *const codec)\n" +
"{\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" return codec->index + 1 < codec->count;\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
"}\n\n" +

"SBE_ONE_DEF struct %3$s *%3$s_next(struct %3$s *const codec)\n" +
"{\n" +
" codec->offset = *codec->position_ptr;\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" if (SBE_BOUNDS_CHECK_EXPECT(((codec->offset + codec->block_length) " +
"> codec->buffer_length), false))\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
" {\n" +
" errno = E108;\n" +
" return NULL;\n" +
Expand Down Expand Up @@ -1341,7 +1362,14 @@ private CharSequence generateLoadValue(
{
sb.append(String.format(
" %1$s val;\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" memcpy(&val, codec->buffer + codec->offset + %2$s, sizeof(%1$s));\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif\n" +
" %4$s %3$s(val);",
cTypeName,
offsetStr,
Expand Down Expand Up @@ -1400,7 +1428,14 @@ private CharSequence generateStoreValue(
{
sb.append(String.format(
" %1$s val = %2$s(value);\n" +
" memcpy(codec->buffer + codec->offset + %3$s, &val, sizeof(%1$s));",
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic push\n" +
"#pragma GCC diagnostic ignored \"-Wmaybe-uninitialized\"\n" +
"#endif\n" +
" memcpy(codec->buffer + codec->offset + %3$s, &val, sizeof(%1$s));\n" +
"#if defined(__GNUG__) && !defined(__clang__)\n" +
"#pragma GCC diagnostic pop\n" +
"#endif",
cTypeName,
byteOrderStr,
offsetStr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ private static CharSequence generateGroupProperty(
sb.append(String.format("\n" +
indent + " static SBE_CONSTEXPR std::uint64_t %1$sSinceVersion() SBE_NOEXCEPT\n" +
indent + " {\n" +
indent + " return %2$d;\n" +
indent + " return %2$d;\n" +
indent + " }\n\n" +

indent + " bool %1$sInActingVersion() const SBE_NOEXCEPT\n" +
Expand Down Expand Up @@ -437,11 +437,11 @@ private CharSequence generateVarData(final String className, final List<Token> t
indent + " const char *%1$s()\n" +
indent + " {\n" +
"%2$s" +
indent + " %4$s lengthFieldValue;\n" +
indent + " std::memcpy(&lengthFieldValue, m_buffer + sbePosition(), sizeof(%4$s));\n" +
indent + " const char *fieldPtr = m_buffer + sbePosition() + %3$d;\n" +
indent + " sbePosition(sbePosition() + %3$d + %5$s(lengthFieldValue));\n" +
indent + " return fieldPtr;\n" +
indent + " %4$s lengthFieldValue;\n" +
indent + " std::memcpy(&lengthFieldValue, m_buffer + sbePosition(), sizeof(%4$s));\n" +
indent + " const char *fieldPtr = m_buffer + sbePosition() + %3$d;\n" +
indent + " sbePosition(sbePosition() + %3$d + %5$s(lengthFieldValue));\n" +
indent + " return fieldPtr;\n" +
indent + " }\n",
formatPropertyName(propertyName),
generateTypeFieldNotPresentCondition(token.version(), indent),
Expand Down Expand Up @@ -539,7 +539,7 @@ private CharSequence generateVarData(final String className, final List<Token> t
indent + " {\n" +
indent + " if (str.length() > %6$d)\n" +
indent + " {\n" +
indent + " throw std::runtime_error(\"std::string too long for length type [E109]\");\n" +
indent + " throw std::runtime_error(\"std::string too long for length type [E109]\");\n" +
indent + " }\n" +
indent + " std::uint64_t lengthOfLengthField = %3$d;\n" +
indent + " std::uint64_t lengthPosition = sbePosition();\n" +
Expand Down Expand Up @@ -585,7 +585,7 @@ private void generateVarDataDescriptors(
sb.append(String.format("\n" +
indent + " static SBE_CONSTEXPR std::uint64_t %1$sSinceVersion() SBE_NOEXCEPT\n" +
indent + " {\n" +
indent + " return %2$d;\n" +
indent + " return %2$d;\n" +
indent + " }\n\n" +

indent + " bool %1$sInActingVersion() SBE_NOEXCEPT\n" +
Expand Down Expand Up @@ -1365,7 +1365,7 @@ private CharSequence generateArrayProperty(
indent + " {\n" +
indent + " if (length > %2$d)\n" +
indent + " {\n" +
indent + " throw std::runtime_error(\"length too large for get%1$s [E106]\");\n" +
indent + " throw std::runtime_error(\"length too large for get%1$s [E106]\");\n" +
indent + " }\n\n" +

"%3$s" +
Expand Down Expand Up @@ -1431,7 +1431,7 @@ private CharSequence generateArrayProperty(
indent + " const size_t srcLength = str.length();\n" +
indent + " if (srcLength > %4$d)\n" +
indent + " {\n" +
indent + " throw std::runtime_error(\"string too large for put%2$s [E106]\");\n" +
indent + " throw std::runtime_error(\"string too large for put%2$s [E106]\");\n" +
indent + " }\n\n" +

indent + " size_t length = srcLength < %4$d ? srcLength : %4$d;\n" +
Expand All @@ -1449,7 +1449,7 @@ private CharSequence generateArrayProperty(
indent + " const size_t srcLength = str.length();\n" +
indent + " if (srcLength > %4$d)\n" +
indent + " {\n" +
indent + " throw std::runtime_error(\"string too large for put%2$s [E106]\");\n" +
indent + " throw std::runtime_error(\"string too large for put%2$s [E106]\");\n" +
indent + " }\n\n" +

indent + " size_t length = srcLength < %4$d ? srcLength : %4$d;\n" +
Expand Down Expand Up @@ -1791,8 +1791,8 @@ private CharSequence generateMessageFlyweightCode(final String className, final
" }\n\n" +

" %10$s &wrapForDecode(\n" +
" char *buffer, const std::uint64_t offset, const std::uint64_t actingBlockLength,\n" +
" const std::uint64_t actingVersion, const std::uint64_t bufferLength)\n" +
" char *buffer, const std::uint64_t offset, const std::uint64_t actingBlockLength,\n" +
" const std::uint64_t actingVersion, const std::uint64_t bufferLength)\n" +
" {\n" +
" return *this = %10$s(buffer, offset, bufferLength, actingBlockLength, actingVersion);\n" +
" }\n\n" +
Expand Down Expand Up @@ -1916,7 +1916,7 @@ private void generateFieldCommonMethods(
sb.append(String.format("\n" +
indent + " static SBE_CONSTEXPR std::uint64_t %1$sSinceVersion() SBE_NOEXCEPT\n" +
indent + " {\n" +
indent + " return %2$d;\n" +
indent + " return %2$d;\n" +
indent + " }\n\n" +

indent + " bool %1$sInActingVersion() SBE_NOEXCEPT\n" +
Expand All @@ -1936,7 +1936,7 @@ private void generateFieldCommonMethods(
sb.append(String.format("\n" +
indent + " static SBE_CONSTEXPR std::size_t %1$sEncodingOffset() SBE_NOEXCEPT\n" +
indent + " {\n" +
indent + " return %2$d;\n" +
indent + " return %2$d;\n" +
indent + " }\n",
propertyName,
encodingToken.offset()));
Expand Down
3 changes: 3 additions & 0 deletions sbe-tool/src/test/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function(sbe_test name)
PRIVATE ${GTEST_SOURCE_DIR}/googletest/include
PRIVATE ${C_CODEC_TARGET_DIR}
)
target_compile_options("C${name}" PRIVATE $<$<CXX_COMPILER_ID:AppleClang>:-Werror>)
target_compile_options("C${name}" PRIVATE $<$<CXX_COMPILER_ID:Clang>:-Werror>)
target_compile_options("C${name}" PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Werror>)
target_link_libraries("C${name}" ${GTEST_LIBS} ${CMAKE_THREAD_LIBS_INIT})
add_test(NAME C${name} COMMAND C${name} WORKING_DIRECTORY ${C_CODEC_TARGET_DIR})
add_dependencies(C${name} gtest)
Expand Down
3 changes: 3 additions & 0 deletions sbe-tool/src/test/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function(sbe_test name)
PRIVATE ${GTEST_SOURCE_DIR}/googletest/include
PRIVATE ${CXX_CODEC_TARGET_DIR}
)
target_compile_options("${name}" PRIVATE $<$<CXX_COMPILER_ID:AppleClang>:-Werror>)
target_compile_options("${name}" PRIVATE $<$<CXX_COMPILER_ID:Clang>:-Werror>)
target_compile_options("${name}" PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Werror>)
target_link_libraries("${name}" sbe ${GTEST_LIBS} ${CMAKE_THREAD_LIBS_INIT})
add_test(NAME ${name} COMMAND ${name} WORKING_DIRECTORY ${CXX_CODEC_TARGET_DIR})
add_dependencies(${name} gtest)
Expand Down