Skip to content
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

Cherry-picked from commit 628e418df1a009e0d073545cbef3604350e7b808 #26

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions llvm/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "tools/clang"]
path = tools/clang
url = https://github.com/Microsoft/checkedc-clang
[submodule "projects/checkedc-wrapper/checkedc"]
path = projects/checkedc-wrapper/checkedc
url = https://github.com/Microsoft/checkedc
14 changes: 10 additions & 4 deletions llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,22 @@ option(LLVM_APPEND_VC_REV

set(PACKAGE_NAME LLVM)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "https://bugs.llvm.org/")
set(PACKAGE_BUGREPORT "https://github.com/Microsoft/checkedc-clang/issues")

set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING
"Default URL where bug reports are to be submitted.")

# Configure CPack.
set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM")
set(CPACK_PACKAGE_VENDOR "LLVM")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CheckedC-LLVM")
set(CPACK_PACKAGE_VENDOR "Microsoft")
set(CPACK_PACKAGE_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${LLVM_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${LLVM_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma \r\n SetCompressorDictSize 32")
if(WIN32 AND NOT UNIX)
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "CheckedC-LLVM")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
Expand Down Expand Up @@ -456,6 +456,12 @@ else()
set(LINK_POLLY_INTO_TOOLS OFF)
endif()

if (EXISTS ${LLVM_MAIN_SRC_DIR}/projects/checkedc-wrapper/checkedc)
set(CHECKEDC_IN_TREE TRUE)
else()
set(CHECKEDC_IN_TREE FALSE)
endif()

# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
Expand Down
64 changes: 64 additions & 0 deletions llvm/projects/checkedc-wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This script adds the Checked C tests to the LLVM tests infrastructure,
# provided that the Checked C repo exists as a subdirectory.

# LLVM uses the CMake meta-build system to generate the build system.
# The build system includes targets for running tests.
#
# The script adds a new target for running Checked C tests.
# To do that, it sets up the information needed by the LIT tool.

if(CHECKEDC_IN_TREE)
add_subdirectory(checkedc/include)

set(CHECKEDC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CHECKEDC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})


if (CMAKE_CFG_INTDIR STREQUAL ".")
set(LLVM_BUILD_MODE ".")
else ()
set(LLVM_BUILD_MODE "%(build_mode)s")
endif ()

string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})

configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)

list(APPEND CHECKEDC_TEST_DEPS
clang clang-headers checkedc-headers
)

if(CLANG_ENABLE_STATIC_ANALYZER)
list(APPEND CLANG_TEST_DEPS
clang-check
)
endif()

set(CHECKEDC_TEST_PARAMS
checkedc_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
)

if( NOT CLANG_BUILT_STANDALONE )
list(APPEND CHECKEDC_TEST_DEPS
llvm-config
FileCheck count not
opt
)
endif()

add_custom_target(checkedc-test-depends DEPENDS ${CHECKEDC_TEST_DEPS})

add_lit_testsuite(check-checkedc "Running the Checked C regression tests"
${CMAKE_CURRENT_BINARY_DIR}
#LIT ${LLVM_LIT}
PARAMS ${CHECKEDC_TEST_PARAMS}
DEPENDS ${CHECKEDC_TEST_DEPS}
ARGS ${CHECKEDC_TEST_EXTRA_ARGS}
)

set_target_properties(check-checkedc PROPERTIES FOLDER "Checked C tests")

endif()
31 changes: 31 additions & 0 deletions llvm/projects/checkedc-wrapper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Summary

Checked C is a research project to extend C with
static and dynamic checking to detect or prevent
common programming errors.

This directory contains LLVM-specific files for
testing the LLVM implementation of Checked C.
The files include build system files and LLVM
test infrastructure configuration files.

Checked C is a separate project from LLVM.
The specification for Checked C and the tests
for Checked C reside in a separate repo on
Github. To use those tests, clone the
Checked C repo to this directory:

git clone https://github.com/Microsoft/checkedc

## Why this directory exists.

You might wonder why these files were not
placed directly into the Checked C repo,
allowing us to elide this directory entirely.
The build and test infrastructure configuration
files are derived directly from existing LLVM files,
so they are subject the LLVM license and copyright
terms. The Checked C repo is subject to the MIT
conflicting licenses in the repo, just for a few files.


1 change: 1 addition & 0 deletions llvm/projects/checkedc-wrapper/checkedc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Subproject commit bc45607280f8ca1c4fc3208f3409b34749c1f728
Loading