<commit_before># vim:ft=cmake:

set(WARNINGS "
  -Wfatal-errors
  -Wall
  -Wextra
  -Wformat=2
  -Wcomment
  -Wshadow
  -Wctor-dtor-privacy
  -Wnon-virtual-dtor
  -Wreorder
  -Winit-self
  -Wmissing-include-dirs
  -Wunused
  -Wunused-parameter
  -Wunknown-pragmas
  -Wstrict-overflow=2
  -Wstrict-overflow=3
  -Wstrict-overflow=4
  -Wstrict-aliasing
  -Wfloat-equal
  -Wundef
  -Wcast-qual
  -Wcast-align
  -Wwrite-strings
  -Wmissing-format-attribute
  -Wno-multichar
  -Wpacked
  -Wredundant-decls
  -Winvalid-pch
  -Wlong-long
  -Wdisabled-optimization
  -Wconversion
  -Wabi
  -Wstrict-null-sentinel
  -Weffc++
  -Wno-non-template-friend
  -Wsign-promo
  -Wswitch-default
  -Wsync-nand
  -Wlogical-op
  -Wvla
  -Wstack-protector
  -Wold-style-cast
  -Wno-pmf-conversions
#  -Winline
  -Wmissing-noreturn
  -Wunsafe-loop-optimizations
#  -Waggregate-return   # with this on, only POD may be returned from functions
  -Wsign-conversion    # *very* pedantic sign warnings
#  -Wpadded             # we don't need padding warnings on a quad core
#  -Wswitch-enum        # warnings in mousePressEvent
 ")

set(OPTIMIZATIONS "
#  -fPIC
  -funsafe-loop-optimizations
  -fno-strict-aliasing
  -funit-at-a-time      # needed for GCC 4.3.3
 ")

execute_process(
  COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion"
  OUTPUT_VARIABLE COMPILER_VERSION
)

# remove unsupported warning flags
if("${CMAKE_CXX_COMPILER}" MATCHES ".*c\\+\\+")
  if(COMPILER_VERSION STRLESS "4.3.4")
    string(REGEX REPLACE "[^\n]*-Wsync-nand[^\n]*\n" ""               WARNINGS ${WARNINGS})
  endif()
elseif("${CMAKE_CXX_COMPILER}" MATCHES ".*clang.*")
  string(REGEX REPLACE "[^\n]*-Wstrict-null-sentinel[^\n]*\n" ""      WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wno-non-template-friend[^\n]*\n" ""    WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wsync-nand[^\n]*\n" ""                 WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wlogical-op[^\n]*\n" ""                WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wno-pmf-conversions[^\n]*\n" ""        WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wunsafe-loop-optimizations[^\n]*\n" "" WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wsign-conversion[^\n]*\n" ""           WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-funsafe-loop-optimizations[^\n]*\n" "" OPTIMIZATIONS ${OPTIMIZATIONS})
  set(WARNINGS "${WARNINGS} -Wno-mismatched-tags")
endif()

# strip comments and newlines
string(REGEX REPLACE "\ *#[^\n]*\n" "" WARNINGS ${WARNINGS})
string(REGEX REPLACE "\n\ *" " "       WARNINGS ${WARNINGS})
string(REGEX REPLACE "\ *#[^\n]*\n" "" OPTIMIZATIONS ${OPTIMIZATIONS})
string(REGEX REPLACE "\n\ *" " "       OPTIMIZATIONS ${OPTIMIZATIONS})
<commit_msg>remove broken warning command under GCC 4.4.1<commit_after># vim:ft=cmake:

set(WARNINGS "
  -Wfatal-errors
  -Wall
  -Wextra
  -Wformat=2
  -Wcomment
  -Wshadow
  -Wctor-dtor-privacy
  -Wnon-virtual-dtor
  -Wreorder
  -Winit-self
  -Wmissing-include-dirs
  -Wunused
  -Wunused-parameter
  -Wunknown-pragmas
  -Wstrict-overflow=2
  -Wstrict-overflow=3
  -Wstrict-overflow=4
  -Wstrict-aliasing
  -Wfloat-equal
  -Wundef
  -Wcast-qual
  -Wcast-align
  -Wwrite-strings
  -Wmissing-format-attribute
  -Wno-multichar
  -Wpacked
  -Wredundant-decls
  -Winvalid-pch
  -Wlong-long
  -Wdisabled-optimization
  -Wconversion
  -Wabi
  -Wstrict-null-sentinel
  -Weffc++
  -Wno-non-template-friend
  -Wsign-promo
  -Wswitch-default
  -Wsync-nand
  -Wlogical-op
  -Wvla
  -Wstack-protector
  -Wold-style-cast
  -Wno-pmf-conversions
#  -Winline
  -Wmissing-noreturn
  -Wunsafe-loop-optimizations
#  -Waggregate-return   # with this on, only POD may be returned from functions
  -Wsign-conversion    # *very* pedantic sign warnings
#  -Wpadded             # we don't need padding warnings on a quad core
#  -Wswitch-enum        # warnings in mousePressEvent
 ")

set(OPTIMIZATIONS "
#  -fPIC
  -funsafe-loop-optimizations
  -fno-strict-aliasing
  -funit-at-a-time      # needed for GCC 4.3.3
 ")

execute_process(
  COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion"
  OUTPUT_VARIABLE COMPILER_VERSION
)

# remove unsupported warning flags
if("${CMAKE_CXX_COMPILER}" MATCHES ".*c\\+\\+")
  if(COMPILER_VERSION STRLESS "4.3.4")
    string(REGEX REPLACE "[^\n]*-Wsync-nand[^\n]*\n" ""               WARNINGS ${WARNINGS})
  endif()
  if(COMPILER_VERSION STREQUAL "4.4.1\n")
    string(REGEX REPLACE "[^\n]*-Wunsafe-loop-optimizations[^\n]*\n" ""   WARNINGS ${WARNINGS})
  endif()
elseif("${CMAKE_CXX_COMPILER}" MATCHES ".*clang.*")
  string(REGEX REPLACE "[^\n]*-Wstrict-null-sentinel[^\n]*\n" ""      WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wno-non-template-friend[^\n]*\n" ""    WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wsync-nand[^\n]*\n" ""                 WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wlogical-op[^\n]*\n" ""                WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wno-pmf-conversions[^\n]*\n" ""        WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wunsafe-loop-optimizations[^\n]*\n" "" WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-Wsign-conversion[^\n]*\n" ""           WARNINGS ${WARNINGS})
  string(REGEX REPLACE "[^\n]*-funsafe-loop-optimizations[^\n]*\n" "" OPTIMIZATIONS ${OPTIMIZATIONS})
  set(WARNINGS "${WARNINGS} -Wno-mismatched-tags")
endif()

# strip comments and newlines
string(REGEX REPLACE "\ *#[^\n]*\n" "" WARNINGS ${WARNINGS})
string(REGEX REPLACE "\n\ *" " "       WARNINGS ${WARNINGS})
string(REGEX REPLACE "\ *#[^\n]*\n" "" OPTIMIZATIONS ${OPTIMIZATIONS})
string(REGEX REPLACE "\n\ *" " "       OPTIMIZATIONS ${OPTIMIZATIONS})

{'fraction_non_alphanumeric': 0.1723404255319149, 'fraction_numerical': 0.004609929078014184, 'mean_word_length': 3.2159940209267566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6135123', 'n_tokens_mistral': 2322, 'n_tokens_neox': 2223, 'n_words': 377}