From 1420abc81beb18126219ddbd1b2e23f12dc18a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Thu, 20 Apr 2017 12:17:00 +0200 Subject: [PATCH] Add .travis.yml --- .travis.yml | 62 +++++++++++++++++++++++++++++ README.md | 2 +- include/cppast/cpp_entity.hpp | 2 + include/cppast/cpp_entity_index.hpp | 4 +- src/libclang/class_parser.cpp | 1 + src/libclang/debug_helper.hpp | 2 + src/libclang/function_parser.cpp | 3 +- src/libclang/namespace_parser.cpp | 6 +-- src/libclang/parse_functions.cpp | 2 +- src/libclang/preprocessor.cpp | 2 +- src/libclang/tokenizer.hpp | 1 + src/libclang/type_parser.cpp | 2 +- src/libclang/variable_parser.cpp | 4 +- test/test_parser.hpp | 2 +- 14 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..85ebefe --- /dev/null +++ b/.travis.yml @@ -0,0 +1,62 @@ +language: cpp + +matrix: + include: + - os: linux + compiler: gcc + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-5'] + env: TOOLSET=g++-5 LLVM_DOWNLOAD_OS_NAME=x86_64-linux-gnu-ubuntu-14.04 LLVM_VERSION=3.9.1 + + - os: linux + compiler: gcc + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-5'] + env: TOOLSET=g++-5 LLVM_DOWNLOAD_OS_NAME=x86_64-linux-gnu-ubuntu-14.04 LLVM_VERSION=4.0.0 + + - os: linux + compiler: clang + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.9'] + packages: ['g++-4.9', 'g++-5', 'clang-3.9'] + env: TOOLSET=clang++-3.9 LLVM_DOWNLOAD_OS_NAME=x86_64-linux-gnu-ubuntu-14.04 LLVM_VERSION=3.9.1 + + - os: linux + compiler: clang + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.9'] + packages: ['g++-4.9', 'g++-5', 'clang-3.9'] + env: TOOLSET=clang++-3.9 LLVM_DOWNLOAD_OS_NAME=x86_64-linux-gnu-ubuntu-14.04 LLVM_VERSION=4.0.0 + + - os: osx + compiler: clang + env: TOOLSET=clang++ LLVM_DOWNLOAD_OS_NAME=x86_64-apple-darwin LLVM_VERSION=4.0.0 + +install: + - cd ../ + + - 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 + + - export CXX=$TOOLSET + - $CXX --version + - $CMAKE --version + + - cd cppast/ + +script: + - mkdir build/ && cd build/ + - $CMAKE -DCMAKE_CXX_FLAGS="-pedantic -Wall -Wextra -Wconversion -Wsign-conversion -Wno-parentheses" -DLLVM_DOWNLOAD_OS_NAME=$LLVM_DOWNLOAD_OS_NAME -DLLVM_PREFERRED_VERSION=$LLVM_VERSION ../ + - $CMAKE --build . + - ./test/cppast_test diff --git a/README.md b/README.md index 15ff69f..0caaa36 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Else you need to set the CMake variable `LLVM_CONFIG_BINARY` to the proper path. 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. `linux-gnu-ubuntu-16.10` for Ubuntu 16.10. +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. The other dependencies like [type_safe](http://type_safe.foonathan.net) are installed automatically with git submodules, if they're not installed already. diff --git a/include/cppast/cpp_entity.hpp b/include/cppast/cpp_entity.hpp index 4170e3c..0fe192d 100644 --- a/include/cppast/cpp_entity.hpp +++ b/include/cppast/cpp_entity.hpp @@ -5,6 +5,8 @@ #ifndef CPPAST_CPP_ENTITY_HPP_INCLUDED #define CPPAST_CPP_ENTITY_HPP_INCLUDED +#include + #include #include diff --git a/include/cppast/cpp_entity_index.hpp b/include/cppast/cpp_entity_index.hpp index 8155565..abb3802 100644 --- a/include/cppast/cpp_entity_index.hpp +++ b/include/cppast/cpp_entity_index.hpp @@ -28,7 +28,7 @@ namespace cppast // FNV-1a 64 bit hash constexpr std::size_t id_hash(const char* str, std::size_t hash = fnv_basis) { - return *str ? id_hash(str + 1, (hash ^ *str) * fnv_prime) : hash; + return *str ? id_hash(str + 1, (hash ^ std::size_t(*str)) * fnv_prime) : hash; } } // namespace detail @@ -50,7 +50,7 @@ namespace cppast inline namespace literals { /// \returns A new [cppast::cpp_entity_id]() created from the given string. - inline cpp_entity_id operator""_id(const char* str, std::size_t) + inline cpp_entity_id operator"" _id(const char* str, std::size_t) { return cpp_entity_id(str); } diff --git a/src/libclang/class_parser.cpp b/src/libclang/class_parser.cpp index d7068a5..d3f19a5 100644 --- a/src/libclang/class_parser.cpp +++ b/src/libclang/class_parser.cpp @@ -96,6 +96,7 @@ std::unique_ptr detail::parse_cpp_class(const detail::parse_context& #if CPPAST_CINDEX_HAS_FRIEND auto is_friend = clang_getCursorKind(parent_cur) == CXCursor_FriendDecl; #else + (void)parent_cur; auto is_friend = false; #endif diff --git a/src/libclang/debug_helper.hpp b/src/libclang/debug_helper.hpp index 4443528..8f21616 100644 --- a/src/libclang/debug_helper.hpp +++ b/src/libclang/debug_helper.hpp @@ -5,6 +5,8 @@ #ifndef CPPAST_DEBUG_HELPER_HPP_INCLUDED #define CPPAST_DEBUG_HELPER_HPP_INCLUDED +#include + #include "raii_wrapper.hpp" namespace cppast diff --git a/src/libclang/function_parser.cpp b/src/libclang/function_parser.cpp index fde4771..0eee2c9 100644 --- a/src/libclang/function_parser.cpp +++ b/src/libclang/function_parser.cpp @@ -58,7 +58,8 @@ namespace for (auto i = 0; i != no; ++i) try { - auto parameter = parse_parameter(context, clang_Cursor_getArgument(cur, i)); + auto parameter = + parse_parameter(context, clang_Cursor_getArgument(cur, unsigned(i))); builder.add_parameter(std::move(parameter)); } catch (detail::parse_error& ex) diff --git a/src/libclang/namespace_parser.cpp b/src/libclang/namespace_parser.cpp index d00bcea..12b3e55 100644 --- a/src/libclang/namespace_parser.cpp +++ b/src/libclang/namespace_parser.cpp @@ -98,7 +98,7 @@ std::unique_ptr detail::parse_cpp_namespace_alias(const detail::pars auto result = cpp_namespace_alias::build(*context.idx, get_entity_id(cur), std::move(name), std::move(target)); context.comments.match(*result, cur); - return result; + return std::move(result); } std::unique_ptr detail::parse_cpp_using_directive(const detail::parse_context& context, @@ -121,7 +121,7 @@ std::unique_ptr detail::parse_cpp_using_directive(const detail::pars auto target = cpp_namespace_ref(parse_ns_target_cursor(cur), std::move(target_name)); auto result = cpp_using_directive::build(target); context.comments.match(*result, cur); - return result; + return std::move(result); } namespace @@ -189,5 +189,5 @@ std::unique_ptr detail::parse_cpp_using_declaration( auto target = cpp_entity_ref(parse_entity_target_cursor(cur), std::move(target_name)); auto result = cpp_using_declaration::build(std::move(target)); context.comments.match(*result, cur); - return result; + return std::move(result); } diff --git a/src/libclang/parse_functions.cpp b/src/libclang/parse_functions.cpp index f42f110..3e0af7e 100644 --- a/src/libclang/parse_functions.cpp +++ b/src/libclang/parse_functions.cpp @@ -227,5 +227,5 @@ std::unique_ptr detail::parse_cpp_static_assert(const detail::parse_ auto result = cpp_static_assert::build(std::move(expr), std::move(msg)); context.comments.match(*result, cur); - return result; + return std::move(result); } diff --git a/src/libclang/preprocessor.cpp b/src/libclang/preprocessor.cpp index 3af41c4..b39d61a 100644 --- a/src/libclang/preprocessor.cpp +++ b/src/libclang/preprocessor.cpp @@ -84,7 +84,7 @@ namespace str.push_back(*ptr++); ++ptr; - line = std::stoi(str); + line = unsigned(std::stoi(str)); } DEBUG_ASSERT(*ptr == ':', detail::assert_handler{}); diff --git a/src/libclang/tokenizer.hpp b/src/libclang/tokenizer.hpp index 5b204a8..dcf41cd 100644 --- a/src/libclang/tokenizer.hpp +++ b/src/libclang/tokenizer.hpp @@ -5,6 +5,7 @@ #ifndef CPPAST_TOKENIZER_HPP_INCLUDED #define CPPAST_TOKENIZER_HPP_INCLUDED +#include #include #include "raii_wrapper.hpp" diff --git a/src/libclang/type_parser.cpp b/src/libclang/type_parser.cpp index 38be045..103dbe4 100644 --- a/src/libclang/type_parser.cpp +++ b/src/libclang/type_parser.cpp @@ -674,6 +674,6 @@ std::unique_ptr detail::parse_cpp_type_alias(const detail::parse_con auto result = cpp_type_alias::build(*context.idx, get_entity_id(cur), name.c_str(), std::move(type)); context.comments.match(*result, cur); - return result; + return std::move(result); } } diff --git a/src/libclang/variable_parser.cpp b/src/libclang/variable_parser.cpp index a350b09..89e00d4 100644 --- a/src/libclang/variable_parser.cpp +++ b/src/libclang/variable_parser.cpp @@ -78,7 +78,7 @@ std::unique_ptr detail::parse_cpp_variable(const detail::parse_conte result = cpp_variable::build_declaration(get_entity_id(cur), name.c_str(), std::move(type), storage_class, is_constexpr); context.comments.match(*result, cur); - return result; + return std::move(result); } std::unique_ptr detail::parse_cpp_member_variable(const detail::parse_context& context, @@ -108,5 +108,5 @@ std::unique_ptr detail::parse_cpp_member_variable(const detail::pars std::move(type), std::move(default_value), is_mutable); } context.comments.match(*result, cur); - return result; + return std::move(result); } diff --git a/test/test_parser.hpp b/test/test_parser.hpp index 85f4f78..5eedfd4 100644 --- a/test/test_parser.hpp +++ b/test/test_parser.hpp @@ -138,7 +138,7 @@ unsigned test_visit(const cppast::cpp_file& file, Func f, bool check_code = true template unsigned count_children(const Entity& cont) { - return std::distance(cont.begin(), cont.end()); + return unsigned(std::distance(cont.begin(), cont.end())); } // ignores templated scopes