[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

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