//===--- ParseCXXInlineMethods.cpp - C++ class inline methods parsing------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements parsing for C++ class inline methods. // //===----------------------------------------------------------------------===// #include "clang/AST/DeclTemplate.h" #include "clang/Parse/ParseDiagnostic.h" #include "clang/Parse/Parser.h" #include "clang/Parse/RAIIObjectsForParser.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/EnterExpressionEvaluationContext.h" #include "clang/Sema/Scope.h" usingnamespaceclang; /// Parse the optional ("message") part of a deleted-function-body. StringLiteral *Parser::ParseCXXDeletedFunctionMessage() { … } /// If we've encountered '= delete' in a context where it is ill-formed, such /// as in the declaration of a non-function, also skip the ("message") part if /// it is present to avoid issuing further diagnostics. void Parser::SkipDeletedFunctionBody() { … } /// 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. NamedDecl *Parser::ParseCXXInlineMethodDef( AccessSpecifier AS, const ParsedAttributesView &AccessAttrs, ParsingDeclarator &D, const ParsedTemplateInfo &TemplateInfo, const VirtSpecifiers &VS, SourceLocation PureSpecLoc) { … } /// ParseCXXNonStaticMemberInitializer - We parsed and verified that the /// specified Declarator is a well formed C++ non-static data member /// declaration. Now lex its initializer and store its tokens for parsing /// after the class is complete. void Parser::ParseCXXNonStaticMemberInitializer(Decl *VarD) { … } Parser::LateParsedDeclaration::~LateParsedDeclaration() { … } void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() { … } void Parser::LateParsedDeclaration::ParseLexedMemberInitializers() { … } void Parser::LateParsedDeclaration::ParseLexedMethodDefs() { … } void Parser::LateParsedDeclaration::ParseLexedAttributes() { … } void Parser::LateParsedDeclaration::ParseLexedPragmas() { … } Parser::LateParsedClass::LateParsedClass(Parser *P, ParsingClass *C) : … { … } Parser::LateParsedClass::~LateParsedClass() { … } void Parser::LateParsedClass::ParseLexedMethodDeclarations() { … } void Parser::LateParsedClass::ParseLexedMemberInitializers() { … } void Parser::LateParsedClass::ParseLexedMethodDefs() { … } void Parser::LateParsedClass::ParseLexedAttributes() { … } void Parser::LateParsedClass::ParseLexedPragmas() { … } void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() { … } void Parser::LexedMethod::ParseLexedMethodDefs() { … } void Parser::LateParsedMemberInitializer::ParseLexedMemberInitializers() { … } void Parser::LateParsedAttribute::ParseLexedAttributes() { … } void Parser::LateParsedPragma::ParseLexedPragmas() { … } /// Utility to re-enter a possibly-templated scope while parsing its /// late-parsed components. struct Parser::ReenterTemplateScopeRAII { … }; /// Utility to re-enter a class scope while parsing its late-parsed components. struct Parser::ReenterClassScopeRAII : ReenterTemplateScopeRAII { … }; /// ParseLexedMethodDeclarations - We finished parsing the member /// specification of a top (non-nested) C++ class. Now go over the /// stack of method declarations with some parts for which parsing was /// delayed (such as default arguments) and parse them. void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) { … } void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) { … } /// 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(ParsingClass &Class) { … } void Parser::ParseLexedMethodDef(LexedMethod &LM) { … } /// ParseLexedMemberInitializers - We finished parsing the member specification /// of a top (non-nested) C++ class. Now go over the stack of lexed data member /// initializers that were collected during its parsing and parse them all. void Parser::ParseLexedMemberInitializers(ParsingClass &Class) { … } void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) { … } /// Wrapper class which calls ParseLexedAttribute, after setting up the /// scope appropriately. void Parser::ParseLexedAttributes(ParsingClass &Class) { … } /// Parse all attributes in LAs, and attach them to Decl D. void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D, bool EnterScope, bool OnDefinition) { … } /// Finish parsing an attribute for which parsing was delayed. /// This will be called at the end of parsing a class declaration /// for each LateParsedAttribute. We consume the saved tokens and /// create an attribute with the arguments filled in. We add this /// to the Attribute list for the decl. void Parser::ParseLexedAttribute(LateParsedAttribute &LA, bool EnterScope, bool OnDefinition) { … } void Parser::ParseLexedPragmas(ParsingClass &Class) { … } void Parser::ParseLexedPragma(LateParsedPragma &LP) { … } /// ConsumeAndStoreUntil - Consume and store the token at the passed token /// container until the token 'T' is reached (which gets /// consumed/stored too, if ConsumeFinalToken). /// If StopAtSemi is true, then we will stop early at a ';' character. /// Returns true if token 'T1' or 'T2' was found. /// NOTE: This is a specialized version of Parser::SkipUntil. bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2, CachedTokens &Toks, bool StopAtSemi, bool ConsumeFinalToken) { … } /// Consume tokens and store them in the passed token container until /// we've passed the try keyword and constructor initializers and have consumed /// the opening brace of the function body. The opening brace will be consumed /// if and only if there was no error. /// /// \return True on error. bool Parser::ConsumeAndStoreFunctionPrologue(CachedTokens &Toks) { … } /// Consume and store tokens from the '?' to the ':' in a conditional /// expression. bool Parser::ConsumeAndStoreConditional(CachedTokens &Toks) { … } /// ConsumeAndStoreInitializer - Consume and store the token at the passed token /// container until the end of the current initializer expression (either a /// default argument or an in-class initializer for a non-static data member). /// /// Returns \c true if we reached the end of something initializer-shaped, /// \c false if we bailed out. bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks, CachedInitKind CIK) { … }