-
Notifications
You must be signed in to change notification settings - Fork 1
feature/update clang format and tidy #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
StephanKa
merged 8 commits into
Zuehlke:main
from
StephanKa:feature/update-clang-format-and-tidy
May 31, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
84b8080
update clang-format and clang-tidy files
StephanKa 9daaecd
update files with new formatting
StephanKa 18c392e
format CMakeLists.txt to have consistent style
StephanKa 738b81b
Merge branch 'main' into feature/update-clang-format-and-tidy
StephanKa ac9c4c3
formatted crow
StephanKa e92d650
replaced std::cout with fmt::print
StephanKa c963743
added missing includes
StephanKa 8094129
removed WarningAsErrors
StephanKa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,18 @@ | ||
| --- | ||
| Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm*' | ||
| WarningsAsErrors: '*' | ||
| Checks: "*, | ||
| -abseil-*, | ||
| -altera-*, | ||
| -android-*, | ||
| -fuchsia-*, | ||
| -google-*, | ||
| -llvm*, | ||
| -modernize-use-trailing-return-type, | ||
| -zircon-*, | ||
| -readability-else-after-return, | ||
| -readability-static-accessed-through-instance, | ||
| -readability-avoid-const-params-in-decls, | ||
| -cppcoreguidelines-non-private-member-variables-in-classes, | ||
| -misc-non-private-member-variables-in-classes, | ||
| " | ||
| HeaderFilterRegex: '' | ||
| FormatStyle: none | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,91 +1,90 @@ | ||
| cmake_minimum_required(VERSION 3.15) | ||
| CMAKE_MINIMUM_REQUIRED(VERSION 3.15) | ||
|
|
||
| # Set the project name to your project name, my project isn't very descriptive | ||
| project(myproject | ||
| PROJECT(myproject | ||
| LANGUAGES CXX | ||
| VERSION 0.0.1) | ||
|
|
||
| include(cmake/StandardProjectSettings.cmake) | ||
| include(cmake/PreventInSourceBuilds.cmake) | ||
| include(cmake/CodeFormat.cmake) | ||
| INCLUDE(cmake/StandardProjectSettings.cmake) | ||
| INCLUDE(cmake/PreventInSourceBuilds.cmake) | ||
| INCLUDE(cmake/CodeFormat.cmake) | ||
|
|
||
| execute_process( | ||
| EXECUTE_PROCESS( | ||
| COMMAND git log -1 --format=%h | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} | ||
| OUTPUT_VARIABLE GIT_HASH | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
|
|
||
| configure_file("templates/version.hpp.in" "${CMAKE_BINARY_DIR}/generated/include/version.hpp" ESCAPE_QUOTES) | ||
| CONFIGURE_FILE("templates/version.hpp.in" "${CMAKE_BINARY_DIR}/generated/include/version.hpp" ESCAPE_QUOTES) | ||
|
|
||
| # Link this 'library' to set the c++ standard / compile-time options requested | ||
| add_library(project_options INTERFACE) | ||
| target_compile_features(project_options INTERFACE cxx_std_17) | ||
| ADD_LIBRARY(project_options INTERFACE) | ||
| TARGET_COMPILE_FEATURES(project_options INTERFACE cxx_std_17) | ||
|
|
||
| if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") | ||
| option(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF) | ||
| if(ENABLE_BUILD_WITH_TIME_TRACE) | ||
| target_compile_options(project_options INTERFACE -ftime-trace) | ||
| endif() | ||
| endif() | ||
| IF(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") | ||
| OPTION(ENABLE_BUILD_WITH_TIME_TRACE "Enable -ftime-trace to generate time tracing .json files on clang" OFF) | ||
| IF(ENABLE_BUILD_WITH_TIME_TRACE) | ||
| TARGET_COMPILE_OPTIONS(project_options INTERFACE -ftime-trace) | ||
| ENDIF() | ||
| ENDIF() | ||
|
|
||
| # Link this 'library' to use the warnings specified in CompilerWarnings.cmake | ||
| add_library(project_warnings INTERFACE) | ||
| ADD_LIBRARY(project_warnings INTERFACE) | ||
|
|
||
| # enable cache system | ||
| include(cmake/Cache.cmake) | ||
| INCLUDE(cmake/Cache.cmake) | ||
|
|
||
| # standard compiler warnings | ||
| include(cmake/CompilerWarnings.cmake) | ||
| set_project_warnings(project_warnings) | ||
| INCLUDE(cmake/CompilerWarnings.cmake) | ||
| SET_PROJECT_WARNINGS(project_warnings) | ||
|
|
||
| # sanitizer options if supported by compiler | ||
| include(cmake/Sanitizers.cmake) | ||
| enable_sanitizers(project_options) | ||
| INCLUDE(cmake/Sanitizers.cmake) | ||
| ENABLE_SANITIZERS(project_options) | ||
|
|
||
| # enable doxygen | ||
| include(cmake/Doxygen.cmake) | ||
| enable_doxygen() | ||
| INCLUDE(cmake/Doxygen.cmake) | ||
| ENABLE_DOXYGEN() | ||
|
|
||
| # allow for static analysis options | ||
| include(cmake/StaticAnalyzers.cmake) | ||
| INCLUDE(cmake/StaticAnalyzers.cmake) | ||
|
|
||
| option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) | ||
| option(ENABLE_TESTING "Enable Test Builds" ON) | ||
| option(ENABLE_FUZZING "Enable Fuzzing Builds" OFF) | ||
| OPTION(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) | ||
| OPTION(ENABLE_TESTING "Enable Test Builds" ON) | ||
| OPTION(ENABLE_FUZZING "Enable Fuzzing Builds" OFF) | ||
|
|
||
| # Very basic PCH example | ||
| option(ENABLE_PCH "Enable Precompiled Headers" OFF) | ||
| if(ENABLE_PCH) | ||
| # This sets a global PCH parameter, each project will build its own PCH, which is a good idea if any #define's change | ||
| # | ||
| # consider breaking this out per project as necessary | ||
| target_precompile_headers( | ||
| project_options | ||
| INTERFACE | ||
| <vector> | ||
| <string> | ||
| <map> | ||
| <utility>) | ||
| endif() | ||
| OPTION(ENABLE_PCH "Enable Precompiled Headers" OFF) | ||
| IF(ENABLE_PCH) | ||
| # This sets a global PCH parameter, each project will build its own PCH, which is a good idea if any #define's change | ||
| # | ||
| # consider breaking this out per project as necessary | ||
| TARGET_PRECOMPILE_HEADERS( | ||
| project_options | ||
| INTERFACE | ||
| <vector> | ||
| <string> | ||
| <map> | ||
| <utility>) | ||
| ENDIF() | ||
|
|
||
| # Set up some extra Conan dependencies based on our needs before loading Conan | ||
| set(CONAN_EXTRA_REQUIRES "") | ||
| set(CONAN_EXTRA_OPTIONS "") | ||
| SET(CONAN_EXTRA_REQUIRES "") | ||
| SET(CONAN_EXTRA_OPTIONS "") | ||
|
|
||
| include(cmake/Conan.cmake) | ||
| run_conan() | ||
| INCLUDE(cmake/Conan.cmake) | ||
| RUN_CONAN() | ||
|
|
||
| if(ENABLE_TESTING) | ||
| enable_testing() | ||
| message("Building Tests. Be sure to check out test/constexpr_tests for constexpr testing") | ||
| add_subdirectory(test) | ||
| endif() | ||
| IF(ENABLE_TESTING) | ||
| ENABLE_TESTING() | ||
| MESSAGE("Building Tests. Be sure to check out test/constexpr_tests for constexpr testing") | ||
| ADD_SUBDIRECTORY(test) | ||
| ENDIF() | ||
|
|
||
| if(ENABLE_FUZZING) | ||
| message("Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html") | ||
| add_subdirectory(fuzz_test) | ||
| endif() | ||
|
|
||
| add_subdirectory(src) | ||
| IF(ENABLE_FUZZING) | ||
| MESSAGE("Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html") | ||
| ADD_SUBDIRECTORY(fuzz_test) | ||
| ENDIF() | ||
|
|
||
| ADD_SUBDIRECTORY(src) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,19 @@ | ||
| # A fuzz test runs until it finds an error. This particular one is going to rely on libFuzzer. | ||
| # | ||
|
|
||
| add_executable(fuzz_tester fuzz_tester.cpp) | ||
| target_link_libraries( | ||
| fuzz_tester | ||
| PRIVATE project_options | ||
| project_warnings | ||
| CONAN_PKG::fmt | ||
| -coverage | ||
| -fsanitize=fuzzer,undefined,address) | ||
| target_compile_options(fuzz_tester PRIVATE -fsanitize=fuzzer,undefined,address) | ||
| ADD_EXECUTABLE(fuzz_tester fuzz_tester.cpp) | ||
| TARGET_LINK_LIBRARIES( | ||
| fuzz_tester | ||
| PRIVATE project_options | ||
| project_warnings | ||
| CONAN_PKG::fmt | ||
| -coverage | ||
| -fsanitize=fuzzer,undefined,address) | ||
| TARGET_COMPILE_OPTIONS(fuzz_tester PRIVATE -fsanitize=fuzzer,undefined,address) | ||
|
|
||
| # Allow short runs during automated testing to see if something new breaks | ||
| set(FUZZ_RUNTIME | ||
| SET(FUZZ_RUNTIME | ||
| 10 | ||
| CACHE STRING "Number of seconds to run fuzz tests during ctest run") # Default of 10 seconds | ||
|
|
||
| add_test(NAME fuzz_tester_run COMMAND fuzz_tester -max_total_time=${FUZZ_RUNTIME}) | ||
| ADD_TEST(NAME fuzz_tester_run COMMAND fuzz_tester -max_total_time=${FUZZ_RUNTIME}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,20 @@ | ||
| #include <fmt/format.h> | ||
| #include <iterator> | ||
| #include <utility> | ||
| #include <fmt/format.h> | ||
|
|
||
| [[nodiscard]] auto sum_values(const uint8_t *Data, size_t Size) | ||
| { | ||
| constexpr auto scale = 1000; | ||
| constexpr auto scale = 1000; | ||
|
|
||
| int value = 0; | ||
| for (std::size_t offset = 0; offset < Size; ++offset) { | ||
| value += static_cast<int>(*std::next(Data, static_cast<long>(offset))) * scale; | ||
| } | ||
| return value; | ||
| int value = 0; | ||
| for (std::size_t offset = 0; offset < Size; ++offset) { value += static_cast<int>(*std::next(Data, static_cast<long>(offset))) * scale; } | ||
| return value; | ||
| } | ||
|
|
||
| // Fuzzer that attempts to invoke undefined behavior for signed integer overflow | ||
| // cppcheck-suppress unusedFunction symbolName=LLVMFuzzerTestOneInput | ||
| extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) | ||
| { | ||
| fmt::print("Value sum: {}, len{}\n", sum_values(Data,Size), Size); | ||
| return 0; | ||
| fmt::print("Value sum: {}, len{}\n", sum_values(Data, Size), Size); | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.