From 133d51b6302c46824d637455ca836fdba769c9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Wed, 12 Apr 2017 21:28:02 +0200 Subject: [PATCH] Workaround token issue in unnamed variadic template parameter --- src/libclang/tokenizer.cpp | 15 ++++++++++++++- test/cpp_template_parameter.cpp | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libclang/tokenizer.cpp b/src/libclang/tokenizer.cpp index 3e5725c..fc59d3c 100644 --- a/src/libclang/tokenizer.cpp +++ b/src/libclang/tokenizer.cpp @@ -166,6 +166,18 @@ namespace // now we found the proper end of the token end = get_next_location(tu, file, next, -1); } + else if ((kind == CXCursor_TemplateTypeParameter + || kind == CXCursor_NonTypeTemplateParameter + || kind == CXCursor_TemplateTemplateParameter) + && token_after_is(tu, file, cur, end, "...")) + { + // variadic tokens in unnamed parameter not included + end = get_next_location(tu, file, end, 3); + DEBUG_ASSERT(token_after_is(tu, file, cur, end, ">") + || token_after_is(tu, file, cur, end, ","), + detail::parse_error_handler{}, cur, + "unexpected token in variadic parameter workaround"); + } else if ((kind == CXCursor_TemplateTypeParameter || kind == CXCursor_NonTypeTemplateParameter || kind == CXCursor_TemplateTemplateParameter) @@ -173,7 +185,8 @@ namespace && !token_after_is(tu, file, cur, end, ",")) { DEBUG_ASSERT(token_after_is(tu, file, cur, get_next_location(tu, file, end, -2), ">>"), - detail::assert_handler{}); + detail::parse_error_handler{}, cur, + "unexpected token in maximal munch workaround"); unmunch = true; // need to shrink range anyway end = get_next_location(tu, file, end, -1); diff --git a/test/cpp_template_parameter.cpp b/test/cpp_template_parameter.cpp index 5bc3f04..faccfee 100644 --- a/test/cpp_template_parameter.cpp +++ b/test/cpp_template_parameter.cpp @@ -209,7 +209,7 @@ using b = void; template