diff --git a/src/libclang/cxtokenizer.cpp b/src/libclang/cxtokenizer.cpp index 7d3c313..c2d7cc3 100644 --- a/src/libclang/cxtokenizer.cpp +++ b/src/libclang/cxtokenizer.cpp @@ -561,12 +561,16 @@ namespace } } -cpp_attribute_list detail::parse_attributes(detail::cxtoken_stream& stream) +cpp_attribute_list detail::parse_attributes(detail::cxtoken_stream& stream, bool skip_anway) { cpp_attribute_list result; + while (parse_attribute_impl(result, stream)) - { - } + skip_anway = false; + + if (skip_anway) + stream.bump(); + return result; } diff --git a/src/libclang/cxtokenizer.hpp b/src/libclang/cxtokenizer.hpp index 5e11d15..b2a277e 100644 --- a/src/libclang/cxtokenizer.hpp +++ b/src/libclang/cxtokenizer.hpp @@ -191,7 +191,8 @@ namespace cppast void skip_brackets(cxtoken_stream& stream); // parses attributes - cpp_attribute_list parse_attributes(cxtoken_stream& stream); + // if skip_anyway is true it will bump even if no attributes have been parsed + cpp_attribute_list parse_attributes(cxtoken_stream& stream, bool skip_anyway = false); // converts a token range to a string cpp_token_string to_string(cxtoken_stream& stream, cxtoken_iterator end); diff --git a/src/libclang/function_parser.cpp b/src/libclang/function_parser.cpp index 1f84563..1861d6c 100644 --- a/src/libclang/function_parser.cpp +++ b/src/libclang/function_parser.cpp @@ -281,12 +281,9 @@ namespace result.is_explicit = true; else { - auto attributes = detail::parse_attributes(stream); - if (attributes.empty()) - stream.bump(); - else - result.attributes.insert(result.attributes.end(), attributes.begin(), - attributes.end()); + auto attributes = detail::parse_attributes(stream, true); + result.attributes.insert(result.attributes.end(), attributes.begin(), + attributes.end()); } } DEBUG_ASSERT(!stream.done(), detail::parse_error_handler{}, stream.cursor(), @@ -296,8 +293,7 @@ namespace } auto attributes = detail::parse_attributes(stream); - if (!attributes.empty()) - result.attributes.insert(result.attributes.end(), attributes.begin(), attributes.end()); + result.attributes.insert(result.attributes.end(), attributes.begin(), attributes.end()); return result; } diff --git a/src/libclang/variable_parser.cpp b/src/libclang/variable_parser.cpp index c45fb37..8403ed0 100644 --- a/src/libclang/variable_parser.cpp +++ b/src/libclang/variable_parser.cpp @@ -38,11 +38,8 @@ std::unique_ptr detail::parse_default_value(cpp_attribute_list& } else { - auto cur_attributes = detail::parse_attributes(stream); - if (cur_attributes.empty()) - stream.bump(); - else - attributes.insert(attributes.end(), cur_attributes.begin(), cur_attributes.end()); + auto cur_attributes = detail::parse_attributes(stream, true); + attributes.insert(attributes.end(), cur_attributes.begin(), cur_attributes.end()); } } if (has_default)