Skip to content

Commit 62e5f01

Browse files
committed
Update concept parser to work with clang15
Fixes #155.
1 parent 6439fc5 commit 62e5f01

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

src/libclang/concept_parser.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ using namespace cppast;
1313
std::unique_ptr<cpp_entity> detail::try_parse_cpp_concept(const detail::parse_context& context,
1414
const CXCursor& cur)
1515
{
16+
#if CINDEX_VERSION_MINOR >= 62
17+
if (cur.kind != CXCursor_ConceptDecl)
18+
return nullptr;
19+
#else
1620
DEBUG_ASSERT(cur.kind == CXCursor_UnexposedDecl, detail::assert_handler{});
21+
#endif
1722

1823
detail::cxtokenizer tokenizer(context.tu, context.file, cur);
1924
detail::cxtoken_stream stream(tokenizer, cur);
@@ -34,28 +39,15 @@ std::unique_ptr<cpp_entity> detail::try_parse_cpp_concept(const detail::parse_co
3439
return nullptr;
3540

3641
const auto& identifier_token = stream.get();
37-
if (identifier_token.kind() != CXTokenKind::CXToken_Identifier)
38-
{
39-
return nullptr;
40-
}
41-
42-
cpp_concept::builder builder(identifier_token.value().std_str());
43-
44-
if (!detail::skip_if(stream, "="))
45-
{
46-
return nullptr;
47-
}
48-
49-
if (*(stream.end() - 1) != ";")
50-
{
51-
return nullptr;
52-
}
42+
DEBUG_ASSERT(identifier_token.kind() == CXTokenKind::CXToken_Identifier,
43+
detail::assert_handler{});
5344

54-
builder.set_expression(
55-
parse_raw_expression(context, stream, stream.end() - 1,
56-
cpp_builtin_type::build(cpp_builtin_type_kind::cpp_bool)));
45+
detail::skip(stream, "=");
46+
auto expr = parse_raw_expression(context, stream, stream.end() - 1,
47+
cpp_builtin_type::build(cpp_builtin_type_kind::cpp_bool));
5748

49+
cpp_concept::builder builder(identifier_token.value().std_str());
50+
builder.set_expression(std::move(expr));
5851
builder.set_parameters(std::move(params));
59-
6052
return builder.finish(*context.idx, detail::get_entity_id(cur));
6153
}

src/libclang/parse_functions.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ try
198198
case CXCursor_ClassTemplatePartialSpecialization:
199199
return parse_cpp_class_template_specialization(context, cur);
200200

201+
#if CINDEX_VERSION_MINOR >= 62
202+
case CXCursor_ConceptDecl:
203+
return try_parse_cpp_concept(context, cur);
204+
#endif
205+
201206
case CXCursor_StaticAssert:
202207
return parse_cpp_static_assert(context, cur);
203208

0 commit comments

Comments
 (0)