[breaking] Drop support for clang 3.9.1

This commit is contained in:
Jonathan Müller 2018-09-24 15:59:12 +02:00
commit c26d230d33
10 changed files with 11 additions and 94 deletions

View file

@ -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

View file

@ -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")

View file

@ -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<std::string>& 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;

View file

@ -115,12 +115,7 @@ std::unique_ptr<cpp_entity> 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<cpp_entity_ref> semantic_parent;

View file

@ -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)

View file

@ -12,7 +12,6 @@
using namespace cppast;
#if CPPAST_CINDEX_HAS_FRIEND
std::unique_ptr<cpp_entity> detail::parse_cpp_friend(const detail::parse_context& context,
const CXCursor& cur)
{
@ -107,4 +106,3 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_friend(const detail::parse_context
context.comments.match(*result, cur);
return result;
}
#endif

View file

@ -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<std::string>& 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);

View file

@ -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<cpp_entity> 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);

View file

@ -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;

View file

@ -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)