<commit_before>########################################################################################################################
# Root build script

cmake_minimum_required(VERSION 2.8)
project(openfpga CXX)
include(GNUInstallDirs)

set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
set( LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)

if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
  set(EXTRA_WARNINGS "-Wcast-align -Winit-self -Wmissing-declarations")
  set(EXTRA_WARNINGS "${EXTRA_WARNINGS} -Wswitch -Wwrite-strings")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ${EXTRA_WARNINGS} -std=c++11 -fPIC")
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -shared-libgcc -ggdb")
  set(CMAKE_LINK_FLAGS "-ggdb")
endif()

# Sanitizers
if(SANITIZE)
  if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
    if(SANITIZE STREQUAL memory)
      message(STATUS "Please note that you need to build instrumented libc++ and libjson-c.")
      message(STATUS "Try: cmake -DCMAKE_CXX_FLAGS=\"-I\${MSAN_PREFIX}/include/ \\")
      message(STATUS "                              -stdlib=libc++ -I\${MSAN_PREFIX}/include/c++/v1/\" \\")
      message(STATUS "           -DCMAKE_EXE_LINKER_FLAGS=\"-lc++abi -L\${MSAN_PREFIX}/lib\" ...")
      message(STATUS "See https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins")
    elseif(SANITIZE STREQUAL undefined)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
    else()
      message(FATAL_ERROR "Unsupported sanitizer ${SANITIZE}")
    endif()
  else()
    message(FATAL_ERROR "Sanitizers not supported on compiler ${CMAKE_CXX_COMPILER_ID}")
  endif()
endif()

add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(doc)<commit_msg>CMake: add asan and clang-analyzer plumbing.<commit_after>########################################################################################################################
# Root build script

cmake_minimum_required(VERSION 2.8)
project(openfpga CXX)
include(GNUInstallDirs)

set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
set( LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)

if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
  set(EXTRA_WARNINGS "-Wcast-align -Winit-self -Wmissing-declarations")
  set(EXTRA_WARNINGS "${EXTRA_WARNINGS} -Wswitch -Wwrite-strings")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ${EXTRA_WARNINGS} -std=c++11 -fPIC")
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -shared-libgcc -ggdb")
  set(CMAKE_LINK_FLAGS "-ggdb")
endif()

# Compilation database for Clang static analyzer
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Clang sanitizers
if(SANITIZE)
  if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
    if(SANITIZE STREQUAL memory)
      message(STATUS "Please note that you need to build instrumented libc++ and libjson-c.")
      message(STATUS "Try: cmake -DCMAKE_CXX_FLAGS=\"-I\${MSAN_PREFIX}/include/ \\")
      message(STATUS "                              -stdlib=libc++ -I\${MSAN_PREFIX}/include/c++/v1/\" \\")
      message(STATUS "           -DCMAKE_EXE_LINKER_FLAGS=\"-lc++abi -L\${MSAN_PREFIX}/lib\" ...")
      message(STATUS "See https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins")
    elseif(SANITIZE STREQUAL address)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
    elseif(SANITIZE STREQUAL undefined)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined,integer")
    else()
      message(FATAL_ERROR "Unsupported sanitizer ${SANITIZE}")
    endif()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=all")
  else()
    message(FATAL_ERROR "Sanitizers not supported on compiler ${CMAKE_CXX_COMPILER_ID}")
  endif()
endif()

add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(doc)
{'fraction_non_alphanumeric': 0.17625548512920527, 'fraction_numerical': 0.0024378352023403218, 'mean_word_length': 5.254573170731708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5123872', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1443, 'n_words': 242}