diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..aa318d75 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:24.10 + +RUN apt-get update && apt-get install -y \ + bash-completion \ + build-essential \ + clang-format \ + clangd \ + cmake \ + ninja-build \ + python3-pip \ + python3-venv \ + wget + +RUN wget -nd -P /tmp/ https://github.com/watchexec/watchexec/releases/download/v2.2.0/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb \ + && dpkg -i /tmp/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb \ + && rm -f /tmp/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb diff --git a/.devcontainer/ubuntu/devcontainer.json b/.devcontainer/devcontainer.json similarity index 50% rename from .devcontainer/ubuntu/devcontainer.json rename to .devcontainer/devcontainer.json index 9fd820fd..5df0c2dc 100644 --- a/.devcontainer/ubuntu/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "Ubuntu 24.04", + "name": "Ubuntu 24.10", "build": { "dockerfile": "Dockerfile" @@ -16,19 +16,23 @@ "postCreateCommand": "npm ci", "features": { + "ghcr.io/devcontainers/features/common-utils": {}, "ghcr.io/devcontainers/features/github-cli": "latest", - "ghcr.io/devcontainers/features/node": "latest", - "ghcr.io/devcontainers/features/docker-in-docker:2": {} + "ghcr.io/devcontainers/features/node": "latest" }, "customizations": { "vscode": { "extensions": [ - "ms-vscode.cpptools", - "ms-vscode.cmake-tools", - "esbenp.prettier-vscode", - "dbaeumer.vscode-eslint" - ] + "llvm-vs-code-extensions.vscode-clangd", + "llvm-vs-code-extensions.lldb-dap" + ], + "settings": { + "clangd.arguments": [ + "--compile-commands-dir=build", + "--completion-style=bundled" + ] + } } } } diff --git a/.devcontainer/ubuntu/Dockerfile b/.devcontainer/ubuntu/Dockerfile deleted file mode 100644 index 58b11421..00000000 --- a/.devcontainer/ubuntu/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM mcr.microsoft.com/devcontainers/cpp:ubuntu-24.04 - -RUN apt-get update && apt-get install -y \ - bash-completion \ - clang-format \ - python3-pip \ - python3-venv - -RUN wget -nd -P /tmp/ https://github.com/watchexec/watchexec/releases/download/v2.1.1/watchexec-2.1.1-$(uname -m)-unknown-linux-gnu.deb \ - && dpkg -i /tmp/watchexec-2.1.1-$(uname -m)-unknown-linux-gnu.deb \ - && rm -f /tmp/watchexec-2.1.1-$(uname -m)-unknown-linux-gnu.deb diff --git a/src/frontend/cxx/cli.cc b/src/frontend/cxx/cli.cc index 615485d8..840b6d30 100644 --- a/src/frontend/cxx/cli.cc +++ b/src/frontend/cxx/cli.cc @@ -68,7 +68,7 @@ struct CLIOptionDescr { std::string arg; std::string help; CLIOptionDescrKind kind; - bool CLI::*flag = nullptr; + bool CLI::* flag = nullptr; CLIOptionVisibility visibility{CLIOptionVisibility::kDefault}; CLIOptionDescr(std::string option, std::string arg, std::string help, @@ -88,7 +88,7 @@ struct CLIOptionDescr { kind(kind), visibility(visibility) {} - CLIOptionDescr(std::string option, std::string help, bool CLI::*flag, + CLIOptionDescr(std::string option, std::string help, bool CLI::* flag, CLIOptionVisibility visibility = CLIOptionVisibility::kDefault) : option(std::move(option)), help(std::move(help)), diff --git a/src/frontend/cxx/frontend.cc b/src/frontend/cxx/frontend.cc index 984fdd74..1d81a314 100644 --- a/src/frontend/cxx/frontend.cc +++ b/src/frontend/cxx/frontend.cc @@ -56,8 +56,8 @@ namespace { using namespace cxx; -auto readAll(const std::string& fileName, - std::istream& in) -> std::optional { +auto readAll(const std::string& fileName, std::istream& in) + -> std::optional { std::string code; char buffer[4 * 1024]; do { diff --git a/src/parser/cxx/control.cc b/src/parser/cxx/control.cc index 26b45776..44ed795a 100644 --- a/src/parser/cxx/control.cc +++ b/src/parser/cxx/control.cc @@ -343,8 +343,8 @@ auto Control::getLongDoubleType() -> const LongDoubleType* { return &d->longDoubleType; } -auto Control::getQualType(const Type* elementType, - CvQualifiers cvQualifiers) -> const QualType* { +auto Control::getQualType(const Type* elementType, CvQualifiers cvQualifiers) + -> const QualType* { return &*d->qualTypes.emplace(elementType, cvQualifiers).first; } @@ -360,8 +360,8 @@ auto Control::getConstVolatileType(const Type* elementType) -> const QualType* { return getQualType(elementType, CvQualifiers::kConstVolatile); } -auto Control::getBoundedArrayType(const Type* elementType, - std::size_t size) -> const BoundedArrayType* { +auto Control::getBoundedArrayType(const Type* elementType, std::size_t size) + -> const BoundedArrayType* { return &*d->boundedArrayTypes.emplace(elementType, size).first; } @@ -392,8 +392,8 @@ auto Control::getOverloadSetType(OverloadSetSymbol* symbol) auto Control::getFunctionType(const Type* returnType, std::vector parameterTypes, bool isVariadic, CvQualifiers cvQualifiers, - RefQualifier refQualifier, - bool isNoexcept) -> const FunctionType* { + RefQualifier refQualifier, bool isNoexcept) + -> const FunctionType* { return &*d->functionTypes .emplace(returnType, std::move(parameterTypes), isVariadic, cvQualifiers, refQualifier, isNoexcept) @@ -422,17 +422,19 @@ auto Control::getTemplateTypeParameterType(TemplateTypeParameterSymbol* symbol) return &*d->templateTypeParameterTypes.emplace(symbol).first; } -auto Control::getUnresolvedNameType( - TranslationUnit* unit, NestedNameSpecifierAST* nestedNameSpecifier, - UnqualifiedIdAST* unqualifiedId) -> const UnresolvedNameType* { +auto Control::getUnresolvedNameType(TranslationUnit* unit, + NestedNameSpecifierAST* nestedNameSpecifier, + UnqualifiedIdAST* unqualifiedId) + -> const UnresolvedNameType* { return &*d->unresolvedNameTypes .emplace(unit, nestedNameSpecifier, unqualifiedId) .first; } -auto Control::getUnresolvedBoundedArrayType( - TranslationUnit* unit, const Type* elementType, - ExpressionAST* sizeExpression) -> const UnresolvedBoundedArrayType* { +auto Control::getUnresolvedBoundedArrayType(TranslationUnit* unit, + const Type* elementType, + ExpressionAST* sizeExpression) + -> const UnresolvedBoundedArrayType* { return &*d->unresolvedBoundedArrayTypes .emplace(unit, elementType, sizeExpression) .first; diff --git a/src/parser/cxx/control.h b/src/parser/cxx/control.h index df5a81d1..2af7c7ce 100644 --- a/src/parser/cxx/control.h +++ b/src/parser/cxx/control.h @@ -108,8 +108,9 @@ class Control { -> const QualType*; [[nodiscard]] auto getConstVolatileType(const Type* elementType) -> const QualType*; - [[nodiscard]] auto getBoundedArrayType( - const Type* elementType, std::size_t size) -> const BoundedArrayType*; + [[nodiscard]] auto getBoundedArrayType(const Type* elementType, + std::size_t size) + -> const BoundedArrayType*; [[nodiscard]] auto getUnboundedArrayType(const Type* elementType) -> const UnboundedArrayType*; [[nodiscard]] auto getPointerType(const Type* elementType) @@ -123,14 +124,14 @@ class Control { [[nodiscard]] auto getFunctionType( const Type* returnType, std::vector parameterTypes, bool isVariadic = false, CvQualifiers cvQualifiers = CvQualifiers::kNone, - RefQualifier refQualifier = RefQualifier::kNone, - bool isNoexcept = false) -> const FunctionType*; + RefQualifier refQualifier = RefQualifier::kNone, bool isNoexcept = false) + -> const FunctionType*; [[nodiscard]] auto getMemberObjectPointerType(const ClassType* classType, const Type* elementType) -> const MemberObjectPointerType*; [[nodiscard]] auto getMemberFunctionPointerType( - const ClassType* classType, - const FunctionType* functionType) -> const MemberFunctionPointerType*; + const ClassType* classType, const FunctionType* functionType) + -> const MemberFunctionPointerType*; [[nodiscard]] auto getTypeParameterType(TypeParameterSymbol* symbol) -> const TypeParameterType*; [[nodiscard]] auto getTemplateTypeParameterType( diff --git a/src/parser/cxx/flatbuffers/ast_decoder.cc b/src/parser/cxx/flatbuffers/ast_decoder.cc index 9211e8ed..acf87712 100644 --- a/src/parser/cxx/flatbuffers/ast_decoder.cc +++ b/src/parser/cxx/flatbuffers/ast_decoder.cc @@ -59,8 +59,8 @@ auto ASTDecoder::decodeUnit(const void* ptr, io::Unit type) -> UnitAST* { } // switch } -auto ASTDecoder::decodeDeclaration(const void* ptr, - io::Declaration type) -> DeclarationAST* { +auto ASTDecoder::decodeDeclaration(const void* ptr, io::Declaration type) + -> DeclarationAST* { switch (type) { case io::Declaration_SimpleDeclaration: return decodeSimpleDeclaration( @@ -150,8 +150,8 @@ auto ASTDecoder::decodeDeclaration(const void* ptr, } // switch } -auto ASTDecoder::decodeStatement(const void* ptr, - io::Statement type) -> StatementAST* { +auto ASTDecoder::decodeStatement(const void* ptr, io::Statement type) + -> StatementAST* { switch (type) { case io::Statement_LabeledStatement: return decodeLabeledStatement( @@ -212,8 +212,8 @@ auto ASTDecoder::decodeStatement(const void* ptr, } // switch } -auto ASTDecoder::decodeExpression(const void* ptr, - io::Expression type) -> ExpressionAST* { +auto ASTDecoder::decodeExpression(const void* ptr, io::Expression type) + -> ExpressionAST* { switch (type) { case io::Expression_GeneratedLiteralExpression: return decodeGeneratedLiteralExpression( @@ -390,8 +390,9 @@ auto ASTDecoder::decodeExpression(const void* ptr, } // switch } -auto ASTDecoder::decodeTemplateParameter( - const void* ptr, io::TemplateParameter type) -> TemplateParameterAST* { +auto ASTDecoder::decodeTemplateParameter(const void* ptr, + io::TemplateParameter type) + -> TemplateParameterAST* { switch (type) { case io::TemplateParameter_TemplateTypeParameter: return decodeTemplateTypeParameter( @@ -410,8 +411,8 @@ auto ASTDecoder::decodeTemplateParameter( } // switch } -auto ASTDecoder::decodeSpecifier(const void* ptr, - io::Specifier type) -> SpecifierAST* { +auto ASTDecoder::decodeSpecifier(const void* ptr, io::Specifier type) + -> SpecifierAST* { switch (type) { case io::Specifier_GeneratedTypeSpecifier: return decodeGeneratedTypeSpecifier( @@ -526,8 +527,8 @@ auto ASTDecoder::decodeSpecifier(const void* ptr, } // switch } -auto ASTDecoder::decodePtrOperator(const void* ptr, - io::PtrOperator type) -> PtrOperatorAST* { +auto ASTDecoder::decodePtrOperator(const void* ptr, io::PtrOperator type) + -> PtrOperatorAST* { switch (type) { case io::PtrOperator_PointerOperator: return decodePointerOperator( @@ -562,8 +563,9 @@ auto ASTDecoder::decodeCoreDeclarator(const void* ptr, io::CoreDeclarator type) } // switch } -auto ASTDecoder::decodeDeclaratorChunk( - const void* ptr, io::DeclaratorChunk type) -> DeclaratorChunkAST* { +auto ASTDecoder::decodeDeclaratorChunk(const void* ptr, + io::DeclaratorChunk type) + -> DeclaratorChunkAST* { switch (type) { case io::DeclaratorChunk_FunctionDeclaratorChunk: return decodeFunctionDeclaratorChunk( @@ -608,8 +610,9 @@ auto ASTDecoder::decodeUnqualifiedId(const void* ptr, io::UnqualifiedId type) } // switch } -auto ASTDecoder::decodeNestedNameSpecifier( - const void* ptr, io::NestedNameSpecifier type) -> NestedNameSpecifierAST* { +auto ASTDecoder::decodeNestedNameSpecifier(const void* ptr, + io::NestedNameSpecifier type) + -> NestedNameSpecifierAST* { switch (type) { case io::NestedNameSpecifier_GlobalNestedNameSpecifier: return decodeGlobalNestedNameSpecifier( @@ -628,8 +631,8 @@ auto ASTDecoder::decodeNestedNameSpecifier( } // switch } -auto ASTDecoder::decodeFunctionBody(const void* ptr, - io::FunctionBody type) -> FunctionBodyAST* { +auto ASTDecoder::decodeFunctionBody(const void* ptr, io::FunctionBody type) + -> FunctionBodyAST* { switch (type) { case io::FunctionBody_DefaultFunctionBody: return decodeDefaultFunctionBody( @@ -648,8 +651,9 @@ auto ASTDecoder::decodeFunctionBody(const void* ptr, } // switch } -auto ASTDecoder::decodeTemplateArgument( - const void* ptr, io::TemplateArgument type) -> TemplateArgumentAST* { +auto ASTDecoder::decodeTemplateArgument(const void* ptr, + io::TemplateArgument type) + -> TemplateArgumentAST* { switch (type) { case io::TemplateArgument_TypeTemplateArgument: return decodeTypeTemplateArgument( @@ -662,8 +666,9 @@ auto ASTDecoder::decodeTemplateArgument( } // switch } -auto ASTDecoder::decodeExceptionSpecifier( - const void* ptr, io::ExceptionSpecifier type) -> ExceptionSpecifierAST* { +auto ASTDecoder::decodeExceptionSpecifier(const void* ptr, + io::ExceptionSpecifier type) + -> ExceptionSpecifierAST* { switch (type) { case io::ExceptionSpecifier_ThrowExceptionSpecifier: return decodeThrowExceptionSpecifier( @@ -676,8 +681,8 @@ auto ASTDecoder::decodeExceptionSpecifier( } // switch } -auto ASTDecoder::decodeRequirement(const void* ptr, - io::Requirement type) -> RequirementAST* { +auto ASTDecoder::decodeRequirement(const void* ptr, io::Requirement type) + -> RequirementAST* { switch (type) { case io::Requirement_SimpleRequirement: return decodeSimpleRequirement( @@ -765,8 +770,9 @@ auto ASTDecoder::decodeExceptionDeclaration(const void* ptr, } // switch } -auto ASTDecoder::decodeAttributeSpecifier( - const void* ptr, io::AttributeSpecifier type) -> AttributeSpecifierAST* { +auto ASTDecoder::decodeAttributeSpecifier(const void* ptr, + io::AttributeSpecifier type) + -> AttributeSpecifierAST* { switch (type) { case io::AttributeSpecifier_CxxAttribute: return decodeCxxAttribute(reinterpret_cast(ptr)); diff --git a/src/parser/cxx/literals.cc b/src/parser/cxx/literals.cc index 4c34b56b..5f37e34c 100644 --- a/src/parser/cxx/literals.cc +++ b/src/parser/cxx/literals.cc @@ -354,8 +354,9 @@ void IntegerLiteral::initialize() const { components_ = Components::from(value(), nullptr); } -auto IntegerLiteral::Components::from( - std::string_view text, DiagnosticsClient *diagnostics) -> Components { +auto IntegerLiteral::Components::from(std::string_view text, + DiagnosticsClient *diagnostics) + -> Components { std::string integerPart; integerPart.reserve(text.size()); @@ -576,8 +577,9 @@ void FloatLiteral::initialize() const { components_ = Components::from(value()); } -auto FloatLiteral::Components::from( - std::string_view text, DiagnosticsClient *diagnostics) -> Components { +auto FloatLiteral::Components::from(std::string_view text, + DiagnosticsClient *diagnostics) + -> Components { std::size_t pos = 0; auto LA = [&](int n = 0) -> int { @@ -730,8 +732,9 @@ auto FloatLiteral::Components::from( return components; } -auto StringLiteral::Components::from( - std::string_view text, DiagnosticsClient *diagnostics) -> Components { +auto StringLiteral::Components::from(std::string_view text, + DiagnosticsClient *diagnostics) + -> Components { StringLiteralParser parser(text, diagnostics); parser.parseStringLiteral(); @@ -746,8 +749,9 @@ void StringLiteral::initialize() const { components_ = Components::from(value()); } -auto CharLiteral::Components::from( - std::string_view text, DiagnosticsClient *diagnostics) -> Components { +auto CharLiteral::Components::from(std::string_view text, + DiagnosticsClient *diagnostics) + -> Components { StringLiteralParser parser(text, diagnostics); parser.parseCharLiteral(); diff --git a/src/parser/cxx/name_lookup.cc b/src/parser/cxx/name_lookup.cc index 5f4a2ba7..df548ae5 100644 --- a/src/parser/cxx/name_lookup.cc +++ b/src/parser/cxx/name_lookup.cc @@ -46,8 +46,8 @@ auto Lookup::qualifiedLookup(Scope* scope, const Name* name) const -> Symbol* { return lookupHelper(scope, name, cache); } -auto Lookup::qualifiedLookup(Symbol* scopedSymbol, - const Name* name) const -> Symbol* { +auto Lookup::qualifiedLookup(Symbol* scopedSymbol, const Name* name) const + -> Symbol* { if (!scopedSymbol) return nullptr; switch (scopedSymbol->kind()) { case SymbolKind::kNamespace: diff --git a/src/parser/cxx/parser.cc b/src/parser/cxx/parser.cc index 24d9f07b..9057fd30 100644 --- a/src/parser/cxx/parser.cc +++ b/src/parser/cxx/parser.cc @@ -706,8 +706,8 @@ struct Parser::TemplateHeadContext { struct Parser::ClassSpecifierContext { ClassSpecifierContext(const ClassSpecifierContext&) = delete; - auto operator=(const ClassSpecifierContext&) -> ClassSpecifierContext& = - delete; + auto operator=(const ClassSpecifierContext&) + -> ClassSpecifierContext& = delete; Parser* p; @@ -3030,8 +3030,8 @@ auto Parser::parse_noexcept_expression(ExpressionAST*& yyast, return true; } -auto Parser::parse_new_expression(ExpressionAST*& yyast, - const ExprContext& ctx) -> bool { +auto Parser::parse_new_expression(ExpressionAST*& yyast, const ExprContext& ctx) + -> bool { if (!lookat(TokenKind::T_NEW) && !lookat(TokenKind::T_COLON_COLON, TokenKind::T_NEW)) return false; @@ -3450,13 +3450,15 @@ auto Parser::parse_binary_expression_helper(ExpressionAST*& yyast, Prec minPrec, return parsed; } -auto Parser::parse_logical_or_expression( - ExpressionAST*& yyast, const ExprContext& exprContext) -> bool { +auto Parser::parse_logical_or_expression(ExpressionAST*& yyast, + const ExprContext& exprContext) + -> bool { return parse_binary_expression(yyast, exprContext); } -auto Parser::parse_conditional_expression( - ExpressionAST*& yyast, const ExprContext& exprContext) -> bool { +auto Parser::parse_conditional_expression(ExpressionAST*& yyast, + const ExprContext& exprContext) + -> bool { if (!parse_logical_or_expression(yyast, exprContext)) return false; SourceLocation questionLoc; @@ -3526,8 +3528,9 @@ void Parser::parse_assignment_expression(ExpressionAST*& yyast, } } -auto Parser::parse_maybe_assignment_expression( - ExpressionAST*& yyast, const ExprContext& exprContext) -> bool { +auto Parser::parse_maybe_assignment_expression(ExpressionAST*& yyast, + const ExprContext& exprContext) + -> bool { if (parse_yield_expression(yyast, exprContext)) return true; if (parse_throw_expression(yyast, exprContext)) return true; @@ -3570,8 +3573,8 @@ auto Parser::parse_maybe_assignment_expression( return true; } -auto Parser::parse_assignment_operator(SourceLocation& loc, - TokenKind& op) -> bool { +auto Parser::parse_assignment_operator(SourceLocation& loc, TokenKind& op) + -> bool { switch (TokenKind(LA())) { case TokenKind::T_EQUAL: case TokenKind::T_STAR_EQUAL: @@ -3625,8 +3628,9 @@ auto Parser::parse_maybe_expression(ExpressionAST*& yyast, return true; } -auto Parser::parse_constant_expression( - ExpressionAST*& yyast, std::optional& value) -> bool { +auto Parser::parse_constant_expression(ExpressionAST*& yyast, + std::optional& value) + -> bool { ExprContext exprContext; exprContext.isConstantEvaluated = true; if (!parse_conditional_expression(yyast, exprContext)) return false; @@ -3861,8 +3865,8 @@ auto Parser::parse_maybe_compound_statement(StatementAST*& yyast) -> bool { return false; } -auto Parser::parse_compound_statement(CompoundStatementAST*& yyast, - bool skip) -> bool { +auto Parser::parse_compound_statement(CompoundStatementAST*& yyast, bool skip) + -> bool { SourceLocation lbraceLoc; if (!match(TokenKind::T_LBRACE, lbraceLoc)) return false; @@ -4316,8 +4320,8 @@ auto Parser::parse_template_declaration_body( BindingContext::kTemplate); } -auto Parser::parse_declaration(DeclarationAST*& yyast, - BindingContext ctx) -> bool { +auto Parser::parse_declaration(DeclarationAST*& yyast, BindingContext ctx) + -> bool { if (lookat(TokenKind::T_RBRACE)) { return false; } else if (lookat(TokenKind::T_SEMICOLON)) { @@ -4345,8 +4349,8 @@ auto Parser::parse_declaration(DeclarationAST*& yyast, } } -auto Parser::parse_block_declaration(DeclarationAST*& yyast, - BindingContext ctx) -> bool { +auto Parser::parse_block_declaration(DeclarationAST*& yyast, BindingContext ctx) + -> bool { if (parse_asm_declaration(yyast)) return true; else if (parse_namespace_alias_definition(yyast)) @@ -4437,8 +4441,8 @@ auto Parser::parse_alias_declaration( return true; } -auto Parser::enterOrCreateNamespace(const Name* name, - bool isInline) -> NamespaceSymbol* { +auto Parser::enterOrCreateNamespace(const Name* name, bool isInline) + -> NamespaceSymbol* { auto parentScope = scope_; auto parentNamespace = symbol_cast(parentScope->owner()); @@ -5102,8 +5106,8 @@ auto Parser::parse_attribute_declaration(DeclarationAST*& yyast) -> bool { return true; } -auto Parser::parse_decl_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_decl_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { switch (TokenKind(LA())) { case TokenKind::T_TYPEDEF: { auto ast = new (pool_) TypedefSpecifierAST(); @@ -5272,8 +5276,8 @@ auto Parser::parse_storage_class_specifier(SpecifierAST*& yyast, return false; } -auto Parser::parse_function_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_function_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { SourceLocation virtualLoc; if (match(TokenKind::T_VIRTUAL, virtualLoc)) { @@ -5287,8 +5291,8 @@ auto Parser::parse_function_specifier(SpecifierAST*& yyast, return parse_explicit_specifier(yyast, specs); } -auto Parser::parse_explicit_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_explicit_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { SourceLocation explicitLoc; if (!match(TokenKind::T_EXPLICIT, explicitLoc)) return false; @@ -5313,8 +5317,8 @@ auto Parser::parse_explicit_specifier(SpecifierAST*& yyast, return true; } -auto Parser::parse_type_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { if (parse_simple_type_specifier(yyast, specs)) { return true; } else if (parse_cv_qualifier(yyast, specs)) { @@ -5440,8 +5444,8 @@ auto Parser::parse_defining_type_specifier_seq(List*& yyast, return true; } -auto Parser::parse_simple_type_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_simple_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { if (parse_size_type_specifier(yyast, specs)) return true; if (parse_sign_type_specifier(yyast, specs)) return true; if (parse_complex_type_specifier(yyast, specs)) return true; @@ -5471,8 +5475,8 @@ auto Parser::parse_simple_type_specifier(SpecifierAST*& yyast, return false; } -auto Parser::parse_size_type_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_size_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { if (SourceLocation specifierLoc; match(TokenKind::T_LONG, specifierLoc)) { auto ast = new (pool_) SizeTypeSpecifierAST(); yyast = ast; @@ -5501,8 +5505,8 @@ auto Parser::parse_size_type_specifier(SpecifierAST*& yyast, return false; } -auto Parser::parse_sign_type_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_sign_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { if (SourceLocation specifierLoc; match(TokenKind::T_UNSIGNED, specifierLoc)) { auto ast = new (pool_) SignTypeSpecifierAST(); yyast = ast; @@ -5573,8 +5577,8 @@ auto Parser::instantiate(SimpleTemplateIdAST* templateId) -> Symbol* { return symbol; } -auto Parser::parse_named_type_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_named_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { if (specs.isUnsigned || specs.isSigned || specs.isShort || specs.isLong) return false; @@ -5671,8 +5675,8 @@ auto Parser::parse_underlying_type_specifier(SpecifierAST*& yyast, return true; } -auto Parser::parse_atomic_type_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_atomic_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { SourceLocation atomicLoc; if (!match(TokenKind::T__ATOMIC, atomicLoc)) return false; @@ -6702,8 +6706,8 @@ auto Parser::parse_init_declarator(InitDeclaratorAST*& yyast, } auto Parser::parse_init_declarator(InitDeclaratorAST*& yyast, - DeclaratorAST* declarator, - Decl& decl) -> bool { + DeclaratorAST* declarator, Decl& decl) + -> bool { if (auto declId = decl.declaratorId; declId) { auto symbolType = GetDeclaratorType{this}(declarator, decl.specs.getType()); const auto name = convertName(declId->unqualifiedId); @@ -7036,8 +7040,8 @@ auto Parser::parse_ptr_operator(PtrOperatorAST*& yyast) -> bool { return true; } -auto Parser::parse_cv_qualifier(SpecifierAST*& yyast, - DeclSpecs& declSpecs) -> bool { +auto Parser::parse_cv_qualifier(SpecifierAST*& yyast, DeclSpecs& declSpecs) + -> bool { SourceLocation loc; if (match(TokenKind::T_CONST, loc)) { @@ -7339,8 +7343,8 @@ auto Parser::parse_parameter_declaration(ParameterDeclarationAST*& yyast, return true; } -auto Parser::parse_initializer(ExpressionAST*& yyast, - const ExprContext& ctx) -> bool { +auto Parser::parse_initializer(ExpressionAST*& yyast, const ExprContext& ctx) + -> bool { SourceLocation lparenLoc; if (match(TokenKind::T_LPAREN, lparenLoc)) { @@ -7649,8 +7653,8 @@ auto Parser::parse_function_body(FunctionBodyAST*& yyast) -> bool { return true; } -auto Parser::parse_enum_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_enum_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { LookaheadParser lookahead{this}; SourceLocation enumLoc; @@ -7785,8 +7789,8 @@ auto Parser::parse_opaque_enum_declaration(DeclarationAST*& yyast) -> bool { return true; } -auto Parser::parse_enum_key(SourceLocation& enumLoc, - SourceLocation& classLoc) -> bool { +auto Parser::parse_enum_key(SourceLocation& enumLoc, SourceLocation& classLoc) + -> bool { if (!match(TokenKind::T_ENUM, enumLoc)) return false; if (match(TokenKind::T_CLASS, classLoc)) { @@ -8964,8 +8968,8 @@ void Parser::parse_private_module_fragment(PrivateModuleFragmentAST*& yyast) { parse_declaration_seq(yyast->declarationList); } -auto Parser::parse_class_specifier(ClassSpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_class_specifier(ClassSpecifierAST*& yyast, DeclSpecs& specs) + -> bool { std::vector templateDeclarations; return parse_class_specifier(yyast, specs, templateDeclarations); } @@ -9592,9 +9596,10 @@ auto Parser::parse_conversion_function_id(ConversionFunctionIdAST*& yyast) return true; } -auto Parser::parse_base_clause( - ClassSymbol* classSymbol, SourceLocation& colonLoc, - List*& baseSpecifierList) -> bool { +auto Parser::parse_base_clause(ClassSymbol* classSymbol, + SourceLocation& colonLoc, + List*& baseSpecifierList) + -> bool { if (!match(TokenKind::T_COLON, colonLoc)) return false; if (!parse_base_specifier_list(classSymbol, baseSpecifierList)) { @@ -9604,8 +9609,9 @@ auto Parser::parse_base_clause( return true; } -auto Parser::parse_base_specifier_list( - ClassSymbol* classSymbol, List*& yyast) -> bool { +auto Parser::parse_base_specifier_list(ClassSymbol* classSymbol, + List*& yyast) + -> bool { auto it = &yyast; BaseSpecifierAST* baseSpecifier = nullptr; @@ -9769,8 +9775,8 @@ auto Parser::parse_access_specifier(SourceLocation& loc) -> bool { } auto Parser::parse_ctor_initializer( - SourceLocation& colonLoc, - List*& memInitializerList) -> bool { + SourceLocation& colonLoc, List*& memInitializerList) + -> bool { if (!match(TokenKind::T_COLON, colonLoc)) return false; parse_mem_initializer_list(memInitializerList); @@ -9842,8 +9848,8 @@ void Parser::parse_mem_initializer(MemInitializerAST*& yyast) { } auto Parser::parse_mem_initializer_id( - NestedNameSpecifierAST*& yynestedNameSpecifier, - UnqualifiedIdAST*& yyast) -> bool { + NestedNameSpecifierAST*& yynestedNameSpecifier, UnqualifiedIdAST*& yyast) + -> bool { auto lookat_class_or_decltype = [&] { LookaheadParser lookahead{this}; NestedNameSpecifierAST* nestedNameSpecifier = nullptr; @@ -9895,8 +9901,8 @@ auto Parser::parse_operator_function_id(OperatorFunctionIdAST*& yyast) -> bool { } auto Parser::parse_operator(TokenKind& op, SourceLocation& opLoc, - SourceLocation& openLoc, - SourceLocation& closeLoc) -> bool { + SourceLocation& openLoc, SourceLocation& closeLoc) + -> bool { op = TokenKind(LA()); switch (op) { case TokenKind::T_LPAREN: @@ -10124,8 +10130,9 @@ auto Parser::parse_requires_clause(RequiresClauseAST*& yyast) -> bool { return true; } -auto Parser::parse_constraint_logical_or_expression( - ExpressionAST*& yyast, const ExprContext& ctx) -> bool { +auto Parser::parse_constraint_logical_or_expression(ExpressionAST*& yyast, + const ExprContext& ctx) + -> bool { if (!parse_constraint_logical_and_expression(yyast, ctx)) return false; SourceLocation opLoc; @@ -10148,8 +10155,9 @@ auto Parser::parse_constraint_logical_or_expression( return true; } -auto Parser::parse_constraint_logical_and_expression( - ExpressionAST*& yyast, const ExprContext& ctx) -> bool { +auto Parser::parse_constraint_logical_and_expression(ExpressionAST*& yyast, + const ExprContext& ctx) + -> bool { if (!parse_primary_expression(yyast, ctx)) return false; SourceLocation opLoc; @@ -10789,8 +10797,8 @@ auto Parser::parse_concept_definition(DeclarationAST*& yyast) -> bool { return true; } -auto Parser::parse_splicer_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_splicer_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { if (!config_.reflect) return false; if (specs.typeSpecifier) return false; LookaheadParser lookahead{this}; @@ -10807,8 +10815,8 @@ auto Parser::parse_splicer_specifier(SpecifierAST*& yyast, return true; } -auto Parser::parse_typename_specifier(SpecifierAST*& yyast, - DeclSpecs& specs) -> bool { +auto Parser::parse_typename_specifier(SpecifierAST*& yyast, DeclSpecs& specs) + -> bool { if (specs.typeSpecifier) return false; SourceLocation typenameLoc; @@ -11090,8 +11098,8 @@ auto Parser::convertName(UnqualifiedIdAST* id) -> const Name* { if (!id) return nullptr; return visit(ConvertToName{control_}, id); } -auto Parser::getFunction(Scope* scope, const Name* name, - const Type* type) -> FunctionSymbol* { +auto Parser::getFunction(Scope* scope, const Name* name, const Type* type) + -> FunctionSymbol* { for (auto candidate : scope->get(name)) { if (auto function = symbol_cast(candidate)) { if (control_->is_same(function->type(), type)) { diff --git a/src/parser/cxx/parser.h b/src/parser/cxx/parser.h index cf3d18c8..0308090e 100644 --- a/src/parser/cxx/parser.h +++ b/src/parser/cxx/parser.h @@ -152,8 +152,8 @@ class Parser final { void parse_translation_unit(UnitAST*& yyast); - [[nodiscard]] auto parse_id(const Identifier* id, - SourceLocation& loc) -> bool; + [[nodiscard]] auto parse_id(const Identifier* id, SourceLocation& loc) + -> bool; [[nodiscard]] auto parse_nospace() -> bool; [[nodiscard]] auto parse_greater_greater() -> bool; [[nodiscard]] auto parse_header_name(SourceLocation& loc) -> bool; @@ -216,8 +216,8 @@ class Parser final { const ExprContext& ctx) -> bool; [[nodiscard]] auto parse_left_fold_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_fold_operator(SourceLocation& loc, - TokenKind& op) -> bool; + [[nodiscard]] auto parse_fold_operator(SourceLocation& loc, TokenKind& op) + -> bool; [[nodiscard]] auto parse_requires_expression(ExpressionAST*& yyast) -> bool; [[nodiscard]] auto parse_requirement_parameter_list( SourceLocation& lparenLoc, @@ -229,13 +229,14 @@ class Parser final { [[nodiscard]] auto parse_type_requirement(RequirementAST*& yyast) -> bool; [[nodiscard]] auto parse_compound_requirement(RequirementAST*& yyast) -> bool; [[nodiscard]] auto parse_return_type_requirement( - SourceLocation& minusGreaterLoc, - TypeConstraintAST*& typeConstraint) -> bool; + SourceLocation& minusGreaterLoc, TypeConstraintAST*& typeConstraint) + -> bool; [[nodiscard]] auto parse_nested_requirement(RequirementAST*& yyast) -> bool; [[nodiscard]] auto parse_postfix_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_start_of_postfix_expression( - ExpressionAST*& yyast, const ExprContext& ctx) -> bool; + [[nodiscard]] auto parse_start_of_postfix_expression(ExpressionAST*& yyast, + const ExprContext& ctx) + -> bool; [[nodiscard]] auto parse_member_expression(ExpressionAST*& yyast) -> bool; [[nodiscard]] auto parse_subscript_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; @@ -246,20 +247,24 @@ class Parser final { [[nodiscard]] auto parse_cpp_cast_head(SourceLocation& loc) -> bool; [[nodiscard]] auto parse_cpp_cast_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_builtin_bit_cast_expression( - ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_cpp_type_cast_expression( - ExpressionAST*& yyast, const ExprContext& ctx) -> bool; + [[nodiscard]] auto parse_builtin_bit_cast_expression(ExpressionAST*& yyast, + const ExprContext& ctx) + -> bool; + [[nodiscard]] auto parse_cpp_type_cast_expression(ExpressionAST*& yyast, + const ExprContext& ctx) + -> bool; [[nodiscard]] auto parse_typeid_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; [[nodiscard]] auto parse_typename_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_type_traits_op( - SourceLocation& loc, BuiltinTypeTraitKind& builtinKind) -> bool; + [[nodiscard]] auto parse_type_traits_op(SourceLocation& loc, + BuiltinTypeTraitKind& builtinKind) + -> bool; [[nodiscard]] auto parse_va_arg_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_builtin_call_expression( - ExpressionAST*& yyast, const ExprContext& ctx) -> bool; + [[nodiscard]] auto parse_builtin_call_expression(ExpressionAST*& yyast, + const ExprContext& ctx) + -> bool; [[nodiscard]] auto parse_expression_list(List*& yyast, const ExprContext& ctx) -> bool; [[nodiscard]] auto parse_unary_expression(ExpressionAST*& yyast, @@ -287,21 +292,24 @@ class Parser final { const ExprContext& ctx) -> bool; [[nodiscard]] auto parse_cast_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_cast_expression_helper( - ExpressionAST*& yyast, const ExprContext& ctx) -> bool; + [[nodiscard]] auto parse_cast_expression_helper(ExpressionAST*& yyast, + const ExprContext& ctx) + -> bool; [[nodiscard]] auto parse_binary_operator(SourceLocation& loc, TokenKind& tk, const ExprContext& exprContext) -> bool; - [[nodiscard]] auto parse_binary_expression( - ExpressionAST*& yyast, const ExprContext& exprContext) -> bool; + [[nodiscard]] auto parse_binary_expression(ExpressionAST*& yyast, + const ExprContext& exprContext) + -> bool; [[nodiscard]] auto parse_lookahead_binary_operator( - SourceLocation& loc, TokenKind& tk, - const ExprContext& exprContext) -> bool; + SourceLocation& loc, TokenKind& tk, const ExprContext& exprContext) + -> bool; [[nodiscard]] auto parse_binary_expression_helper( - ExpressionAST*& yyast, Prec minPrec, - const ExprContext& exprContext) -> bool; - [[nodiscard]] auto parse_logical_or_expression( - ExpressionAST*& yyast, const ExprContext& exprContext) -> bool; + ExpressionAST*& yyast, Prec minPrec, const ExprContext& exprContext) + -> bool; + [[nodiscard]] auto parse_logical_or_expression(ExpressionAST*& yyast, + const ExprContext& exprContext) + -> bool; [[nodiscard]] auto parse_conditional_expression( ExpressionAST*& yyast, const ExprContext& exprContext) -> bool; [[nodiscard]] auto parse_yield_expression(ExpressionAST*& yyast, @@ -317,8 +325,9 @@ class Parser final { void parse_expression(ExpressionAST*& yyast, const ExprContext& ctx); [[nodiscard]] auto parse_maybe_expression(ExpressionAST*& yyast, const ExprContext& ctx) -> bool; - [[nodiscard]] auto parse_constant_expression( - ExpressionAST*& yyast, std::optional& value) -> bool; + [[nodiscard]] auto parse_constant_expression(ExpressionAST*& yyast, + std::optional& value) + -> bool; [[nodiscard]] auto parse_template_argument_constant_expression( ExpressionAST*& yyast) -> bool; void parse_statement(StatementAST*& yyast); @@ -486,21 +495,23 @@ class Parser final { [[nodiscard]] auto parse_declarator_id(CoreDeclaratorAST*& yyast, Decl& decl, DeclaratorKind declaratorKind) -> bool; - [[nodiscard]] auto parse_nested_declarator( - CoreDeclaratorAST*& yyast, Decl& decl, - DeclaratorKind declaratorKind) -> bool; + [[nodiscard]] auto parse_nested_declarator(CoreDeclaratorAST*& yyast, + Decl& decl, + DeclaratorKind declaratorKind) + -> bool; void parse_optional_abstract_declarator(DeclaratorAST*& yyastl, Decl& decl); [[nodiscard]] auto parse_ptr_operator_seq(List*& yyast) -> bool; - [[nodiscard]] auto parse_core_declarator( - CoreDeclaratorAST*& yyast, Decl& decl, - DeclaratorKind declaratorKind) -> bool; + [[nodiscard]] auto parse_core_declarator(CoreDeclaratorAST*& yyast, + Decl& decl, + DeclaratorKind declaratorKind) + -> bool; [[nodiscard]] auto parse_array_declarator(ArrayDeclaratorChunkAST*& yyast) -> bool; [[nodiscard]] auto parse_function_declarator( - FunctionDeclaratorChunkAST*& yyast, - bool acceptTrailingReturnType = true) -> bool; + FunctionDeclaratorChunkAST*& yyast, bool acceptTrailingReturnType = true) + -> bool; [[nodiscard]] auto parse_cv_qualifier_seq(List*& yyast, DeclSpecs& declSpecs) -> bool; [[nodiscard]] auto parse_trailing_return_type(TrailingReturnTypeAST*& yyast) @@ -587,8 +598,8 @@ class Parser final { -> bool; [[nodiscard]] auto parse_attribute_specifier( - AttributeSpecifierAST*& yyast, - AllowedAttributes allowedAttributes) -> bool; + AttributeSpecifierAST*& yyast, AllowedAttributes allowedAttributes) + -> bool; auto lookat_cxx_attribute_specifier() -> bool; [[nodiscard]] auto parse_cxx_attribute_specifier( @@ -628,8 +639,8 @@ class Parser final { void parse_class_body(List*& yyast); [[nodiscard]] auto parse_class_head(ClassHead& classHead) -> bool; [[nodiscard]] auto parse_class_head_name( - NestedNameSpecifierAST*& nestedNameSpecifier, - UnqualifiedIdAST*& yyast) -> bool; + NestedNameSpecifierAST*& nestedNameSpecifier, UnqualifiedIdAST*& yyast) + -> bool; [[nodiscard]] auto parse_class_virt_specifier(SourceLocation& loc) -> bool; [[nodiscard]] auto parse_class_key(SourceLocation& classLoc) -> bool; [[nodiscard]] auto parse_member_specification(DeclarationAST*& yyast) -> bool; @@ -652,21 +663,22 @@ class Parser final { [[nodiscard]] auto parse_base_clause( ClassSymbol* classSymbol, SourceLocation& colonLoc, List*& baseSpecifierList) -> bool; - [[nodiscard]] auto parse_base_specifier_list( - ClassSymbol* classSymbol, List*& yyast) -> bool; + [[nodiscard]] auto parse_base_specifier_list(ClassSymbol* classSymbol, + List*& yyast) + -> bool; void parse_base_specifier(BaseSpecifierAST*& yyast); [[nodiscard]] auto parse_class_or_decltype( NestedNameSpecifierAST*& nestedNameSpecifier, SourceLocation& templateLoc, UnqualifiedIdAST*& unqualifiedId) -> bool; [[nodiscard]] auto parse_access_specifier(SourceLocation& loc) -> bool; [[nodiscard]] auto parse_ctor_initializer( - SourceLocation& colonLoc, - List*& memInitializerList) -> bool; + SourceLocation& colonLoc, List*& memInitializerList) + -> bool; void parse_mem_initializer_list(List*& yyast); void parse_mem_initializer(MemInitializerAST*& yyast); [[nodiscard]] auto parse_mem_initializer_id( - NestedNameSpecifierAST*& nestedNameSpecifier, - UnqualifiedIdAST*& yyast) -> bool; + NestedNameSpecifierAST*& nestedNameSpecifier, UnqualifiedIdAST*& yyast) + -> bool; [[nodiscard]] auto parse_operator_function_id(OperatorFunctionIdAST*& yyast) -> bool; [[nodiscard]] auto parse_operator(TokenKind& op, SourceLocation& opLoc, @@ -694,8 +706,9 @@ class Parser final { TemplateParameterAST*& yyast) -> bool; [[nodiscard]] auto parse_type_parameter_key(SourceLocation& classKeyLoc) -> bool; - [[nodiscard]] auto parse_type_constraint( - TypeConstraintAST*& yyast, bool parsingPlaceholderTypeSpec) -> bool; + [[nodiscard]] auto parse_type_constraint(TypeConstraintAST*& yyast, + bool parsingPlaceholderTypeSpec) + -> bool; [[nodiscard]] auto parse_simple_template_or_name_id( UnqualifiedIdAST*& yyast, NestedNameSpecifierAST* nestedNameSpecifier, bool isTemplateIntroduced) -> bool; @@ -773,8 +786,8 @@ class Parser final { [[nodiscard]] auto getFunction(Scope* scope, const Name* name, const Type* type) -> FunctionSymbol*; - [[nodiscard]] auto enterOrCreateNamespace(const Name* name, - bool isInline) -> NamespaceSymbol*; + [[nodiscard]] auto enterOrCreateNamespace(const Name* name, bool isInline) + -> NamespaceSymbol*; void enterFunctionScope(FunctionDeclaratorChunkAST* functionDeclarator); @@ -795,28 +808,34 @@ class Parser final { [[nodiscard]] auto floating_point_promotion(ExpressionAST*& expr) -> bool; [[nodiscard]] auto integral_conversion(ExpressionAST*& expr, const Type* destinationType) -> bool; - [[nodiscard]] auto floating_point_conversion( - ExpressionAST*& expr, const Type* destinationType) -> bool; - [[nodiscard]] auto floating_integral_conversion( - ExpressionAST*& expr, const Type* destinationType) -> bool; + [[nodiscard]] auto floating_point_conversion(ExpressionAST*& expr, + const Type* destinationType) + -> bool; + [[nodiscard]] auto floating_integral_conversion(ExpressionAST*& expr, + const Type* destinationType) + -> bool; [[nodiscard]] auto pointer_conversion(ExpressionAST*& expr, const Type* destinationType) -> bool; - [[nodiscard]] auto pointer_to_member_conversion( - ExpressionAST*& expr, const Type* destinationType) -> bool; - [[nodiscard]] auto function_pointer_conversion( - ExpressionAST*& expr, const Type* destinationType) -> bool; + [[nodiscard]] auto pointer_to_member_conversion(ExpressionAST*& expr, + const Type* destinationType) + -> bool; + [[nodiscard]] auto function_pointer_conversion(ExpressionAST*& expr, + const Type* destinationType) + -> bool; [[nodiscard]] auto boolean_conversion(ExpressionAST*& expr, const Type* destinationType) -> bool; [[nodiscard]] auto temporary_materialization_conversion(ExpressionAST*& expr) -> bool; - [[nodiscard]] auto qualification_conversion( - ExpressionAST*& expr, const Type* destinationType) -> bool; + [[nodiscard]] auto qualification_conversion(ExpressionAST*& expr, + const Type* destinationType) + -> bool; [[nodiscard]] auto implicit_conversion(ExpressionAST*& expr, const Type* destinationType) -> bool; - [[nodiscard]] auto usual_arithmetic_conversion( - ExpressionAST*& expr, ExpressionAST*& other) -> const Type*; + [[nodiscard]] auto usual_arithmetic_conversion(ExpressionAST*& expr, + ExpressionAST*& other) + -> const Type*; [[nodiscard]] auto is_null_pointer_constant(ExpressionAST* expr) const -> bool; diff --git a/src/parser/cxx/preprocessor.cc b/src/parser/cxx/preprocessor.cc index c07548e8..24b2a1d8 100644 --- a/src/parser/cxx/preprocessor.cc +++ b/src/parser/cxx/preprocessor.cc @@ -263,14 +263,14 @@ struct std::less { return names < hideset.names(); } - auto operator()(const Hideset &hideset, - const std::string_view &name) const -> bool { + auto operator()(const Hideset &hideset, const std::string_view &name) const + -> bool { return std::lexicographical_compare(begin(hideset.names()), end(hideset.names()), &name, &name + 1); } - auto operator()(const std::string_view &name, - const Hideset &hideset) const -> bool { + auto operator()(const std::string_view &name, const Hideset &hideset) const + -> bool { return std::lexicographical_compare( &name, &name + 1, begin(hideset.names()), end(hideset.names())); } @@ -321,13 +321,13 @@ struct std::equal_to { return hideset.names() == names; } - auto operator()(const Hideset &hideset, - const std::string_view &name) const -> bool { + auto operator()(const Hideset &hideset, const std::string_view &name) const + -> bool { return hideset.names().size() == 1 && *hideset.names().begin() == name; } - auto operator()(const std::string_view &name, - const Hideset &hideset) const -> bool { + auto operator()(const std::string_view &name, const Hideset &hideset) const + -> bool { return hideset.names().size() == 1 && *hideset.names().begin() == name; } }; @@ -422,8 +422,8 @@ struct TokList final : Managed { explicit TokList(const Tok *tok, const TokList *next = nullptr) : tok(tok), next(next) {} - [[nodiscard]] static auto isSame(const TokList *ls, - const TokList *rs) -> bool { + [[nodiscard]] static auto isSame(const TokList *ls, const TokList *rs) + -> bool { if (ls == rs) return true; if (!ls || !rs) return false; if (ls->tok->kind != rs->tok->kind) return false; @@ -778,13 +778,13 @@ struct Preprocessor::Private { return cons(ts->tok, clone(ts->next)); } - [[nodiscard]] auto cons(const Tok *tok, - const TokList *next = nullptr) -> TokList * { + [[nodiscard]] auto cons(const Tok *tok, const TokList *next = nullptr) + -> TokList * { return new (&pool_) TokList(tok, next); } - [[nodiscard]] auto snoc(const TokList *first, - const TokList *second) -> const TokList * { + [[nodiscard]] auto snoc(const TokList *first, const TokList *second) + -> const TokList * { if (!first) return second; if (!second) return first; @@ -815,13 +815,13 @@ struct Preprocessor::Private { return toTokList(std::ranges::begin(range), std::ranges::end(range)); } - [[nodiscard]] auto withHideset(const Tok *tok, - const Hideset *hideset) -> Tok * { + [[nodiscard]] auto withHideset(const Tok *tok, const Hideset *hideset) + -> Tok * { return Tok::WithHideset(&pool_, tok, hideset); } - [[nodiscard]] auto fromCurrentToken(const Lexer &lex, - int sourceFile) -> Tok * { + [[nodiscard]] auto fromCurrentToken(const Lexer &lex, int sourceFile) + -> Tok * { return Tok::FromCurrentToken(&pool_, lex, sourceFile); } @@ -857,8 +857,8 @@ struct Preprocessor::Private { return nullptr; } - [[nodiscard]] auto createSourceFile(std::string fileName, - std::string source) -> SourceFile * { + [[nodiscard]] auto createSourceFile(std::string fileName, std::string source) + -> SourceFile * { if (sourceFiles_.size() >= 4096) { cxx_runtime_error("too many source files"); } @@ -890,8 +890,8 @@ struct Preprocessor::Private { return false; } - [[nodiscard]] auto match(TokIterator &it, TokIterator last, - TokenKind k) const -> bool { + [[nodiscard]] auto match(TokIterator &it, TokIterator last, TokenKind k) const + -> bool { if (it == last) return false; if (it->isNot(k)) return false; ++it; @@ -933,8 +933,8 @@ struct Preprocessor::Private { return get(std::move(names)); } - [[nodiscard]] auto makeIntersection(const Hideset *hs, - const Hideset *other) -> const Hideset * { + [[nodiscard]] auto makeIntersection(const Hideset *hs, const Hideset *other) + -> const Hideset * { if (!other || !hs) return nullptr; if (other == hs) return hs; @@ -971,8 +971,8 @@ struct Preprocessor::Private { } // switch } - [[nodiscard]] auto updateStringLiteralValue(Token &lastToken, - const Tok *tk) -> bool { + [[nodiscard]] auto updateStringLiteralValue(Token &lastToken, const Tok *tk) + -> bool { if (!isStringLiteral(lastToken.kind())) { return false; } @@ -1035,8 +1035,8 @@ struct Preprocessor::Private { [[nodiscard]] auto checkPragmaOnceProtected(const TokList *ts) const -> bool; - [[nodiscard]] auto resolve(const Include &include, - bool next) const -> std::optional { + [[nodiscard]] auto resolve(const Include &include, bool next) const + -> std::optional { if (!canResolveFiles_) return std::nullopt; struct Resolve { @@ -1141,11 +1141,13 @@ struct Preprocessor::Private { [[nodiscard]] auto expandMacro(const TokList *ts) -> const TokList *; - [[nodiscard]] auto expandObjectLikeMacro( - const TokList *ts, const Macro *macro) -> const TokList *; + [[nodiscard]] auto expandObjectLikeMacro(const TokList *ts, + const Macro *macro) + -> const TokList *; - [[nodiscard]] auto expandFunctionLikeMacro( - const TokList *ts, const Macro *macro) -> const TokList *; + [[nodiscard]] auto expandFunctionLikeMacro(const TokList *ts, + const Macro *macro) + -> const TokList *; struct ParsedIncludeDirective { Include header; @@ -1174,8 +1176,8 @@ struct Preprocessor::Private { [[nodiscard]] auto stringize(const TokList *ts) -> const Tok *; - [[nodiscard]] auto instantiate(const TokList *ts, - const Hideset *hideset) -> const TokList *; + [[nodiscard]] auto instantiate(const TokList *ts, const Hideset *hideset) + -> const TokList *; [[nodiscard]] auto lookupMacro(const Tok *tk) const -> const Macro *; @@ -1217,8 +1219,8 @@ struct Preprocessor::ParseArguments { Private &d; template S> - auto operator()(TokIterator it, S last, int formalCount, - bool ignoreComma) -> std::optional { + auto operator()(TokIterator it, S last, int formalCount, bool ignoreComma) + -> std::optional { if (!cxx::lookat(it, last, TokenKind::T_LPAREN)) { cxx_runtime_error("expected '('"); return std::nullopt; @@ -1567,8 +1569,8 @@ void Preprocessor::Private::finalizeToken(std::vector &tokens, }; auto Preprocessor::Private::tokenize(const std::string_view &source, - int sourceFile, - bool bol) -> const TokList * { + int sourceFile, bool bol) + -> const TokList * { cxx::Lexer lex(source); lex.setKeepComments(true); lex.setPreprocessing(true); @@ -2067,8 +2069,9 @@ auto Preprocessor::Private::expandMacro(const TokList *ts) -> const TokList * { return nullptr; } -auto Preprocessor::Private::expandObjectLikeMacro( - const TokList *ts, const Macro *m) -> const TokList * { +auto Preprocessor::Private::expandObjectLikeMacro(const TokList *ts, + const Macro *m) + -> const TokList * { auto macro = &std::get(*m); const Tok *tk = ts->tok; @@ -2091,8 +2094,9 @@ auto Preprocessor::Private::expandObjectLikeMacro( return expanded; } -auto Preprocessor::Private::expandFunctionLikeMacro( - const TokList *ts, const Macro *m) -> const TokList * { +auto Preprocessor::Private::expandFunctionLikeMacro(const TokList *ts, + const Macro *m) + -> const TokList * { auto macro = &std::get(*m); assert(lookat(ts->next, TokenKind::T_LPAREN)); @@ -2122,9 +2126,10 @@ auto Preprocessor::Private::expandFunctionLikeMacro( return expanded; } -auto Preprocessor::Private::substitute( - const Macro *macro, const std::vector &actuals, - const Hideset *hideset) -> const TokList * { +auto Preprocessor::Private::substitute(const Macro *macro, + const std::vector &actuals, + const Hideset *hideset) + -> const TokList * { const TokList *os = nullptr; auto **ip = const_cast(&os); @@ -2214,8 +2219,8 @@ auto Preprocessor::Private::substitute( } auto Preprocessor::Private::lookupMacroArgument( - const TokList *&ts, const Macro *m, - const std::vector &actuals) -> std::optional { + const TokList *&ts, const Macro *m, const std::vector &actuals) + -> std::optional { if (!isFunctionLikeMacro(*m)) return std::nullopt; const FunctionMacro *macro = &std::get(*m); @@ -2517,8 +2522,9 @@ auto Preprocessor::Private::primaryExpression(const TokList *&ts) -> long { return 0; } -auto Preprocessor::Private::instantiate( - const TokList *ts, const Hideset *hideset) -> const TokList * { +auto Preprocessor::Private::instantiate(const TokList *ts, + const Hideset *hideset) + -> const TokList * { for (auto ip = ts; ip; ip = ip->next) { if (ip->tok->hideset != hideset) { const_cast(ip)->tok = withHideset(ip->tok, hideset); @@ -2640,8 +2646,8 @@ void Preprocessor::Private::defineMacro(const TokList *ts) { macros_.insert_or_assign(name, std::move(macro)); } -auto Preprocessor::Private::merge(const Tok *left, - const Tok *right) -> const Tok * { +auto Preprocessor::Private::merge(const Tok *left, const Tok *right) + -> const Tok * { if (!left) return right; if (!right) return left; const auto hideset = makeIntersection(left->hideset, right->hideset); @@ -2655,8 +2661,8 @@ auto Preprocessor::Private::merge(const Tok *left, return tok; } -auto Preprocessor::Private::skipLine(TokIterator it, - TokIterator last) -> TokIterator { +auto Preprocessor::Private::skipLine(TokIterator it, TokIterator last) + -> TokIterator { for (; it != last; ++it) { if (it->kind == TokenKind::T_EOF_SYMBOL) break; if (it->bol) break; diff --git a/src/parser/cxx/private/ast_decoder.h b/src/parser/cxx/private/ast_decoder.h index b54b5e07..6e812391 100644 --- a/src/parser/cxx/private/ast_decoder.h +++ b/src/parser/cxx/private/ast_decoder.h @@ -39,44 +39,44 @@ class ASTDecoder { private: auto decodeUnit(const void* ptr, io::Unit type) -> UnitAST*; - auto decodeDeclaration(const void* ptr, - io::Declaration type) -> DeclarationAST*; + auto decodeDeclaration(const void* ptr, io::Declaration type) + -> DeclarationAST*; auto decodeStatement(const void* ptr, io::Statement type) -> StatementAST*; auto decodeExpression(const void* ptr, io::Expression type) -> ExpressionAST*; auto decodeTemplateParameter(const void* ptr, io::TemplateParameter type) -> TemplateParameterAST*; auto decodeSpecifier(const void* ptr, io::Specifier type) -> SpecifierAST*; - auto decodePtrOperator(const void* ptr, - io::PtrOperator type) -> PtrOperatorAST*; - auto decodeCoreDeclarator(const void* ptr, - io::CoreDeclarator type) -> CoreDeclaratorAST*; - auto decodeDeclaratorChunk(const void* ptr, - io::DeclaratorChunk type) -> DeclaratorChunkAST*; - auto decodeUnqualifiedId(const void* ptr, - io::UnqualifiedId type) -> UnqualifiedIdAST*; + auto decodePtrOperator(const void* ptr, io::PtrOperator type) + -> PtrOperatorAST*; + auto decodeCoreDeclarator(const void* ptr, io::CoreDeclarator type) + -> CoreDeclaratorAST*; + auto decodeDeclaratorChunk(const void* ptr, io::DeclaratorChunk type) + -> DeclaratorChunkAST*; + auto decodeUnqualifiedId(const void* ptr, io::UnqualifiedId type) + -> UnqualifiedIdAST*; auto decodeNestedNameSpecifier(const void* ptr, io::NestedNameSpecifier type) -> NestedNameSpecifierAST*; - auto decodeFunctionBody(const void* ptr, - io::FunctionBody type) -> FunctionBodyAST*; + auto decodeFunctionBody(const void* ptr, io::FunctionBody type) + -> FunctionBodyAST*; auto decodeTemplateArgument(const void* ptr, io::TemplateArgument type) -> TemplateArgumentAST*; auto decodeExceptionSpecifier(const void* ptr, io::ExceptionSpecifier type) -> ExceptionSpecifierAST*; - auto decodeRequirement(const void* ptr, - io::Requirement type) -> RequirementAST*; - auto decodeNewInitializer(const void* ptr, - io::NewInitializer type) -> NewInitializerAST*; - auto decodeMemInitializer(const void* ptr, - io::MemInitializer type) -> MemInitializerAST*; - auto decodeLambdaCapture(const void* ptr, - io::LambdaCapture type) -> LambdaCaptureAST*; + auto decodeRequirement(const void* ptr, io::Requirement type) + -> RequirementAST*; + auto decodeNewInitializer(const void* ptr, io::NewInitializer type) + -> NewInitializerAST*; + auto decodeMemInitializer(const void* ptr, io::MemInitializer type) + -> MemInitializerAST*; + auto decodeLambdaCapture(const void* ptr, io::LambdaCapture type) + -> LambdaCaptureAST*; auto decodeExceptionDeclaration(const void* ptr, io::ExceptionDeclaration type) -> ExceptionDeclarationAST*; auto decodeAttributeSpecifier(const void* ptr, io::AttributeSpecifier type) -> AttributeSpecifierAST*; - auto decodeAttributeToken(const void* ptr, - io::AttributeToken type) -> AttributeTokenAST*; + auto decodeAttributeToken(const void* ptr, io::AttributeToken type) + -> AttributeTokenAST*; auto decodeTranslationUnit(const io::TranslationUnit* node) -> TranslationUnitAST*; diff --git a/src/parser/cxx/symbols.cc b/src/parser/cxx/symbols.cc index afe047da..ce4c1fc7 100644 --- a/src/parser/cxx/symbols.cc +++ b/src/parser/cxx/symbols.cc @@ -185,8 +185,8 @@ auto ClassSymbol::hasBaseClass(Symbol* symbol) const -> bool { } auto ClassSymbol::hasBaseClass( - Symbol* symbol, - std::unordered_set& processed) const -> bool { + Symbol* symbol, std::unordered_set& processed) const + -> bool { if (!processed.insert(this).second) { return false; } diff --git a/src/parser/cxx/symbols.h b/src/parser/cxx/symbols.h index 6bd469c4..ae82bb00 100644 --- a/src/parser/cxx/symbols.h +++ b/src/parser/cxx/symbols.h @@ -284,8 +284,9 @@ class ClassSymbol final : public ScopedSymbol { } private: - [[nodiscard]] auto hasBaseClass( - Symbol* symbol, std::unordered_set&) const -> bool; + [[nodiscard]] auto hasBaseClass(Symbol* symbol, + std::unordered_set&) const + -> bool; private: std::vector baseClasses_; diff --git a/src/parser/cxx/type_printer.cc b/src/parser/cxx/type_printer.cc index 2b005fdd..e7413c55 100644 --- a/src/parser/cxx/type_printer.cc +++ b/src/parser/cxx/type_printer.cc @@ -358,8 +358,8 @@ class TypePrinter { } } - auto textOf(TranslationUnit* unit, - SourceLocationRange range) const -> std::string { + auto textOf(TranslationUnit* unit, SourceLocationRange range) const + -> std::string { std::string buf; auto [first, last] = range; for (auto loc = first; loc != last; loc = loc.next()) { diff --git a/src/parser/cxx/type_traits.h b/src/parser/cxx/type_traits.h index 586f9402..c519d1a3 100644 --- a/src/parser/cxx/type_traits.h +++ b/src/parser/cxx/type_traits.h @@ -776,8 +776,8 @@ class TypeTraits { struct { TypeTraits& traits; - auto operator()(const BuiltinVaListType*, - const BuiltinVaListType*) const -> bool { + auto operator()(const BuiltinVaListType*, const BuiltinVaListType*) const + -> bool { return true; } @@ -789,8 +789,8 @@ class TypeTraits { return true; } - auto operator()(const DecltypeAutoType*, - const DecltypeAutoType*) const -> bool { + auto operator()(const DecltypeAutoType*, const DecltypeAutoType*) const + -> bool { return true; } @@ -802,8 +802,8 @@ class TypeTraits { return true; } - auto operator()(const SignedCharType*, - const SignedCharType*) const -> bool { + auto operator()(const SignedCharType*, const SignedCharType*) const + -> bool { return true; } @@ -819,13 +819,13 @@ class TypeTraits { return true; } - auto operator()(const LongLongIntType*, - const LongLongIntType*) const -> bool { + auto operator()(const LongLongIntType*, const LongLongIntType*) const + -> bool { return true; } - auto operator()(const UnsignedCharType*, - const UnsignedCharType*) const -> bool { + auto operator()(const UnsignedCharType*, const UnsignedCharType*) const + -> bool { return true; } @@ -834,8 +834,8 @@ class TypeTraits { return true; } - auto operator()(const UnsignedIntType*, - const UnsignedIntType*) const -> bool { + auto operator()(const UnsignedIntType*, const UnsignedIntType*) const + -> bool { return true; } @@ -877,13 +877,13 @@ class TypeTraits { return true; } - auto operator()(const LongDoubleType*, - const LongDoubleType*) const -> bool { + auto operator()(const LongDoubleType*, const LongDoubleType*) const + -> bool { return true; } - auto operator()(const QualType* type, - const QualType* otherType) const -> bool { + auto operator()(const QualType* type, const QualType* otherType) const + -> bool { if (type->cvQualifiers() != otherType->cvQualifiers()) return false; return traits.is_same(type->elementType(), otherType->elementType()); } @@ -899,8 +899,8 @@ class TypeTraits { return traits.is_same(type->elementType(), otherType->elementType()); } - auto operator()(const PointerType* type, - const PointerType* otherType) const -> bool { + auto operator()(const PointerType* type, const PointerType* otherType) const + -> bool { return traits.is_same(type->elementType(), otherType->elementType()); } @@ -932,13 +932,13 @@ class TypeTraits { return true; } - auto operator()(const ClassType* type, - const ClassType* otherType) const -> bool { + auto operator()(const ClassType* type, const ClassType* otherType) const + -> bool { return type->symbol() == otherType->symbol(); } - auto operator()(const EnumType* type, - const EnumType* otherType) const -> bool { + auto operator()(const EnumType* type, const EnumType* otherType) const + -> bool { return type->symbol() == otherType->symbol(); } diff --git a/tests/unit_tests/ast/consteval_if_01.cc b/tests/unit_tests/ast/consteval_if_01.cc index d66444e5..2d650291 100644 --- a/tests/unit_tests/ast/consteval_if_01.cc +++ b/tests/unit_tests/ast/consteval_if_01.cc @@ -16,7 +16,6 @@ auto main() -> int { } } - // clang-format off // CHECK:translation-unit // CHECK-NEXT: declaration-list diff --git a/tests/unit_tests/ast/if_statement_01.cc b/tests/unit_tests/ast/if_statement_01.cc index c3d29a46..89d57162 100644 --- a/tests/unit_tests/ast/if_statement_01.cc +++ b/tests/unit_tests/ast/if_statement_01.cc @@ -6,7 +6,6 @@ auto main() -> int { // expected-error@1 {{expected a statement}} } - // clang-format off // CHECK:translation-unit // CHECK-NEXT: declaration-list diff --git a/tests/unit_tests/ast/lambda_specifier_01.cc b/tests/unit_tests/ast/lambda_specifier_01.cc index bab7118a..71a165c9 100644 --- a/tests/unit_tests/ast/lambda_specifier_01.cc +++ b/tests/unit_tests/ast/lambda_specifier_01.cc @@ -7,7 +7,6 @@ auto main() -> int { auto static_lambda = []() static { return 0; }; }; - // clang-format off // CHECK:translation-unit // CHECK-NEXT: declaration-list