@@ -229,16 +229,19 @@ namespace
229229 bool is_friend = false ;
230230 };
231231
232- bool prefix_end (detail::cxtoken_stream& stream, const char * name, bool is_ctor )
232+ bool prefix_end (detail::cxtoken_stream& stream, const char * name, bool is_ctor_dtor )
233233 {
234234 auto cur = stream.cur ();
235235 // name can have multiple tokens if it is an operator
236236 if (!detail::skip_if (stream, name, true ))
237237 return false ;
238238 else if (stream.peek () == " ," || stream.peek () == " >" || stream.peek () == " >>" )
239+ {
239240 // argument to template parameters
241+ stream.set_cur (cur);
240242 return false ;
241- else if (is_ctor)
243+ }
244+ else if (is_ctor_dtor)
242245 {
243246 // need to make sure it is not actually a class name
244247 if (stream.peek () == " ::" )
@@ -269,15 +272,22 @@ namespace
269272 else
270273 return true ;
271274 }
275+ else if (std::strcmp (name, " operator" ) != 0 && stream.peek ().kind () == CXToken_Identifier)
276+ {
277+ // can't be function name
278+ stream.set_cur (cur);
279+ return false ;
280+ }
272281 else
273282 return true ;
274283 }
275284
276- prefix_info parse_prefix_info (detail::cxtoken_stream& stream, const char * name, bool is_ctor)
285+ prefix_info parse_prefix_info (detail::cxtoken_stream& stream, const char * name,
286+ bool is_ctor_dtor)
277287 {
278288 prefix_info result;
279289
280- while (!stream.done () && !prefix_end (stream, name, is_ctor ))
290+ while (!stream.done () && !prefix_end (stream, name, is_ctor_dtor ))
281291 {
282292 if (detail::skip_if (stream, " constexpr" ))
283293 result.is_constexpr = true ;
@@ -811,7 +821,7 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_destructor(const detail::parse_con
811821 detail::cxtokenizer tokenizer (context.tu , context.file , cur);
812822 detail::cxtoken_stream stream (tokenizer, cur);
813823
814- auto prefix_info = parse_prefix_info (stream, " ~" , false );
824+ auto prefix_info = parse_prefix_info (stream, " ~" , true );
815825 DEBUG_ASSERT (!prefix_info.is_constexpr && !prefix_info.is_explicit , detail::assert_handler{});
816826
817827 auto name = std::string (" ~" ) + stream.get ().c_str ();
0 commit comments