commit
9605bb328f
12 changed files with 100 additions and 110 deletions
70
.travis.yml
70
.travis.yml
|
|
@ -1,70 +0,0 @@
|
|||
language: cpp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
sudo: false
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
|
||||
packages: ['g++-5', 'lcov', 'llvm-4.0', 'clang-4.0', 'libclang-4.0-dev']
|
||||
env: TOOLSET=g++-5 CPPAST_TEST_GCOV=ON LLVM_CONFIG_BINARY=/usr/bin/llvm-config-4.0
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
sudo: false
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
|
||||
packages: ['g++-5', 'lcov', 'llvm-5.0', 'clang-5.0', 'libclang-5.0-dev']
|
||||
env: TOOLSET=g++-5 LLVM_CONFIG_BINARY=/usr/bin/llvm-config-5.0
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
sudo: false
|
||||
compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0']
|
||||
packages: ['g++-4.9', 'g++-5', 'llvm-4.0', 'clang-4.0', 'libclang-4.0-dev']
|
||||
env: TOOLSET=clang++-4.0 LLVM_CONFIG_BINARY=/usr/bin/llvm-config-4.0
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
compiler: clang
|
||||
env: TOOLSET=clang++
|
||||
|
||||
install:
|
||||
- cd ../
|
||||
|
||||
- if [[ "$CPPAST_TEST_GCOV" == "ON" ]]; then pip install --user cpp-coveralls; fi
|
||||
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget --no-check-certificate https://www.cmake.org/files/v3.3/cmake-3.3.1-Linux-x86_64.tar.gz; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar -xzf cmake-3.3.1-Linux-x86_64.tar.gz; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CMAKE=$TRAVIS_BUILD_DIR/../cmake-3.3.1-Linux-x86_64/bin/cmake; fi
|
||||
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget --no-check-certificate https://cmake.org/files/v3.3/cmake-3.3.0-Darwin-x86_64.tar.gz; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar -xzf cmake-3.3.0-Darwin-x86_64.tar.gz && ls && ls cmake-3.3.0-Darwin-x86_64; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CMAKE=$TRAVIS_BUILD_DIR/../cmake-3.3.0-Darwin-x86_64/CMake.app/Contents/bin/cmake; fi
|
||||
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget --no-check-certificate http://releases.llvm.org/5.0.0/clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar -xzf clang+llvm-5.0.0-x86_64-apple-darwin.tar.xz; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export LLVM_CONFIG_BINARY="$TRAVIS_BUILD_DIR/../clang+llvm-5.0.0-x86_64-apple-darwin/bin/llvm-config"; fi
|
||||
|
||||
- export CXX=$TOOLSET
|
||||
- $CXX --version
|
||||
- $CMAKE --version
|
||||
|
||||
- cd cppast/
|
||||
|
||||
script:
|
||||
- mkdir build/ && cd build/
|
||||
- $CMAKE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Werror -pedantic -Wall -Wextra -Wconversion -Wsign-conversion -Wno-parentheses -Wno-assume" ../ -DCPPAST_TEST_GCOV=$CPPAST_TEST_GCOV -DLLVM_CONFIG_BINARY=$LLVM_CONFIG_BINARY
|
||||
- $CMAKE --build .
|
||||
- ./test/cppast_test \*
|
||||
|
||||
after_script:
|
||||
- if [[ "$CPPAST_TEST_GCOV" == "ON" ]]; then $CMAKE --build . --target cppast_coverage && cd ../ && coveralls --no-gcov --lcov-file build/cppast_coverage.info.cleaned; fi
|
||||
|
|
@ -2,18 +2,10 @@
|
|||
# This file is subject to the license terms in the LICENSE file
|
||||
# found in the top-level directory of this distribution.
|
||||
|
||||
cmake_minimum_required(VERSION 3.3)
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(cppast VERSION 0.0)
|
||||
|
||||
# options
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(default_assertions ON)
|
||||
else()
|
||||
set(default_assertions OFF)
|
||||
endif()
|
||||
option(CPPAST_ENABLE_ASSERTIONS "whether or not to enable internal assertions for the cppast library" ${default_assertions})
|
||||
option(CPPAST_ENABLE_PRECONDITION_CHECKS "whether or not to enable precondition checks" ON)
|
||||
|
||||
option(CPPAST_BUILD_TEST "whether or not to build the tests" OFF)
|
||||
option(CPPAST_BUILD_EXAMPLE "whether or not to build the examples" OFF)
|
||||
option(CPPAST_BUILD_TOOL "whether or not to build the tool" OFF)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
# cppast
|
||||
|
||||
[](https://travis-ci.org/foonathan/cppast)
|
||||
[](https://dev.azure.com/foonathan/cppast/_build/latest?definitionId=5?branchName=master)
|
||||
[](https://ci.appveyor.com/project/foonathan/cppast)
|
||||
[](https://coveralls.io/github/foonathan/cppast)
|
||||
|
||||
Library interface to the C++ AST — parse source files, synthesize entities, get documentation comments and generate code.
|
||||
|
||||
|
|
@ -61,6 +60,8 @@ If you don't have a proper clang version installed, it can also be downloaded.
|
|||
For that you need to set `LLVM_DOWNLOAD_OS_NAME`.
|
||||
This is the name of the operating system used on the [LLVM pre-built binary archive](http://releases.llvm.org/download.html#4.0.0), e.g. `x86_64-linux-gnu-ubuntu-16.10` for Ubuntu 16.10.
|
||||
|
||||
You can also set `LLVM_DOWNLOAD_URL` to a custom url, to download a specific version or from a mirror.
|
||||
|
||||
If you don't have `llvm-config`, you need to pass the locations explictly.
|
||||
For that set the option `LLVM_VERSION_EXPLICIT` to the version you're using,
|
||||
`LIBCLANG_LIBRARY` to the location of the libclang library file,
|
||||
|
|
|
|||
64
azure-pipelines.yml
Normal file
64
azure-pipelines.yml
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
name: 'CI build'
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- feature/*
|
||||
paths:
|
||||
exclude:
|
||||
- README.md
|
||||
|
||||
jobs:
|
||||
- job: compiler_linux
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
strategy:
|
||||
matrix:
|
||||
GCC5:
|
||||
IMAGE: 'conanio/gcc5'
|
||||
GCC6:
|
||||
IMAGE: 'conanio/gcc6'
|
||||
GCC7:
|
||||
IMAGE: 'conanio/gcc7'
|
||||
GCC8:
|
||||
IMAGE: 'conanio/gcc8'
|
||||
steps:
|
||||
- script: docker run --privileged -u root -v "$PWD:/cppast" $(IMAGE) bash -c "apt-get -qq update && apt-get -qq install -y --no-install-recommends llvm-4.0-dev clang-4.0 libclang-4.0-dev && cmake /cppast/ && cmake --build . && ctest --output-on-failure"
|
||||
displayName: "Compiling using $(IMAGE)"
|
||||
|
||||
- job: llvm_linux
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
strategy:
|
||||
matrix:
|
||||
LLVM4:
|
||||
IMAGE: 'foonathan/micro_cpp_llvm:llvm4'
|
||||
LLVM5:
|
||||
IMAGE: 'foonathan/micro_cpp_llvm:llvm5'
|
||||
LLVM6:
|
||||
IMAGE: 'foonathan/micro_cpp_llvm:llvm6'
|
||||
LLVM7:
|
||||
IMAGE: 'foonathan/micro_cpp_llvm:llvm7'
|
||||
steps:
|
||||
- script: docker run -u root -v "$PWD:/cppast" $(IMAGE) bash -c "cmake -DCMAKE_CXX_COMPILER=clang++ /cppast/ && cmake --build . && ctest --output-on-failure"
|
||||
displayName: "Compiling using $(IMAGE)"
|
||||
|
||||
- job: llvm_macos
|
||||
pool:
|
||||
vmImage: 'macOS-10.13'
|
||||
strategy:
|
||||
matrix:
|
||||
LLVM4:
|
||||
URL: 'http://releases.llvm.org/4.0.0/clang+llvm-4.0.0-x86_64-apple-darwin.tar.xz'
|
||||
EXCLUDE: 'integration'
|
||||
LLVM5:
|
||||
URL: 'http://releases.llvm.org/5.0.2/clang+llvm-5.0.2-x86_64-apple-darwin.tar.xz'
|
||||
LLVM6:
|
||||
URL: 'http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz'
|
||||
LLVM7:
|
||||
URL: 'http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz'
|
||||
steps:
|
||||
- script: |
|
||||
mkdir build && cd build/
|
||||
cmake -DLLVM_DOWNLOAD_URL=$URL ../ && cmake --build . && ctest --output-on-failure -E $EXCLUDE
|
||||
displayName: "Compiling using $(URL)"
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
function(_cppast_example name)
|
||||
add_executable(cppast_example_${name} ${name}.cpp example_parser.hpp)
|
||||
target_link_libraries(cppast_example_${name} PUBLIC cppast)
|
||||
set_target_properties(cppast_example_${name} PROPERTIES CXX_STANDARD 11)
|
||||
endfunction()
|
||||
|
||||
_cppast_example(ast_printer)
|
||||
|
|
|
|||
4
external/external.cmake
vendored
4
external/external.cmake
vendored
|
|
@ -72,7 +72,7 @@ function(_cppast_download_llvm url)
|
|||
|
||||
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${folder})
|
||||
message(STATUS "Downloading LLVM from ${url}")
|
||||
file(DOWNLOAD ${url} ${CMAKE_CURRENT_BINARY_DIR}/${file} SHOW_PROGRESS
|
||||
file(DOWNLOAD ${url} ${CMAKE_CURRENT_BINARY_DIR}/${file}
|
||||
STATUS status
|
||||
LOG log)
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ function(_cppast_find_llvm_config)
|
|||
if (LLVM_DOWNLOAD_DIR)
|
||||
find_program(LLVM_CONFIG_BINARY "llvm-config" "${LLVM_DOWNLOAD_DIR}/bin" NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_program(LLVM_CONFIG_BINARY "llvm-config")
|
||||
find_program(LLVM_CONFIG_BINARY NAMES llvm-config llvm-config-4.0 llvm-config-5.0 llvm-config-6.0 llvm-config-7)
|
||||
endif()
|
||||
if(NOT LLVM_CONFIG_BINARY)
|
||||
message(FATAL_ERROR "Unable to find llvm-config binary, please set option LLVM_CONFIG_BINARY yourself")
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@
|
|||
|
||||
#include <debug_assert.hpp>
|
||||
|
||||
#ifdef CPPAST_ENABLE_ASSERTIONS
|
||||
# define CPPAST_ASSERTION_LEVEL 1
|
||||
#else
|
||||
#ifndef CPPAST_ASSERTION_LEVEL
|
||||
# define CPPAST_ASSERTION_LEVEL 0
|
||||
#endif
|
||||
|
||||
#ifdef CPPAST_ENABLE_PRECONDITION_CHECKS
|
||||
# define CPPAST_PRECONDITION_LEVEL 1
|
||||
#else
|
||||
# define CPPAST_PRECONDITION_LEVEL 0
|
||||
#ifndef CPPAST_PRECONDITION_LEVEL
|
||||
# ifdef NDEBUG
|
||||
# define CPPAST_PRECONDITION_LEVEL 0
|
||||
# else
|
||||
# define CPPAST_PRECONDITION_LEVEL 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace cppast
|
||||
|
|
|
|||
|
|
@ -102,16 +102,19 @@ set(libclang_source
|
|||
libclang/variable_parser.cpp)
|
||||
|
||||
add_library(cppast ${detail_header} ${header} ${source} ${libclang_source})
|
||||
set_target_properties(cppast PROPERTIES CXX_STANDARD 11)
|
||||
target_include_directories(cppast PUBLIC ../include)
|
||||
target_compile_features(cppast PUBLIC cxx_std_11)
|
||||
target_include_directories(cppast PRIVATE ../include SYSTEM INTERFACE ../include)
|
||||
target_link_libraries(cppast PUBLIC type_safe _cppast_tiny_process _cppast_libclang)
|
||||
target_compile_definitions(cppast PUBLIC
|
||||
CPPAST_VERSION_MINOR="${cppast_VERSION_MINOR}"
|
||||
CPPAST_VERSION_MAJOR="${cppast_VERSION_MAJOR}"
|
||||
CPPAST_VERSION_STRING="${cppast_VERSION}")
|
||||
if(CPPAST_ENABLE_ASSERTIONS)
|
||||
target_compile_definitions(cppast PUBLIC CPPAST_ENABLE_ASSERTIONS)
|
||||
endif()
|
||||
if(CPPAST_ENABLE_PRECONDITION_CHECKS)
|
||||
target_compile_definitions(cppast PUBLIC CPPAST_ENABLE_PRECONDITION_CHECKS)
|
||||
endif()
|
||||
target_compile_options(cppast PRIVATE
|
||||
# clang/GCC warnings
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-pedantic-errors -Werror -Wall -Wextra -Wconversion -Wsign-conversion>
|
||||
# disable noexcept type warning on GCC
|
||||
$<$<CXX_COMPILER_ID:GNU>: -Wno-noexcept-type>
|
||||
# MSVC warnings
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/WX /W4>)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ void cpp_entity_index::register_definition(cpp_entity_id
|
|||
{
|
||||
// already in map, override declaration
|
||||
auto& value = result.first->second;
|
||||
if (value.is_definition)
|
||||
if (value.is_definition && !is_template_specialization(value.entity->kind()))
|
||||
// allow duplicate definition of template specializations as a workaround for MacOS
|
||||
throw duplicate_definition_error();
|
||||
value.is_definition = true;
|
||||
value.entity = entity;
|
||||
|
|
|
|||
|
|
@ -408,10 +408,10 @@ detail::cxtokenizer::cxtokenizer(const CXTranslationUnit& tu, const CXFile& file
|
|||
|
||||
if (!clang_Range_isNull(extent.second_part))
|
||||
{
|
||||
simple_tokenizer tokenizer(tu, extent.second_part);
|
||||
tokens_.reserve(tokens_.size() + tokenizer.size());
|
||||
for (auto i = 0u; i != tokenizer.size(); ++i)
|
||||
tokens_.emplace_back(tu, tokenizer[i]);
|
||||
simple_tokenizer second_tokenizer(tu, extent.second_part);
|
||||
tokens_.reserve(tokens_.size() + second_tokenizer.size());
|
||||
for (auto i = 0u; i != second_tokenizer.size(); ++i)
|
||||
tokens_.emplace_back(tu, second_tokenizer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ detail::cxtranslation_unit get_cxunit(const diagnostic_logger& logger, const det
|
|||
CXUnsavedFile file;
|
||||
file.Filename = path;
|
||||
file.Contents = source.c_str();
|
||||
file.Length = source.length();
|
||||
file.Length = static_cast<unsigned long>(source.length());
|
||||
|
||||
auto args = get_arguments(config);
|
||||
|
||||
|
|
@ -648,10 +648,10 @@ std::unique_ptr<cpp_file> libclang_parser::do_parse(const cpp_entity_index& idx,
|
|||
for (; macro_iter != preprocessed.macros.end(); ++macro_iter)
|
||||
builder.add_child(std::move(macro_iter->macro));
|
||||
|
||||
for (auto& c : preprocessed.comments)
|
||||
for (auto& cur : preprocessed.comments)
|
||||
{
|
||||
if (!c.comment.empty())
|
||||
builder.add_unmatched_comment(cpp_doc_comment(std::move(c.comment), c.line));
|
||||
if (!cur.comment.empty())
|
||||
builder.add_unmatched_comment(cpp_doc_comment(std::move(cur.comment), cur.line));
|
||||
}
|
||||
|
||||
if (context.error)
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ target_include_directories(cppast_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../src)
|
|||
target_link_libraries(cppast_test PUBLIC cppast)
|
||||
target_compile_definitions(cppast_test PUBLIC CPPAST_INTEGRATION_FILE="${CMAKE_CURRENT_SOURCE_DIR}/integration.cpp"
|
||||
CPPAST_COMPILE_COMMANDS="${CMAKE_BINARY_DIR}")
|
||||
set_target_properties(cppast_test PROPERTIES CXX_STANDARD 11)
|
||||
|
||||
add_test(NAME test COMMAND cppast_test)
|
||||
add_test(NAME unit_test COMMAND cppast_test "~[integration]")
|
||||
add_test(NAME integration_test COMMAND cppast_test "[integration]")
|
||||
|
||||
if(CPPAST_TEST_GCOV AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
|
||||
setup_target_for_coverage(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue