Skip to content

Commit

Permalink
filter for codeql; resolve more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Sep 16, 2023
1 parent 3bf8640 commit 1b9c027
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config: |
query-filters:
- exclude:
id: cpp/integer-multiplication-cast-to-long
- name: Configure
run: |
Expand Down
37 changes: 23 additions & 14 deletions cmake/cage_build_configuration.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

macro(cage_build_configuration)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(FATAL_ERROR "CMAKE_BUILD_TYPE needs to be set")
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be set")
endif()

cmake_policy(SET CMP0063 NEW)
Expand Down Expand Up @@ -44,11 +44,12 @@ macro(cage_build_configuration)
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")

# disable some compiler warnings:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_ENABLE_EXTENDED_ALIGNED_STORAGE")
# disable some warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_ENABLE_EXTENDED_ALIGNED_STORAGE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd26812") # The enum type ___ is unscoped. Prefer 'enum class' over 'enum'
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd26451") # Arithmetic overflow: Using operator ___ on a 4 byte value and then casting the result to a 8 byte value.

# optionally improve runtime performance in debug builds
# optionally improve runtime performance in debug builds (basic inlining)
option(cage_faster_debug "enable some optimizations to improve performance in debug builds" ON)
if(cage_faster_debug)
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
Expand All @@ -57,10 +58,13 @@ macro(cage_build_configuration)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Ob1 /D_ITERATOR_DEBUG_LEVEL=0")
endif()

# multi-process compilation
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
# optionally improve runtime performance in release builds (more aggressive inlining)
option(cage_faster_release "enable more aggressive inlining in release builds" ON)
if(cage_faster_release)
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_DEBUG}")
string(REGEX REPLACE "/Ob[0-9]" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ob3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob3")
endif()

# 8 MB default stack size
Expand All @@ -70,12 +74,17 @@ macro(cage_build_configuration)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")

# disable warnings about attributes
# disable some warnings
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-abi")
endif()

# no warnings about changes in ABI
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-abi")
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") # multi-process compilation
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
endmacro(cage_build_configuration)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-assume") # __builtin_assume has side effects that are discarded
endif()
endmacro(cage_build_configuration)
3 changes: 0 additions & 3 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ endif()
if(MSVC)
set_source_files_properties(libcore/mesh/marchingCubes.cpp PROPERTIES COMPILE_FLAGS "/wd4244 /wd4267") # it includes file with weird extension which does not honor warnings disabled by pragma
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(cage-core PUBLIC "-Wno-assume") # __builtin_assume has side effects that are discarded
endif()
try_compile(sourceLocationAvailable "${CMAKE_CURRENT_BINARY_DIR}/tryCompile" SOURCES "${CMAKE_CURRENT_LIST_DIR}/tryCompileSourceLocation.cpp" OUTPUT_VARIABLE sourceLocationMessages)
if(NOT sourceLocationAvailable)
target_compile_definitions(cage-core PUBLIC GCHL_DUMMY_SOURCE_LOCATION)
Expand Down
4 changes: 2 additions & 2 deletions sources/libcore/mesh/importAssimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ namespace cage
}
totalKeys += n->mNumScalingKeys;
}
const uint32 animationBonesCount = numeric_cast<uint32>(bones.size());
const uint16 animationBonesCount = numeric_cast<uint16>(bones.size());
if (config.verbose)
{
CAGE_LOG(SeverityEnum::Info, "meshImport", Stringizer() + "animated bones: " + animationBonesCount);
Expand All @@ -658,7 +658,7 @@ namespace cage
{
std::vector<uint16> mapping;
mapping.resize(skeletonBonesCount, m);
for (uint16 i = 0; i < bones.size(); i++)
for (uint16 i = 0; i < animationBonesCount; i++)
{
CAGE_ASSERT(mapping[boneIndices[i]] == m);
mapping[boneIndices[i]] = i;
Expand Down

0 comments on commit 1b9c027

Please sign in to comment.