From 76fb7dee43ab6b259ccb4a9f363db866b582c726 Mon Sep 17 00:00:00 2001 From: topisani Date: Wed, 20 Dec 2017 18:15:31 +0100 Subject: [PATCH] Parse C++17 nested namespace declarations This is maybe not the most correct way to do it, but i dont think it misparses any valid code. --- src/libclang/namespace_parser.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libclang/namespace_parser.cpp b/src/libclang/namespace_parser.cpp index c5d1cd9..e7df48f 100644 --- a/src/libclang/namespace_parser.cpp +++ b/src/libclang/namespace_parser.cpp @@ -18,13 +18,16 @@ namespace { detail::cxtokenizer tokenizer(context.tu, context.file, cur); detail::cxtoken_stream stream(tokenizer, cur); - // [inline] namespace [] { + // [inline] namespace|:: [] [{] auto is_inline = false; if (skip_if(stream, "inline")) is_inline = true; - skip(stream, "namespace"); + // C++17 nested namespace declarations + if (!detail::skip_if(stream, "namespace")) + skip(stream, "::"); + auto attributes = parse_attributes(stream); // { @@ -37,7 +40,9 @@ namespace auto other_attributes = parse_attributes(stream); attributes.insert(attributes.end(), other_attributes.begin(), other_attributes.end()); - skip(stream, "{"); + // C++17 nested namespace declarations + if (!detail::skip_if(stream, "::")) + skip(stream, "{"); auto result = cpp_namespace::builder(name.c_str(), is_inline); result.get().add_attribute(attributes);