[breaking] Drop support for clang 3.9.1
This commit is contained in:
parent
9dfb518741
commit
c26d230d33
10 changed files with 11 additions and 94 deletions
22
.travis.yml
22
.travis.yml
|
|
@ -2,16 +2,6 @@ language: cpp
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
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
|
- os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
@ -22,16 +12,6 @@ matrix:
|
||||||
packages: ['g++-5', 'lcov', 'llvm-4.0', 'clang-4.0', 'libclang-4.0-dev']
|
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
|
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
|
- os: linux
|
||||||
dist: trusty
|
dist: trusty
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
@ -74,7 +54,7 @@ script:
|
||||||
- mkdir build/ && cd build/
|
- 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 -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 .
|
- $CMAKE --build .
|
||||||
- if [[ "$LLVM_VERSION" == "4.0" ]]; then ./test/cppast_test \*; else ./test/cppast_test; fi
|
- ./test/cppast_test \*
|
||||||
|
|
||||||
after_script:
|
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
|
- if [[ "$CPPAST_TEST_GCOV" == "ON" ]]; then $CMAKE --build . --target cppast_coverage && cd ../ && coveralls --no-gcov --lcov-file build/cppast_coverage.info.cleaned; fi
|
||||||
|
|
|
||||||
2
external/external.cmake
vendored
2
external/external.cmake
vendored
|
|
@ -212,7 +212,7 @@ function(_cppast_find_libclang config_tool min_version force)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
set(llvm_min_version 3.9.1)
|
set(llvm_min_version 4.0.0)
|
||||||
|
|
||||||
if(NOT DEFINED LLVM_PREFERRED_VERSION)
|
if(NOT DEFINED LLVM_PREFERRED_VERSION)
|
||||||
set(LLVM_PREFERRED_VERSION 4.0.0 CACHE STRING "the preferred LLVM version")
|
set(LLVM_PREFERRED_VERSION 4.0.0 CACHE STRING "the preferred LLVM version")
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ namespace detail
|
||||||
{
|
{
|
||||||
static const std::string& clang_binary(const libclang_compile_config& config);
|
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 const std::vector<std::string>& flags(const libclang_compile_config& config);
|
||||||
|
|
||||||
static bool write_preprocessed(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;
|
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
|
/// \effects Sets the path to the location of the `clang++` binary and the version of that
|
||||||
/// binary. \notes It will be used for preprocessing.
|
/// binary.
|
||||||
void set_clang_binary(std::string binary, int major, int minor, int patch)
|
/// \notes It will be used for preprocessing.
|
||||||
|
void set_clang_binary(std::string binary)
|
||||||
{
|
{
|
||||||
clang_binary_ = std::move(binary);
|
clang_binary_ = std::move(binary);
|
||||||
clang_version_ = major * 10000 + minor * 100 + patch;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \effects Sets whether or not the preprocessed file will be written out.
|
/// \effects Sets whether or not the preprocessed file will be written out.
|
||||||
|
|
@ -170,7 +168,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string clang_binary_;
|
std::string clang_binary_;
|
||||||
int clang_version_;
|
|
||||||
bool write_preprocessed_ : 1;
|
bool write_preprocessed_ : 1;
|
||||||
bool fast_preprocessing_ : 1;
|
bool fast_preprocessing_ : 1;
|
||||||
bool remove_comments_in_macro_ : 1;
|
bool remove_comments_in_macro_ : 1;
|
||||||
|
|
|
||||||
|
|
@ -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
|
auto is_templated = (clang_getTemplateCursorKind(cur) != CXCursor_NoDeclFound
|
||||||
|| !clang_Cursor_isNull(clang_getSpecializedCursorTemplate(cur)));
|
|| !clang_Cursor_isNull(clang_getSpecializedCursorTemplate(cur)));
|
||||||
#if CPPAST_CINDEX_HAS_FRIEND
|
auto is_friend = clang_getCursorKind(parent_cur) == CXCursor_FriendDecl;
|
||||||
auto is_friend = clang_getCursorKind(parent_cur) == CXCursor_FriendDecl;
|
|
||||||
#else
|
|
||||||
(void)parent_cur;
|
|
||||||
auto is_friend = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto builder = make_class_builder(context, cur);
|
auto builder = make_class_builder(context, cur);
|
||||||
type_safe::optional<cpp_entity_ref> semantic_parent;
|
type_safe::optional<cpp_entity_ref> semantic_parent;
|
||||||
|
|
|
||||||
|
|
@ -199,11 +199,7 @@ CXSourceRange get_extent(const CXTranslationUnit& tu, const CXFile& file, const
|
||||||
--paren_count;
|
--paren_count;
|
||||||
prev = next;
|
prev = next;
|
||||||
}
|
}
|
||||||
#if CINDEX_VERSION_MINOR < 37
|
|
||||||
end = prev;
|
|
||||||
#else
|
|
||||||
end = next;
|
end = next;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (kind == CXCursor_TemplateTemplateParameter && token_after_is(tu, file, end, "<", 0))
|
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
|
// need to shrink range by one
|
||||||
end = get_next_location(tu, file, end, -1);
|
end = get_next_location(tu, file, end, -1);
|
||||||
else if (kind == CXCursor_FieldDecl || kind == CXCursor_NonTypeTemplateParameter
|
else if (kind == CXCursor_FieldDecl || kind == CXCursor_NonTypeTemplateParameter
|
||||||
|| kind == CXCursor_TemplateTemplateParameter
|
|| kind == CXCursor_TemplateTemplateParameter)
|
||||||
#if CINDEX_VERSION_MINOR < 37
|
|
||||||
|| clang_isExpression(kind) || kind == CXCursor_CXXBaseSpecifier
|
|
||||||
|| kind == CXCursor_TemplateTypeParameter
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
// need to shrink range by one
|
// need to shrink range by one
|
||||||
end = get_next_location(tu, file, end, -1);
|
end = get_next_location(tu, file, end, -1);
|
||||||
else if (kind == CXCursor_UnexposedDecl)
|
else if (kind == CXCursor_UnexposedDecl)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
using namespace cppast;
|
using namespace cppast;
|
||||||
|
|
||||||
#if CPPAST_CINDEX_HAS_FRIEND
|
|
||||||
std::unique_ptr<cpp_entity> detail::parse_cpp_friend(const detail::parse_context& context,
|
std::unique_ptr<cpp_entity> detail::parse_cpp_friend(const detail::parse_context& context,
|
||||||
const CXCursor& cur)
|
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);
|
context.comments.match(*result, cur);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,6 @@ const std::string& detail::libclang_compile_config_access::clang_binary(
|
||||||
return config.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 std::vector<std::string>& detail::libclang_compile_config_access::flags(
|
||||||
const libclang_compile_config& config)
|
const libclang_compile_config& config)
|
||||||
{
|
{
|
||||||
|
|
@ -79,30 +74,12 @@ bool libclang_compilation_database::has_config(const char* file_name) const
|
||||||
return true;
|
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()
|
libclang_compile_config::libclang_compile_config()
|
||||||
: compile_config({}), write_preprocessed_(false), fast_preprocessing_(false),
|
: compile_config({}), write_preprocessed_(false), fast_preprocessing_(false),
|
||||||
remove_comments_in_macro_(false)
|
remove_comments_in_macro_(false)
|
||||||
{
|
{
|
||||||
// set given clang binary
|
// set given clang binary
|
||||||
auto ptr = CPPAST_CLANG_VERSION_STRING;
|
set_clang_binary(CPPAST_CLANG_BINARY);
|
||||||
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 system include dir
|
// set system include dir
|
||||||
add_include_dir(CPPAST_LIBCLANG_SYSTEM_INCLUDE_DIR);
|
add_include_dir(CPPAST_LIBCLANG_SYSTEM_INCLUDE_DIR);
|
||||||
|
|
|
||||||
|
|
@ -102,12 +102,7 @@ namespace
|
||||||
{
|
{
|
||||||
bool is_friend(const CXCursor& parent_cur)
|
bool is_friend(const CXCursor& parent_cur)
|
||||||
{
|
{
|
||||||
#if CPPAST_CINDEX_HAS_FRIEND
|
|
||||||
return clang_getCursorKind(parent_cur) == CXCursor_FriendDecl;
|
return clang_getCursorKind(parent_cur) == CXCursor_FriendDecl;
|
||||||
#else
|
|
||||||
(void)parent_cur;
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
@ -189,10 +184,8 @@ std::unique_ptr<cpp_entity> detail::parse_entity(const detail::parse_context& co
|
||||||
case CXCursor_Destructor:
|
case CXCursor_Destructor:
|
||||||
return parse_cpp_destructor(context, cur, is_friend(parent_cur));
|
return parse_cpp_destructor(context, cur, is_friend(parent_cur));
|
||||||
|
|
||||||
#if CPPAST_CINDEX_HAS_FRIEND
|
|
||||||
case CXCursor_FriendDecl:
|
case CXCursor_FriendDecl:
|
||||||
return parse_cpp_friend(context, cur);
|
return parse_cpp_friend(context, cur);
|
||||||
#endif
|
|
||||||
|
|
||||||
case CXCursor_TypeAliasTemplateDecl:
|
case CXCursor_TypeAliasTemplateDecl:
|
||||||
return parse_cpp_alias_template(context, cur);
|
return parse_cpp_alias_template(context, cur);
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,6 @@
|
||||||
#include "preprocessor.hpp"
|
#include "preprocessor.hpp"
|
||||||
#include "raii_wrapper.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
|
namespace cppast
|
||||||
{
|
{
|
||||||
class cpp_expression;
|
class cpp_expression;
|
||||||
|
|
|
||||||
|
|
@ -206,9 +206,8 @@ std::string get_preprocess_command(const libclang_compile_config& c, const char*
|
||||||
// -no*: disable default include search paths
|
// -no*: disable default include search paths
|
||||||
flags += " -nostdinc -nostdinc++";
|
flags += " -nostdinc -nostdinc++";
|
||||||
|
|
||||||
if (detail::libclang_compile_config_access::clang_version(c) >= 40000)
|
// -Xclang -dI: print include directives as well
|
||||||
// -Xclang -dI: print include directives as well (clang >= 4.0.0)
|
flags += " -Xclang -dI";
|
||||||
flags += " -Xclang -dI";
|
|
||||||
|
|
||||||
flags += diagnostics_flags();
|
flags += diagnostics_flags();
|
||||||
|
|
||||||
|
|
@ -1069,13 +1068,6 @@ detail::preprocessor_output detail::preprocess(const libclang_compile_config& co
|
||||||
|
|
||||||
auto preprocessed = clang_preprocess(config, path, logger);
|
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());
|
position p(ts::ref(result.source), preprocessed.file.c_str());
|
||||||
ts::flag in_string(false), in_char(false), first_line(true);
|
ts::flag in_string(false), in_char(false), first_line(true);
|
||||||
while (p)
|
while (p)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue