From c26d230d33ed2e2f3263bece6587dfaeec37ed0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Mon, 24 Sep 2018 15:59:12 +0200 Subject: [PATCH] [breaking] Drop support for clang 3.9.1 --- .travis.yml | 22 +--------------------- external/external.cmake | 2 +- include/cppast/libclang_parser.hpp | 11 ++++------- src/libclang/class_parser.cpp | 7 +------ src/libclang/cxtokenizer.cpp | 11 +---------- src/libclang/friend_parser.cpp | 2 -- src/libclang/libclang_parser.cpp | 25 +------------------------ src/libclang/parse_functions.cpp | 7 ------- src/libclang/parse_functions.hpp | 6 ------ src/libclang/preprocessor.cpp | 12 ++---------- 10 files changed, 11 insertions(+), 94 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9820f99..77885ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,6 @@ language: cpp matrix: include: - - os: linux - dist: trusty - sudo: false - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-3.9'] - packages: ['g++-5', 'llvm-3.9', 'clang-3.9', 'libclang-3.9-dev'] - env: TOOLSET=g++-5 LLVM_VERSION=3.9 LLVM_CONFIG_BINARY=/usr/bin/llvm-config-3.9 - - os: linux dist: trusty sudo: false @@ -22,16 +12,6 @@ matrix: packages: ['g++-5', 'lcov', 'llvm-4.0', 'clang-4.0', 'libclang-4.0-dev'] env: TOOLSET=g++-5 CPPAST_TEST_GCOV=ON LLVM_VERSION=4.0 LLVM_CONFIG_BINARY=/usr/bin/llvm-config-4.0 - - os: linux - dist: trusty - sudo: false - compiler: clang - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-3.9'] - packages: ['g++-4.9', 'g++-5', 'llvm-3.9', 'clang-3.9', 'libclang-3.9-dev'] - env: TOOLSET=clang++-3.9 LLVM_VERSION=3.9 LLVM_CONFIG_BINARY=/usr/bin/llvm-config-3.9 - - os: linux dist: trusty sudo: false @@ -74,7 +54,7 @@ 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 . - - if [[ "$LLVM_VERSION" == "4.0" ]]; then ./test/cppast_test \*; else ./test/cppast_test; fi + - ./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 diff --git a/external/external.cmake b/external/external.cmake index 50dfa6c..fb149e1 100644 --- a/external/external.cmake +++ b/external/external.cmake @@ -212,7 +212,7 @@ function(_cppast_find_libclang config_tool min_version force) endif() endfunction() -set(llvm_min_version 3.9.1) +set(llvm_min_version 4.0.0) if(NOT DEFINED LLVM_PREFERRED_VERSION) set(LLVM_PREFERRED_VERSION 4.0.0 CACHE STRING "the preferred LLVM version") diff --git a/include/cppast/libclang_parser.hpp b/include/cppast/libclang_parser.hpp index 9dca717..9d2f64f 100644 --- a/include/cppast/libclang_parser.hpp +++ b/include/cppast/libclang_parser.hpp @@ -20,8 +20,6 @@ namespace detail { static const std::string& clang_binary(const libclang_compile_config& config); - static int clang_version(const libclang_compile_config& config); - static const std::vector& flags(const libclang_compile_config& config); static bool write_preprocessed(const libclang_compile_config& config); @@ -119,11 +117,11 @@ public: libclang_compile_config& operator=(const libclang_compile_config& other) = default; /// \effects Sets the path to the location of the `clang++` binary and the version of that - /// binary. \notes It will be used for preprocessing. - void set_clang_binary(std::string binary, int major, int minor, int patch) + /// binary. + /// \notes It will be used for preprocessing. + void set_clang_binary(std::string binary) { - clang_binary_ = std::move(binary); - clang_version_ = major * 10000 + minor * 100 + patch; + clang_binary_ = std::move(binary); } /// \effects Sets whether or not the preprocessed file will be written out. @@ -170,7 +168,6 @@ private: } std::string clang_binary_; - int clang_version_; bool write_preprocessed_ : 1; bool fast_preprocessing_ : 1; bool remove_comments_in_macro_ : 1; diff --git a/src/libclang/class_parser.cpp b/src/libclang/class_parser.cpp index 4bc19c1..6bb6793 100644 --- a/src/libclang/class_parser.cpp +++ b/src/libclang/class_parser.cpp @@ -115,12 +115,7 @@ std::unique_ptr detail::parse_cpp_class(const detail::parse_context& { auto is_templated = (clang_getTemplateCursorKind(cur) != CXCursor_NoDeclFound || !clang_Cursor_isNull(clang_getSpecializedCursorTemplate(cur))); -#if CPPAST_CINDEX_HAS_FRIEND - auto is_friend = clang_getCursorKind(parent_cur) == CXCursor_FriendDecl; -#else - (void)parent_cur; - auto is_friend = false; -#endif + auto is_friend = clang_getCursorKind(parent_cur) == CXCursor_FriendDecl; auto builder = make_class_builder(context, cur); type_safe::optional semantic_parent; diff --git a/src/libclang/cxtokenizer.cpp b/src/libclang/cxtokenizer.cpp index 2d3845f..e7c69d8 100644 --- a/src/libclang/cxtokenizer.cpp +++ b/src/libclang/cxtokenizer.cpp @@ -199,11 +199,7 @@ CXSourceRange get_extent(const CXTranslationUnit& tu, const CXFile& file, const --paren_count; prev = next; } -#if CINDEX_VERSION_MINOR < 37 - end = prev; -#else end = next; -#endif } else if (kind == CXCursor_TemplateTemplateParameter && token_after_is(tu, file, end, "<", 0)) { @@ -272,12 +268,7 @@ CXSourceRange get_extent(const CXTranslationUnit& tu, const CXFile& file, const // need to shrink range by one end = get_next_location(tu, file, end, -1); else if (kind == CXCursor_FieldDecl || kind == CXCursor_NonTypeTemplateParameter - || kind == CXCursor_TemplateTemplateParameter -#if CINDEX_VERSION_MINOR < 37 - || clang_isExpression(kind) || kind == CXCursor_CXXBaseSpecifier - || kind == CXCursor_TemplateTypeParameter -#endif - ) + || kind == CXCursor_TemplateTemplateParameter) // need to shrink range by one end = get_next_location(tu, file, end, -1); else if (kind == CXCursor_UnexposedDecl) diff --git a/src/libclang/friend_parser.cpp b/src/libclang/friend_parser.cpp index 307c993..dbbf1c1 100644 --- a/src/libclang/friend_parser.cpp +++ b/src/libclang/friend_parser.cpp @@ -12,7 +12,6 @@ using namespace cppast; -#if CPPAST_CINDEX_HAS_FRIEND std::unique_ptr detail::parse_cpp_friend(const detail::parse_context& context, const CXCursor& cur) { @@ -107,4 +106,3 @@ std::unique_ptr detail::parse_cpp_friend(const detail::parse_context context.comments.match(*result, cur); return result; } -#endif diff --git a/src/libclang/libclang_parser.cpp b/src/libclang/libclang_parser.cpp index 1bbf585..47bdf40 100644 --- a/src/libclang/libclang_parser.cpp +++ b/src/libclang/libclang_parser.cpp @@ -25,11 +25,6 @@ const std::string& detail::libclang_compile_config_access::clang_binary( return config.clang_binary_; } -int detail::libclang_compile_config_access::clang_version(const libclang_compile_config& config) -{ - return config.clang_version_; -} - const std::vector& detail::libclang_compile_config_access::flags( const libclang_compile_config& config) { @@ -79,30 +74,12 @@ bool libclang_compilation_database::has_config(const char* file_name) const return true; } -namespace -{ -int parse_number(const char*& str) -{ - auto result = 0; - for (; *str && *str != '.'; ++str) - { - result *= 10; - result += int(*str - '0'); - } - return result; -} -} // namespace - libclang_compile_config::libclang_compile_config() : compile_config({}), write_preprocessed_(false), fast_preprocessing_(false), remove_comments_in_macro_(false) { // set given clang binary - auto ptr = CPPAST_CLANG_VERSION_STRING; - auto major = parse_number(ptr); - auto minor = parse_number(ptr); - auto patch = parse_number(ptr); - set_clang_binary(CPPAST_CLANG_BINARY, major, minor, patch); + set_clang_binary(CPPAST_CLANG_BINARY); // set system include dir add_include_dir(CPPAST_LIBCLANG_SYSTEM_INCLUDE_DIR); diff --git a/src/libclang/parse_functions.cpp b/src/libclang/parse_functions.cpp index 56b7acd..e667de9 100644 --- a/src/libclang/parse_functions.cpp +++ b/src/libclang/parse_functions.cpp @@ -102,12 +102,7 @@ namespace { bool is_friend(const CXCursor& parent_cur) { -#if CPPAST_CINDEX_HAS_FRIEND return clang_getCursorKind(parent_cur) == CXCursor_FriendDecl; -#else - (void)parent_cur; - return false; -#endif } } // namespace @@ -189,10 +184,8 @@ std::unique_ptr detail::parse_entity(const detail::parse_context& co case CXCursor_Destructor: return parse_cpp_destructor(context, cur, is_friend(parent_cur)); -#if CPPAST_CINDEX_HAS_FRIEND case CXCursor_FriendDecl: return parse_cpp_friend(context, cur); -#endif case CXCursor_TypeAliasTemplateDecl: return parse_cpp_alias_template(context, cur); diff --git a/src/libclang/parse_functions.hpp b/src/libclang/parse_functions.hpp index e2f6598..24ac563 100644 --- a/src/libclang/parse_functions.hpp +++ b/src/libclang/parse_functions.hpp @@ -13,12 +13,6 @@ #include "preprocessor.hpp" #include "raii_wrapper.hpp" -#if CINDEX_VERSION_MINOR >= 36 -# define CPPAST_CINDEX_HAS_FRIEND 1 -#else -# define CPPAST_CINDEX_HAS_FRIEND 0 -#endif - namespace cppast { class cpp_expression; diff --git a/src/libclang/preprocessor.cpp b/src/libclang/preprocessor.cpp index 5b53d32..0919f73 100644 --- a/src/libclang/preprocessor.cpp +++ b/src/libclang/preprocessor.cpp @@ -206,9 +206,8 @@ std::string get_preprocess_command(const libclang_compile_config& c, const char* // -no*: disable default include search paths flags += " -nostdinc -nostdinc++"; - if (detail::libclang_compile_config_access::clang_version(c) >= 40000) - // -Xclang -dI: print include directives as well (clang >= 4.0.0) - flags += " -Xclang -dI"; + // -Xclang -dI: print include directives as well + flags += " -Xclang -dI"; flags += diagnostics_flags(); @@ -1069,13 +1068,6 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co auto preprocessed = clang_preprocess(config, path, logger); - if (detail::libclang_compile_config_access::clang_version(config) < 40000) - { - // add headers from diagnostics w/o line information - for (auto name : preprocessed.included_files) - result.includes.push_back(pp_include{name, "", cpp_include_kind::local, 1u}); - } - position p(ts::ref(result.source), preprocessed.file.c_str()); ts::flag in_string(false), in_char(false), first_line(true); while (p)