正如我所看到的,这是解析结构内的方法定义时的普遍问题,而不是特定于代码完成。无论如何,解析器中有专门针对这种情况的特殊处理,您可以在ParseCXXInlineMethods.cpp 文件中找到。
从评论Parser::ParseCXXInlineMethodDef()
:
/// ParseCXXInlineMethodDef - We parsed and verified that the specified
/// Declarator is a well formed C++ inline method definition. Now lex its body
/// and store its tokens for parsing after the C++ class is complete.
Parser::DeclPtrTy
Parser::ParseCXXInlineMethodDef(...
稍后,用于解析方法定义的代码:
/// ParseLexedMethodDefs - We finished parsing the member specification of a top
/// (non-nested) C++ class. Now go over the stack of lexed methods that were
/// collected during its parsing and parse them all.
void Parser::ParseLexedMethodDefs(...
因此,函数体的词法分析器生成的标记仅在类的其余部分被解析后才被解析。