diff --git a/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts b/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts index 1e46d34d..4c8c702e 100644 --- a/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts +++ b/packages/cxx-gen-ast/src/gen_ast_decoder_cc.ts @@ -48,14 +48,14 @@ export function gen_ast_decoder_cc({ const className = makeClassName(base); emit(); emit( - ` auto ASTDecoder::decode${className}(const void* ptr, io::${className} type) -> ${base}* {`, + ` auto ASTDecoder::decode${className}(const void* ptr, io::${className} type) -> ${base}* {` ); emit(` switch (type) {`); nodes.forEach(({ name }) => { const className = makeClassName(name); emit(` case io::${baseClassName}_${className}:`); emit( - ` return decode${className}(reinterpret_cast(ptr));`, + ` return decode${className}(reinterpret_cast(ptr));` ); }); emit(` default:`); @@ -70,7 +70,7 @@ export function gen_ast_decoder_cc({ const className = makeClassName(name); emit(); emit( - ` auto ASTDecoder::decode${className}(const io::${className}* node) -> ${name}* {`, + ` auto ASTDecoder::decode${className}(const io::${className}* node) -> ${name}* {` ); emit(` if (!node) return nullptr;`); emit(); @@ -135,6 +135,8 @@ export function gen_ast_decoder_cc({ } else if (m.kind == "attribute" && m.type === "TokenKind") { emit(` ast->${m.name} = static_cast(`); emit(` node->${snakeName}());`); + } else if (m.kind == "token") { + emit(` ast->${m.name} = SourceLocation(node->${snakeName}());`); } }); emit(` return ast;`); diff --git a/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts b/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts index a3c3cf58..b04b238b 100644 --- a/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts +++ b/packages/cxx-gen-ast/src/gen_ast_encoder_cc.ts @@ -172,9 +172,8 @@ export function gen_ast_encoder_cc({ emit(` static_cast(ast->${m.name}));`); }); } else if (m.kind == "token") { - emit(` auto ${m.name} = encodeSourceLocation(ast->${m.name});`); finalizers.push(() => { - emit(` builder.add_${fieldName}(${m.name}.o);`); + emit(` builder.add_${fieldName}(ast->${m.name}.index());`); }); } }); @@ -201,8 +200,9 @@ export function gen_ast_encoder_cc({ #include #include #include -#include +#include +#include #include namespace cxx { @@ -214,8 +214,6 @@ auto ASTEncoder::operator()(TranslationUnit* unit) -> std::span stringLiterals; Table integerLiterals; Table floatLiterals; - SourceFiles sourceFiles; - SourceLines sourceLines; std::swap(unit_, unit); std::swap(identifiers_, identifiers); @@ -223,8 +221,25 @@ auto ASTEncoder::operator()(TranslationUnit* unit) -> std::span> sources; + for (const auto& source : unit_->preprocessor()->sources()) { + auto file_name = fbb_.CreateString(source.fileName); + std::vector lineOffsets(source.lineOffsets.begin(), + source.lineOffsets.end()); + auto line_offsets = fbb_.CreateVector(lineOffsets); + sources.push_back(io::CreateSource(fbb_, file_name, line_offsets)); + } + + auto source_list = fbb_.CreateVector(sources); + + std::vector tokens; + for (std::uint32_t i = 0; i < unit_->tokenCount(); ++i) { + const auto& token = unit_->tokenAt(SourceLocation(i)); + tokens.push_back(token.raw()); + } + + auto token_list = fbb_.CreateVector(tokens); auto [unitOffset, unitType] = acceptUnit(unit_->ast()); @@ -234,6 +249,8 @@ auto ASTEncoder::operator()(TranslationUnit* unit) -> std::span(unitType)); builder.add_file_name(file_name); + builder.add_source_list(source_list); + builder.add_token_list(token_list); std::swap(unit_, unit); std::swap(identifiers_, identifiers); @@ -241,8 +258,6 @@ auto ASTEncoder::operator()(TranslationUnit* unit) -> std::span flatbuffers::Offset<> { return offset; } -auto ASTEncoder::encodeSourceLocation(const SourceLocation& loc) - -> flatbuffers::Offset<> { - if (!loc) { - return {}; - } - - const auto start = unit_->tokenStartPosition(loc); - - flatbuffers::Offset sourceLineOffset; - - auto key = std::tuple(start.fileName, start.line); - - if (sourceLines_.contains(key)) { - sourceLineOffset = sourceLines_.at(key).o; - } else { - flatbuffers::Offset fileNameOffset; - - if (sourceFiles_.contains(start.fileName)) { - fileNameOffset = sourceFiles_.at(start.fileName); - } else { - fileNameOffset = fbb_.CreateString(start.fileName); - sourceFiles_.emplace(start.fileName, fileNameOffset.o); - } - - io::SourceLineBuilder sourceLineBuilder{fbb_}; - sourceLineBuilder.add_file_name(fileNameOffset); - sourceLineBuilder.add_line(start.line); - sourceLineOffset = sourceLineBuilder.Finish(); - sourceLines_.emplace(std::move(key), sourceLineOffset.o); - } - - io::SourceLocationBuilder sourceLocationBuilder{fbb_}; - sourceLocationBuilder.add_source_line(sourceLineOffset); - sourceLocationBuilder.add_column(start.column); - - auto offset = sourceLocationBuilder.Finish(); - - return offset.Union(); -} - - ${code.join("\n")} } // namespace cxx diff --git a/packages/cxx-gen-ast/src/gen_ast_encoder_h.ts b/packages/cxx-gen-ast/src/gen_ast_encoder_h.ts index 788473d9..d3d14fbc 100644 --- a/packages/cxx-gen-ast/src/gen_ast_encoder_h.ts +++ b/packages/cxx-gen-ast/src/gen_ast_encoder_h.ts @@ -43,22 +43,12 @@ export function gen_ast_encoder_h({ emit(` using Table = std::unordered_map>;`); emit(); - emit(` using SourceFiles = std::unordered_map<`); - emit(` std::string_view,`); - emit(` flatbuffers::Offset>;`); - emit(); - emit(` using SourceLines = std::map<`); - emit(` std::tuple,`); - emit(` flatbuffers::Offset>;`); - emit(); emit(` TranslationUnit* unit_ = nullptr;`); emit(` Table identifiers_;`); emit(` Table charLiterals_;`); emit(` Table stringLiterals_;`); emit(` Table integerLiterals_;`); emit(` Table floatLiterals_;`); - emit(` SourceFiles sourceFiles_;`); - emit(` SourceLines sourceLines_;`); emit(` flatbuffers::FlatBufferBuilder fbb_;`); emit(` flatbuffers::Offset<> offset_;`); emit(` std::uint32_t type_ = 0;`); @@ -70,9 +60,6 @@ export function gen_ast_encoder_h({ emit(` -> std::span;`); emit(`private:`); - emit(` auto encodeSourceLocation(const SourceLocation& loc)`); - emit(` -> flatbuffers::Offset<>;`); - emit(); emit(` auto accept(AST* ast) -> flatbuffers::Offset<>;`); by_base.forEach((_nodes, base) => { if (base === "AST") return; diff --git a/packages/cxx-gen-ast/src/gen_ast_fbs.ts b/packages/cxx-gen-ast/src/gen_ast_fbs.ts index 73ba7bf5..ad060f24 100644 --- a/packages/cxx-gen-ast/src/gen_ast_fbs.ts +++ b/packages/cxx-gen-ast/src/gen_ast_fbs.ts @@ -95,10 +95,10 @@ export function gen_ast_fbs({ ast, output }: { ast: AST; output: string }) { case "node-list": break; case "token": - emit(` ${fieldName}: SourceLocation;`); + emit(` ${fieldName}: uint32;`); break; case "token-list": - emit(` ${fieldName}: [SourceLocation];`); + throw new Error("unexpected token-list"); break; case "attribute": { break; @@ -115,14 +115,9 @@ export function gen_ast_fbs({ ast, output }: { ast: AST; output: string }) { const out = `${cpy_header} namespace cxx.io; -table SourceLine { +table Source { file_name: string; - line: uint32; -} - -table SourceLocation { - source_line: SourceLine; - column: uint32; + line_offsets: [int]; } ${code.join("\n")} @@ -131,6 +126,8 @@ table SerializedUnit { version: uint32; unit: Unit; file_name: string; + token_list: [uint64]; + source_list: [Source]; } root_type SerializedUnit; diff --git a/src/parser/cxx/ast.fbs b/src/parser/cxx/ast.fbs index 6558e805..f412cea8 100644 --- a/src/parser/cxx/ast.fbs +++ b/src/parser/cxx/ast.fbs @@ -20,14 +20,9 @@ namespace cxx.io; -table SourceLine { +table Source { file_name: string; - line: uint32; -} - -table SourceLocation { - source_line: SourceLine; - column: uint32; + line_offsets: [int]; } union AST { @@ -323,58 +318,58 @@ union UnqualifiedId { table Splicer /* AST */ { expression: Expression; - lbracket_loc: SourceLocation; - colon_loc: SourceLocation; - ellipsis_loc: SourceLocation; - second_colon_loc: SourceLocation; - rbracket_loc: SourceLocation; + lbracket_loc: uint32; + colon_loc: uint32; + ellipsis_loc: uint32; + second_colon_loc: uint32; + rbracket_loc: uint32; } table GlobalModuleFragment /* AST */ { declaration_list: [Declaration]; - module_loc: SourceLocation; - semicolon_loc: SourceLocation; + module_loc: uint32; + semicolon_loc: uint32; } table PrivateModuleFragment /* AST */ { declaration_list: [Declaration]; - module_loc: SourceLocation; - colon_loc: SourceLocation; - private_loc: SourceLocation; - semicolon_loc: SourceLocation; + module_loc: uint32; + colon_loc: uint32; + private_loc: uint32; + semicolon_loc: uint32; } table ModuleDeclaration /* AST */ { module_name: ModuleName; module_partition: ModulePartition; attribute_list: [AttributeSpecifier]; - export_loc: SourceLocation; - module_loc: SourceLocation; - semicolon_loc: SourceLocation; + export_loc: uint32; + module_loc: uint32; + semicolon_loc: uint32; } table ModuleName /* AST */ { module_qualifier: ModuleQualifier; identifier: string; - identifier_loc: SourceLocation; + identifier_loc: uint32; } table ModuleQualifier /* AST */ { module_qualifier: ModuleQualifier; identifier: string; - identifier_loc: SourceLocation; - dot_loc: SourceLocation; + identifier_loc: uint32; + dot_loc: uint32; } table ModulePartition /* AST */ { module_name: ModuleName; - colon_loc: SourceLocation; + colon_loc: uint32; } table ImportName /* AST */ { module_partition: ModulePartition; module_name: ModuleName; - header_loc: SourceLocation; + header_loc: uint32; } table InitDeclarator /* AST */ { @@ -392,16 +387,16 @@ table Declarator /* AST */ { table UsingDeclarator /* AST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; - typename_loc: SourceLocation; - ellipsis_loc: SourceLocation; + typename_loc: uint32; + ellipsis_loc: uint32; } table Enumerator /* AST */ { attribute_list: [AttributeSpecifier]; expression: Expression; identifier: string; - identifier_loc: SourceLocation; - equal_loc: SourceLocation; + identifier_loc: uint32; + equal_loc: uint32; } table TypeId /* AST */ { @@ -412,9 +407,9 @@ table TypeId /* AST */ { table Handler /* AST */ { exception_declaration: ExceptionDeclaration; statement: CompoundStatement; - catch_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + catch_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table BaseSpecifier /* AST */ { @@ -422,144 +417,144 @@ table BaseSpecifier /* AST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; access_specifier: uint32; - template_loc: SourceLocation; + template_loc: uint32; } table RequiresClause /* AST */ { expression: Expression; - requires_loc: SourceLocation; + requires_loc: uint32; } table ParameterDeclarationClause /* AST */ { parameter_declaration_list: [ParameterDeclaration]; - comma_loc: SourceLocation; - ellipsis_loc: SourceLocation; + comma_loc: uint32; + ellipsis_loc: uint32; } table TrailingReturnType /* AST */ { type_id: TypeId; - minus_greater_loc: SourceLocation; + minus_greater_loc: uint32; } table LambdaSpecifier /* AST */ { specifier: uint32; - specifier_loc: SourceLocation; + specifier_loc: uint32; } table TypeConstraint /* AST */ { nested_name_specifier: NestedNameSpecifier; template_argument_list: [TemplateArgument]; identifier: string; - identifier_loc: SourceLocation; - less_loc: SourceLocation; - greater_loc: SourceLocation; + identifier_loc: uint32; + less_loc: uint32; + greater_loc: uint32; } table AttributeArgumentClause /* AST */ { - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table Attribute /* AST */ { attribute_token: AttributeToken; attribute_argument_clause: AttributeArgumentClause; - ellipsis_loc: SourceLocation; + ellipsis_loc: uint32; } table AttributeUsingPrefix /* AST */ { - using_loc: SourceLocation; - attribute_namespace_loc: SourceLocation; - colon_loc: SourceLocation; + using_loc: uint32; + attribute_namespace_loc: uint32; + colon_loc: uint32; } table NewPlacement /* AST */ { expression_list: [Expression]; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table NestedNamespaceSpecifier /* AST */ { identifier: string; - inline_loc: SourceLocation; - identifier_loc: SourceLocation; - scope_loc: SourceLocation; + inline_loc: uint32; + identifier_loc: uint32; + scope_loc: uint32; } table CxxAttribute /* AttributeSpecifierAST */ { attribute_using_prefix: AttributeUsingPrefix; attribute_list: [Attribute]; - lbracket_loc: SourceLocation; - lbracket2_loc: SourceLocation; - rbracket_loc: SourceLocation; - rbracket2_loc: SourceLocation; + lbracket_loc: uint32; + lbracket2_loc: uint32; + rbracket_loc: uint32; + rbracket2_loc: uint32; } table GccAttribute /* AttributeSpecifierAST */ { - attribute_loc: SourceLocation; - lparen_loc: SourceLocation; - lparen2_loc: SourceLocation; - rparen_loc: SourceLocation; - rparen2_loc: SourceLocation; + attribute_loc: uint32; + lparen_loc: uint32; + lparen2_loc: uint32; + rparen_loc: uint32; + rparen2_loc: uint32; } table AlignasAttribute /* AttributeSpecifierAST */ { expression: Expression; - alignas_loc: SourceLocation; - lparen_loc: SourceLocation; - ellipsis_loc: SourceLocation; - rparen_loc: SourceLocation; + alignas_loc: uint32; + lparen_loc: uint32; + ellipsis_loc: uint32; + rparen_loc: uint32; } table AlignasTypeAttribute /* AttributeSpecifierAST */ { type_id: TypeId; - alignas_loc: SourceLocation; - lparen_loc: SourceLocation; - ellipsis_loc: SourceLocation; - rparen_loc: SourceLocation; + alignas_loc: uint32; + lparen_loc: uint32; + ellipsis_loc: uint32; + rparen_loc: uint32; } table AsmAttribute /* AttributeSpecifierAST */ { - asm_loc: SourceLocation; - lparen_loc: SourceLocation; - literal_loc: SourceLocation; - rparen_loc: SourceLocation; + asm_loc: uint32; + lparen_loc: uint32; + literal_loc: uint32; + rparen_loc: uint32; } table ScopedAttributeToken /* AttributeTokenAST */ { attribute_namespace: string; identifier: string; - attribute_namespace_loc: SourceLocation; - scope_loc: SourceLocation; - identifier_loc: SourceLocation; + attribute_namespace_loc: uint32; + scope_loc: uint32; + identifier_loc: uint32; } table SimpleAttributeToken /* AttributeTokenAST */ { identifier: string; - identifier_loc: SourceLocation; + identifier_loc: uint32; } table BitfieldDeclarator /* CoreDeclaratorAST */ { unqualified_id: NameId; size_expression: Expression; - colon_loc: SourceLocation; + colon_loc: uint32; } table ParameterPack /* CoreDeclaratorAST */ { core_declarator: CoreDeclarator; - ellipsis_loc: SourceLocation; + ellipsis_loc: uint32; } table IdDeclarator /* CoreDeclaratorAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; attribute_list: [AttributeSpecifier]; - template_loc: SourceLocation; + template_loc: uint32; } table NestedDeclarator /* CoreDeclaratorAST */ { declarator: Declarator; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table SimpleDeclaration /* DeclarationAST */ { @@ -567,7 +562,7 @@ table SimpleDeclaration /* DeclarationAST */ { decl_specifier_list: [Specifier]; init_declarator_list: [InitDeclarator]; requires_clause: RequiresClause; - semicolon_loc: SourceLocation; + semicolon_loc: uint32; } table AsmDeclaration /* DeclarationAST */ { @@ -577,52 +572,52 @@ table AsmDeclaration /* DeclarationAST */ { input_operand_list: [AsmOperand]; clobber_list: [AsmClobber]; goto_label_list: [AsmGotoLabel]; - asm_loc: SourceLocation; - lparen_loc: SourceLocation; - literal_loc: SourceLocation; - rparen_loc: SourceLocation; - semicolon_loc: SourceLocation; + asm_loc: uint32; + lparen_loc: uint32; + literal_loc: uint32; + rparen_loc: uint32; + semicolon_loc: uint32; } table NamespaceAliasDefinition /* DeclarationAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: NameId; identifier: string; - namespace_loc: SourceLocation; - identifier_loc: SourceLocation; - equal_loc: SourceLocation; - semicolon_loc: SourceLocation; + namespace_loc: uint32; + identifier_loc: uint32; + equal_loc: uint32; + semicolon_loc: uint32; } table UsingDeclaration /* DeclarationAST */ { using_declarator_list: [UsingDeclarator]; - using_loc: SourceLocation; - semicolon_loc: SourceLocation; + using_loc: uint32; + semicolon_loc: uint32; } table UsingEnumDeclaration /* DeclarationAST */ { enum_type_specifier: ElaboratedTypeSpecifier; - using_loc: SourceLocation; - semicolon_loc: SourceLocation; + using_loc: uint32; + semicolon_loc: uint32; } table UsingDirective /* DeclarationAST */ { attribute_list: [AttributeSpecifier]; nested_name_specifier: NestedNameSpecifier; unqualified_id: NameId; - using_loc: SourceLocation; - namespace_loc: SourceLocation; - semicolon_loc: SourceLocation; + using_loc: uint32; + namespace_loc: uint32; + semicolon_loc: uint32; } table StaticAssertDeclaration /* DeclarationAST */ { expression: Expression; - static_assert_loc: SourceLocation; - lparen_loc: SourceLocation; - comma_loc: SourceLocation; - literal_loc: SourceLocation; - rparen_loc: SourceLocation; - semicolon_loc: SourceLocation; + static_assert_loc: uint32; + lparen_loc: uint32; + comma_loc: uint32; + literal_loc: uint32; + rparen_loc: uint32; + semicolon_loc: uint32; } table AliasDeclaration /* DeclarationAST */ { @@ -630,10 +625,10 @@ table AliasDeclaration /* DeclarationAST */ { gnu_attribute_list: [AttributeSpecifier]; type_id: TypeId; identifier: string; - using_loc: SourceLocation; - identifier_loc: SourceLocation; - equal_loc: SourceLocation; - semicolon_loc: SourceLocation; + using_loc: uint32; + identifier_loc: uint32; + equal_loc: uint32; + semicolon_loc: uint32; } table OpaqueEnumDeclaration /* DeclarationAST */ { @@ -641,10 +636,10 @@ table OpaqueEnumDeclaration /* DeclarationAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: NameId; type_specifier_list: [Specifier]; - enum_loc: SourceLocation; - class_loc: SourceLocation; - colon_loc: SourceLocation; - emicolon_loc: SourceLocation; + enum_loc: uint32; + class_loc: uint32; + colon_loc: uint32; + emicolon_loc: uint32; } table FunctionDefinition /* DeclarationAST */ { @@ -659,18 +654,18 @@ table TemplateDeclaration /* DeclarationAST */ { template_parameter_list: [TemplateParameter]; requires_clause: RequiresClause; declaration: Declaration; - template_loc: SourceLocation; - less_loc: SourceLocation; - greater_loc: SourceLocation; + template_loc: uint32; + less_loc: uint32; + greater_loc: uint32; } table ConceptDefinition /* DeclarationAST */ { expression: Expression; identifier: string; - concept_loc: SourceLocation; - identifier_loc: SourceLocation; - equal_loc: SourceLocation; - semicolon_loc: SourceLocation; + concept_loc: uint32; + identifier_loc: uint32; + equal_loc: uint32; + semicolon_loc: uint32; } table DeductionGuide /* DeclarationAST */ { @@ -678,38 +673,38 @@ table DeductionGuide /* DeclarationAST */ { parameter_declaration_clause: ParameterDeclarationClause; template_id: SimpleTemplateId; identifier: string; - identifier_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; - arrow_loc: SourceLocation; - semicolon_loc: SourceLocation; + identifier_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; + arrow_loc: uint32; + semicolon_loc: uint32; } table ExplicitInstantiation /* DeclarationAST */ { declaration: Declaration; - extern_loc: SourceLocation; - template_loc: SourceLocation; + extern_loc: uint32; + template_loc: uint32; } table ExportDeclaration /* DeclarationAST */ { declaration: Declaration; - export_loc: SourceLocation; + export_loc: uint32; } table ExportCompoundDeclaration /* DeclarationAST */ { declaration_list: [Declaration]; - export_loc: SourceLocation; - lbrace_loc: SourceLocation; - rbrace_loc: SourceLocation; + export_loc: uint32; + lbrace_loc: uint32; + rbrace_loc: uint32; } table LinkageSpecification /* DeclarationAST */ { declaration_list: [Declaration]; string_literal: string; - extern_loc: SourceLocation; - stringliteral_loc: SourceLocation; - lbrace_loc: SourceLocation; - rbrace_loc: SourceLocation; + extern_loc: uint32; + stringliteral_loc: uint32; + lbrace_loc: uint32; + rbrace_loc: uint32; } table NamespaceDefinition /* DeclarationAST */ { @@ -718,27 +713,27 @@ table NamespaceDefinition /* DeclarationAST */ { extra_attribute_list: [AttributeSpecifier]; declaration_list: [Declaration]; identifier: string; - inline_loc: SourceLocation; - namespace_loc: SourceLocation; - identifier_loc: SourceLocation; - lbrace_loc: SourceLocation; - rbrace_loc: SourceLocation; + inline_loc: uint32; + namespace_loc: uint32; + identifier_loc: uint32; + lbrace_loc: uint32; + rbrace_loc: uint32; } table EmptyDeclaration /* DeclarationAST */ { - semicolon_loc: SourceLocation; + semicolon_loc: uint32; } table AttributeDeclaration /* DeclarationAST */ { attribute_list: [AttributeSpecifier]; - semicolon_loc: SourceLocation; + semicolon_loc: uint32; } table ModuleImportDeclaration /* DeclarationAST */ { import_name: ImportName; attribute_list: [AttributeSpecifier]; - import_loc: SourceLocation; - semicolon_loc: SourceLocation; + import_loc: uint32; + semicolon_loc: uint32; } table ParameterDeclaration /* DeclarationAST */ { @@ -747,14 +742,14 @@ table ParameterDeclaration /* DeclarationAST */ { declarator: Declarator; expression: Expression; identifier: string; - this_loc: SourceLocation; - equal_loc: SourceLocation; + this_loc: uint32; + equal_loc: uint32; } table AccessDeclaration /* DeclarationAST */ { access_specifier: uint32; - access_loc: SourceLocation; - colon_loc: SourceLocation; + access_loc: uint32; + colon_loc: uint32; } table ForRangeDeclaration /* DeclarationAST */ { @@ -765,36 +760,36 @@ table StructuredBindingDeclaration /* DeclarationAST */ { decl_specifier_list: [Specifier]; binding_list: [NameId]; initializer: Expression; - ref_qualifier_loc: SourceLocation; - lbracket_loc: SourceLocation; - rbracket_loc: SourceLocation; - semicolon_loc: SourceLocation; + ref_qualifier_loc: uint32; + lbracket_loc: uint32; + rbracket_loc: uint32; + semicolon_loc: uint32; } table AsmOperand /* DeclarationAST */ { expression: Expression; symbolic_name: string; - lbracket_loc: SourceLocation; - symbolic_name_loc: SourceLocation; - rbracket_loc: SourceLocation; - constraint_literal_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lbracket_loc: uint32; + symbolic_name_loc: uint32; + rbracket_loc: uint32; + constraint_literal_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table AsmQualifier /* DeclarationAST */ { qualifier: uint32; - qualifier_loc: SourceLocation; + qualifier_loc: uint32; } table AsmClobber /* DeclarationAST */ { literal: string; - literal_loc: SourceLocation; + literal_loc: uint32; } table AsmGotoLabel /* DeclarationAST */ { identifier: string; - identifier_loc: SourceLocation; + identifier_loc: uint32; } table FunctionDeclaratorChunk /* DeclaratorChunkAST */ { @@ -803,20 +798,20 @@ table FunctionDeclaratorChunk /* DeclaratorChunkAST */ { exception_specifier: ExceptionSpecifier; attribute_list: [AttributeSpecifier]; trailing_return_type: TrailingReturnType; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; - ref_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; + ref_loc: uint32; } table ArrayDeclaratorChunk /* DeclaratorChunkAST */ { expression: Expression; attribute_list: [AttributeSpecifier]; - lbracket_loc: SourceLocation; - rbracket_loc: SourceLocation; + lbracket_loc: uint32; + rbracket_loc: uint32; } table EllipsisExceptionDeclaration /* ExceptionDeclarationAST */ { - ellipsis_loc: SourceLocation; + ellipsis_loc: uint32; } table TypeExceptionDeclaration /* ExceptionDeclarationAST */ { @@ -826,70 +821,70 @@ table TypeExceptionDeclaration /* ExceptionDeclarationAST */ { } table ThrowExceptionSpecifier /* ExceptionSpecifierAST */ { - throw_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + throw_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table NoexceptSpecifier /* ExceptionSpecifierAST */ { expression: Expression; - noexcept_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + noexcept_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table GeneratedLiteralExpression /* ExpressionAST */ { - literal_loc: SourceLocation; + literal_loc: uint32; } table CharLiteralExpression /* ExpressionAST */ { literal: string; - literal_loc: SourceLocation; + literal_loc: uint32; } table BoolLiteralExpression /* ExpressionAST */ { - literal_loc: SourceLocation; + literal_loc: uint32; } table IntLiteralExpression /* ExpressionAST */ { literal: string; - literal_loc: SourceLocation; + literal_loc: uint32; } table FloatLiteralExpression /* ExpressionAST */ { literal: string; - literal_loc: SourceLocation; + literal_loc: uint32; } table NullptrLiteralExpression /* ExpressionAST */ { literal: uint32; - literal_loc: SourceLocation; + literal_loc: uint32; } table StringLiteralExpression /* ExpressionAST */ { literal: string; - literal_loc: SourceLocation; + literal_loc: uint32; } table UserDefinedStringLiteralExpression /* ExpressionAST */ { literal: string; - literal_loc: SourceLocation; + literal_loc: uint32; } table ThisExpression /* ExpressionAST */ { - this_loc: SourceLocation; + this_loc: uint32; } table NestedExpression /* ExpressionAST */ { expression: Expression; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table IdExpression /* ExpressionAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; - template_loc: SourceLocation; + template_loc: uint32; } table LambdaExpression /* ExpressionAST */ { @@ -905,13 +900,13 @@ table LambdaExpression /* ExpressionAST */ { requires_clause: RequiresClause; statement: CompoundStatement; capture_default: uint32; - lbracket_loc: SourceLocation; - capture_default_loc: SourceLocation; - rbracket_loc: SourceLocation; - less_loc: SourceLocation; - greater_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lbracket_loc: uint32; + capture_default_loc: uint32; + rbracket_loc: uint32; + less_loc: uint32; + greater_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table FoldExpression /* ExpressionAST */ { @@ -919,69 +914,69 @@ table FoldExpression /* ExpressionAST */ { right_expression: Expression; op: uint32; fold_op: uint32; - lparen_loc: SourceLocation; - op_loc: SourceLocation; - ellipsis_loc: SourceLocation; - fold_op_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + op_loc: uint32; + ellipsis_loc: uint32; + fold_op_loc: uint32; + rparen_loc: uint32; } table RightFoldExpression /* ExpressionAST */ { expression: Expression; op: uint32; - lparen_loc: SourceLocation; - op_loc: SourceLocation; - ellipsis_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + op_loc: uint32; + ellipsis_loc: uint32; + rparen_loc: uint32; } table LeftFoldExpression /* ExpressionAST */ { expression: Expression; op: uint32; - lparen_loc: SourceLocation; - ellipsis_loc: SourceLocation; - op_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + ellipsis_loc: uint32; + op_loc: uint32; + rparen_loc: uint32; } table RequiresExpression /* ExpressionAST */ { parameter_declaration_clause: ParameterDeclarationClause; requirement_list: [Requirement]; - requires_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; - lbrace_loc: SourceLocation; - rbrace_loc: SourceLocation; + requires_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; + lbrace_loc: uint32; + rbrace_loc: uint32; } table VaArgExpression /* ExpressionAST */ { expression: Expression; type_id: TypeId; - va_arg_loc: SourceLocation; - lparen_loc: SourceLocation; - comma_loc: SourceLocation; - rparen_loc: SourceLocation; + va_arg_loc: uint32; + lparen_loc: uint32; + comma_loc: uint32; + rparen_loc: uint32; } table SubscriptExpression /* ExpressionAST */ { base_expression: Expression; index_expression: Expression; - lbracket_loc: SourceLocation; - rbracket_loc: SourceLocation; + lbracket_loc: uint32; + rbracket_loc: uint32; } table CallExpression /* ExpressionAST */ { base_expression: Expression; expression_list: [Expression]; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table TypeConstruction /* ExpressionAST */ { type_specifier: Specifier; expression_list: [Expression]; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table BracedTypeConstruction /* ExpressionAST */ { @@ -993,8 +988,8 @@ table SpliceMemberExpression /* ExpressionAST */ { base_expression: Expression; splicer: Splicer; access_op: uint32; - access_loc: SourceLocation; - template_loc: SourceLocation; + access_loc: uint32; + template_loc: uint32; } table MemberExpression /* ExpressionAST */ { @@ -1002,47 +997,47 @@ table MemberExpression /* ExpressionAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; access_op: uint32; - access_loc: SourceLocation; - template_loc: SourceLocation; + access_loc: uint32; + template_loc: uint32; } table PostIncrExpression /* ExpressionAST */ { base_expression: Expression; op: uint32; - op_loc: SourceLocation; + op_loc: uint32; } table CppCastExpression /* ExpressionAST */ { type_id: TypeId; expression: Expression; - cast_loc: SourceLocation; - less_loc: SourceLocation; - greater_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + cast_loc: uint32; + less_loc: uint32; + greater_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table BuiltinBitCastExpression /* ExpressionAST */ { type_id: TypeId; expression: Expression; - cast_loc: SourceLocation; - lparen_loc: SourceLocation; - comma_loc: SourceLocation; - rparen_loc: SourceLocation; + cast_loc: uint32; + lparen_loc: uint32; + comma_loc: uint32; + rparen_loc: uint32; } table TypeidExpression /* ExpressionAST */ { expression: Expression; - typeid_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + typeid_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table TypeidOfTypeExpression /* ExpressionAST */ { type_id: TypeId; - typeid_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + typeid_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table SpliceExpression /* ExpressionAST */ { @@ -1050,75 +1045,75 @@ table SpliceExpression /* ExpressionAST */ { } table GlobalScopeReflectExpression /* ExpressionAST */ { - caret_loc: SourceLocation; - scope_loc: SourceLocation; + caret_loc: uint32; + scope_loc: uint32; } table NamespaceReflectExpression /* ExpressionAST */ { identifier: string; - caret_loc: SourceLocation; - identifier_loc: SourceLocation; + caret_loc: uint32; + identifier_loc: uint32; } table TypeIdReflectExpression /* ExpressionAST */ { type_id: TypeId; - caret_loc: SourceLocation; + caret_loc: uint32; } table ReflectExpression /* ExpressionAST */ { expression: Expression; - caret_loc: SourceLocation; + caret_loc: uint32; } table UnaryExpression /* ExpressionAST */ { expression: Expression; op: uint32; - op_loc: SourceLocation; + op_loc: uint32; } table AwaitExpression /* ExpressionAST */ { expression: Expression; - await_loc: SourceLocation; + await_loc: uint32; } table SizeofExpression /* ExpressionAST */ { expression: Expression; - sizeof_loc: SourceLocation; + sizeof_loc: uint32; } table SizeofTypeExpression /* ExpressionAST */ { type_id: TypeId; - sizeof_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + sizeof_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table SizeofPackExpression /* ExpressionAST */ { identifier: string; - sizeof_loc: SourceLocation; - ellipsis_loc: SourceLocation; - lparen_loc: SourceLocation; - identifier_loc: SourceLocation; - rparen_loc: SourceLocation; + sizeof_loc: uint32; + ellipsis_loc: uint32; + lparen_loc: uint32; + identifier_loc: uint32; + rparen_loc: uint32; } table AlignofTypeExpression /* ExpressionAST */ { type_id: TypeId; - alignof_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + alignof_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table AlignofExpression /* ExpressionAST */ { expression: Expression; - alignof_loc: SourceLocation; + alignof_loc: uint32; } table NoexceptExpression /* ExpressionAST */ { expression: Expression; - noexcept_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + noexcept_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table NewExpression /* ExpressionAST */ { @@ -1126,25 +1121,25 @@ table NewExpression /* ExpressionAST */ { type_specifier_list: [Specifier]; declarator: Declarator; new_initalizer: NewInitializer; - scope_loc: SourceLocation; - new_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + scope_loc: uint32; + new_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table DeleteExpression /* ExpressionAST */ { expression: Expression; - scope_loc: SourceLocation; - delete_loc: SourceLocation; - lbracket_loc: SourceLocation; - rbracket_loc: SourceLocation; + scope_loc: uint32; + delete_loc: uint32; + lbracket_loc: uint32; + rbracket_loc: uint32; } table CastExpression /* ExpressionAST */ { type_id: TypeId; expression: Expression; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table ImplicitCastExpression /* ExpressionAST */ { @@ -1155,51 +1150,51 @@ table BinaryExpression /* ExpressionAST */ { left_expression: Expression; right_expression: Expression; op: uint32; - op_loc: SourceLocation; + op_loc: uint32; } table ConditionalExpression /* ExpressionAST */ { condition: Expression; iftrue_expression: Expression; iffalse_expression: Expression; - question_loc: SourceLocation; - colon_loc: SourceLocation; + question_loc: uint32; + colon_loc: uint32; } table YieldExpression /* ExpressionAST */ { expression: Expression; - yield_loc: SourceLocation; + yield_loc: uint32; } table ThrowExpression /* ExpressionAST */ { expression: Expression; - throw_loc: SourceLocation; + throw_loc: uint32; } table AssignmentExpression /* ExpressionAST */ { left_expression: Expression; right_expression: Expression; op: uint32; - op_loc: SourceLocation; + op_loc: uint32; } table PackExpansionExpression /* ExpressionAST */ { expression: Expression; - ellipsis_loc: SourceLocation; + ellipsis_loc: uint32; } table DesignatedInitializerClause /* ExpressionAST */ { identifier: string; initializer: Expression; - dot_loc: SourceLocation; - identifier_loc: SourceLocation; + dot_loc: uint32; + identifier_loc: uint32; } table TypeTraitExpression /* ExpressionAST */ { type_id_list: [TypeId]; - type_trait_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + type_trait_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table ConditionExpression /* ExpressionAST */ { @@ -1211,129 +1206,129 @@ table ConditionExpression /* ExpressionAST */ { table EqualInitializer /* ExpressionAST */ { expression: Expression; - equal_loc: SourceLocation; + equal_loc: uint32; } table BracedInitList /* ExpressionAST */ { expression_list: [Expression]; - lbrace_loc: SourceLocation; - comma_loc: SourceLocation; - rbrace_loc: SourceLocation; + lbrace_loc: uint32; + comma_loc: uint32; + rbrace_loc: uint32; } table ParenInitializer /* ExpressionAST */ { expression_list: [Expression]; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table DefaultFunctionBody /* FunctionBodyAST */ { - equal_loc: SourceLocation; - default_loc: SourceLocation; - semicolon_loc: SourceLocation; + equal_loc: uint32; + default_loc: uint32; + semicolon_loc: uint32; } table CompoundStatementFunctionBody /* FunctionBodyAST */ { mem_initializer_list: [MemInitializer]; statement: CompoundStatement; - colon_loc: SourceLocation; + colon_loc: uint32; } table TryStatementFunctionBody /* FunctionBodyAST */ { mem_initializer_list: [MemInitializer]; statement: CompoundStatement; handler_list: [Handler]; - try_loc: SourceLocation; - colon_loc: SourceLocation; + try_loc: uint32; + colon_loc: uint32; } table DeleteFunctionBody /* FunctionBodyAST */ { - equal_loc: SourceLocation; - delete_loc: SourceLocation; - semicolon_loc: SourceLocation; + equal_loc: uint32; + delete_loc: uint32; + semicolon_loc: uint32; } table ThisLambdaCapture /* LambdaCaptureAST */ { - this_loc: SourceLocation; + this_loc: uint32; } table DerefThisLambdaCapture /* LambdaCaptureAST */ { - star_loc: SourceLocation; - this_loc: SourceLocation; + star_loc: uint32; + this_loc: uint32; } table SimpleLambdaCapture /* LambdaCaptureAST */ { identifier: string; - identifier_loc: SourceLocation; - ellipsis_loc: SourceLocation; + identifier_loc: uint32; + ellipsis_loc: uint32; } table RefLambdaCapture /* LambdaCaptureAST */ { identifier: string; - amp_loc: SourceLocation; - identifier_loc: SourceLocation; - ellipsis_loc: SourceLocation; + amp_loc: uint32; + identifier_loc: uint32; + ellipsis_loc: uint32; } table RefInitLambdaCapture /* LambdaCaptureAST */ { initializer: Expression; identifier: string; - amp_loc: SourceLocation; - ellipsis_loc: SourceLocation; - identifier_loc: SourceLocation; + amp_loc: uint32; + ellipsis_loc: uint32; + identifier_loc: uint32; } table InitLambdaCapture /* LambdaCaptureAST */ { initializer: Expression; identifier: string; - ellipsis_loc: SourceLocation; - identifier_loc: SourceLocation; + ellipsis_loc: uint32; + identifier_loc: uint32; } table ParenMemInitializer /* MemInitializerAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; expression_list: [Expression]; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; - ellipsis_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; + ellipsis_loc: uint32; } table BracedMemInitializer /* MemInitializerAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; braced_init_list: BracedInitList; - ellipsis_loc: SourceLocation; + ellipsis_loc: uint32; } table GlobalNestedNameSpecifier /* NestedNameSpecifierAST */ { - scope_loc: SourceLocation; + scope_loc: uint32; } table SimpleNestedNameSpecifier /* NestedNameSpecifierAST */ { nested_name_specifier: NestedNameSpecifier; identifier: string; - identifier_loc: SourceLocation; - scope_loc: SourceLocation; + identifier_loc: uint32; + scope_loc: uint32; } table DecltypeNestedNameSpecifier /* NestedNameSpecifierAST */ { nested_name_specifier: NestedNameSpecifier; decltype_specifier: DecltypeSpecifier; - scope_loc: SourceLocation; + scope_loc: uint32; } table TemplateNestedNameSpecifier /* NestedNameSpecifierAST */ { nested_name_specifier: NestedNameSpecifier; template_id: SimpleTemplateId; - template_loc: SourceLocation; - scope_loc: SourceLocation; + template_loc: uint32; + scope_loc: uint32; } table NewParenInitializer /* NewInitializerAST */ { expression_list: [Expression]; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + lparen_loc: uint32; + rparen_loc: uint32; } table NewBracedInitializer /* NewInitializerAST */ { @@ -1343,164 +1338,164 @@ table NewBracedInitializer /* NewInitializerAST */ { table PointerOperator /* PtrOperatorAST */ { attribute_list: [AttributeSpecifier]; cv_qualifier_list: [Specifier]; - star_loc: SourceLocation; + star_loc: uint32; } table ReferenceOperator /* PtrOperatorAST */ { attribute_list: [AttributeSpecifier]; ref_op: uint32; - ref_loc: SourceLocation; + ref_loc: uint32; } table PtrToMemberOperator /* PtrOperatorAST */ { nested_name_specifier: NestedNameSpecifier; attribute_list: [AttributeSpecifier]; cv_qualifier_list: [Specifier]; - star_loc: SourceLocation; + star_loc: uint32; } table SimpleRequirement /* RequirementAST */ { expression: Expression; - semicolon_loc: SourceLocation; + semicolon_loc: uint32; } table CompoundRequirement /* RequirementAST */ { expression: Expression; type_constraint: TypeConstraint; - lbrace_loc: SourceLocation; - rbrace_loc: SourceLocation; - noexcept_loc: SourceLocation; - minus_greater_loc: SourceLocation; - semicolon_loc: SourceLocation; + lbrace_loc: uint32; + rbrace_loc: uint32; + noexcept_loc: uint32; + minus_greater_loc: uint32; + semicolon_loc: uint32; } table TypeRequirement /* RequirementAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; - typename_loc: SourceLocation; - semicolon_loc: SourceLocation; + typename_loc: uint32; + semicolon_loc: uint32; } table NestedRequirement /* RequirementAST */ { expression: Expression; - requires_loc: SourceLocation; - semicolon_loc: SourceLocation; + requires_loc: uint32; + semicolon_loc: uint32; } table GeneratedTypeSpecifier /* SpecifierAST */ { - type_loc: SourceLocation; + type_loc: uint32; } table TypedefSpecifier /* SpecifierAST */ { - typedef_loc: SourceLocation; + typedef_loc: uint32; } table FriendSpecifier /* SpecifierAST */ { - friend_loc: SourceLocation; + friend_loc: uint32; } table ConstevalSpecifier /* SpecifierAST */ { - consteval_loc: SourceLocation; + consteval_loc: uint32; } table ConstinitSpecifier /* SpecifierAST */ { - constinit_loc: SourceLocation; + constinit_loc: uint32; } table ConstexprSpecifier /* SpecifierAST */ { - constexpr_loc: SourceLocation; + constexpr_loc: uint32; } table InlineSpecifier /* SpecifierAST */ { - inline_loc: SourceLocation; + inline_loc: uint32; } table StaticSpecifier /* SpecifierAST */ { - static_loc: SourceLocation; + static_loc: uint32; } table ExternSpecifier /* SpecifierAST */ { - extern_loc: SourceLocation; + extern_loc: uint32; } table ThreadLocalSpecifier /* SpecifierAST */ { - thread_local_loc: SourceLocation; + thread_local_loc: uint32; } table ThreadSpecifier /* SpecifierAST */ { - thread_loc: SourceLocation; + thread_loc: uint32; } table MutableSpecifier /* SpecifierAST */ { - mutable_loc: SourceLocation; + mutable_loc: uint32; } table VirtualSpecifier /* SpecifierAST */ { - virtual_loc: SourceLocation; + virtual_loc: uint32; } table ExplicitSpecifier /* SpecifierAST */ { expression: Expression; - explicit_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + explicit_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table AutoTypeSpecifier /* SpecifierAST */ { - auto_loc: SourceLocation; + auto_loc: uint32; } table VoidTypeSpecifier /* SpecifierAST */ { - void_loc: SourceLocation; + void_loc: uint32; } table SizeTypeSpecifier /* SpecifierAST */ { specifier: uint32; - specifier_loc: SourceLocation; + specifier_loc: uint32; } table SignTypeSpecifier /* SpecifierAST */ { specifier: uint32; - specifier_loc: SourceLocation; + specifier_loc: uint32; } table VaListTypeSpecifier /* SpecifierAST */ { specifier: uint32; - specifier_loc: SourceLocation; + specifier_loc: uint32; } table IntegralTypeSpecifier /* SpecifierAST */ { specifier: uint32; - specifier_loc: SourceLocation; + specifier_loc: uint32; } table FloatingPointTypeSpecifier /* SpecifierAST */ { specifier: uint32; - specifier_loc: SourceLocation; + specifier_loc: uint32; } table ComplexTypeSpecifier /* SpecifierAST */ { - complex_loc: SourceLocation; + complex_loc: uint32; } table NamedTypeSpecifier /* SpecifierAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; - template_loc: SourceLocation; + template_loc: uint32; } table AtomicTypeSpecifier /* SpecifierAST */ { type_id: TypeId; - atomic_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + atomic_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table UnderlyingTypeSpecifier /* SpecifierAST */ { type_id: TypeId; - underlying_type_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + underlying_type_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table ElaboratedTypeSpecifier /* SpecifierAST */ { @@ -1508,22 +1503,22 @@ table ElaboratedTypeSpecifier /* SpecifierAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; class_key: uint32; - class_loc: SourceLocation; - template_loc: SourceLocation; + class_loc: uint32; + template_loc: uint32; } table DecltypeAutoSpecifier /* SpecifierAST */ { - decltype_loc: SourceLocation; - lparen_loc: SourceLocation; - auto_loc: SourceLocation; - rparen_loc: SourceLocation; + decltype_loc: uint32; + lparen_loc: uint32; + auto_loc: uint32; + rparen_loc: uint32; } table DecltypeSpecifier /* SpecifierAST */ { expression: Expression; - decltype_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + decltype_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table PlaceholderTypeSpecifier /* SpecifierAST */ { @@ -1532,15 +1527,15 @@ table PlaceholderTypeSpecifier /* SpecifierAST */ { } table ConstQualifier /* SpecifierAST */ { - const_loc: SourceLocation; + const_loc: uint32; } table VolatileQualifier /* SpecifierAST */ { - volatile_loc: SourceLocation; + volatile_loc: uint32; } table RestrictQualifier /* SpecifierAST */ { - restrict_loc: SourceLocation; + restrict_loc: uint32; } table EnumSpecifier /* SpecifierAST */ { @@ -1549,12 +1544,12 @@ table EnumSpecifier /* SpecifierAST */ { unqualified_id: NameId; type_specifier_list: [Specifier]; enumerator_list: [Enumerator]; - enum_loc: SourceLocation; - class_loc: SourceLocation; - colon_loc: SourceLocation; - lbrace_loc: SourceLocation; - comma_loc: SourceLocation; - rbrace_loc: SourceLocation; + enum_loc: uint32; + class_loc: uint32; + colon_loc: uint32; + lbrace_loc: uint32; + comma_loc: uint32; + rbrace_loc: uint32; } table ClassSpecifier /* SpecifierAST */ { @@ -1564,50 +1559,50 @@ table ClassSpecifier /* SpecifierAST */ { base_specifier_list: [BaseSpecifier]; declaration_list: [Declaration]; class_key: uint32; - class_loc: SourceLocation; - final_loc: SourceLocation; - colon_loc: SourceLocation; - lbrace_loc: SourceLocation; - rbrace_loc: SourceLocation; + class_loc: uint32; + final_loc: uint32; + colon_loc: uint32; + lbrace_loc: uint32; + rbrace_loc: uint32; } table TypenameSpecifier /* SpecifierAST */ { nested_name_specifier: NestedNameSpecifier; unqualified_id: UnqualifiedId; - typename_loc: SourceLocation; + typename_loc: uint32; } table SplicerTypeSpecifier /* SpecifierAST */ { splicer: Splicer; - typename_loc: SourceLocation; + typename_loc: uint32; } table LabeledStatement /* StatementAST */ { identifier: string; - identifier_loc: SourceLocation; - colon_loc: SourceLocation; + identifier_loc: uint32; + colon_loc: uint32; } table CaseStatement /* StatementAST */ { expression: Expression; - case_loc: SourceLocation; - colon_loc: SourceLocation; + case_loc: uint32; + colon_loc: uint32; } table DefaultStatement /* StatementAST */ { - default_loc: SourceLocation; - colon_loc: SourceLocation; + default_loc: uint32; + colon_loc: uint32; } table ExpressionStatement /* StatementAST */ { expression: Expression; - semicolon_loc: SourceLocation; + semicolon_loc: uint32; } table CompoundStatement /* StatementAST */ { statement_list: [Statement]; - lbrace_loc: SourceLocation; - rbrace_loc: SourceLocation; + lbrace_loc: uint32; + rbrace_loc: uint32; } table IfStatement /* StatementAST */ { @@ -1615,47 +1610,47 @@ table IfStatement /* StatementAST */ { condition: Expression; statement: Statement; else_statement: Statement; - if_loc: SourceLocation; - constexpr_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; - else_loc: SourceLocation; + if_loc: uint32; + constexpr_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; + else_loc: uint32; } table ConstevalIfStatement /* StatementAST */ { statement: Statement; else_statement: Statement; - if_loc: SourceLocation; - exclaim_loc: SourceLocation; - constval_loc: SourceLocation; - else_loc: SourceLocation; + if_loc: uint32; + exclaim_loc: uint32; + constval_loc: uint32; + else_loc: uint32; } table SwitchStatement /* StatementAST */ { initializer: Statement; condition: Expression; statement: Statement; - switch_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + switch_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table WhileStatement /* StatementAST */ { condition: Expression; statement: Statement; - while_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; + while_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; } table DoStatement /* StatementAST */ { statement: Statement; expression: Expression; - do_loc: SourceLocation; - while_loc: SourceLocation; - lparen_loc: SourceLocation; - rparen_loc: SourceLocation; - semicolon_loc: SourceLocation; + do_loc: uint32; + while_loc: uint32; + lparen_loc: uint32; + rparen_loc: uint32; + semicolon_loc: uint32; } table ForRangeStatement /* StatementAST */ { @@ -1663,10 +1658,10 @@ table ForRangeStatement /* StatementAST */ { range_declaration: Declaration; range_initializer: Expression; statement: Statement; - for_loc: SourceLocation; - lparen_loc: SourceLocation; - colon_loc: SourceLocation; - rparen_loc: SourceLocation; + for_loc: uint32; + lparen_loc: uint32; + colon_loc: uint32; + rparen_loc: uint32; } table ForStatement /* StatementAST */ { @@ -1674,39 +1669,39 @@ table ForStatement /* StatementAST */ { condition: Expression; expression: Expression; statement: Statement; - for_loc: SourceLocation; - lparen_loc: SourceLocation; - semicolon_loc: SourceLocation; - rparen_loc: SourceLocation; + for_loc: uint32; + lparen_loc: uint32; + semicolon_loc: uint32; + rparen_loc: uint32; } table BreakStatement /* StatementAST */ { - break_loc: SourceLocation; - semicolon_loc: SourceLocation; + break_loc: uint32; + semicolon_loc: uint32; } table ContinueStatement /* StatementAST */ { - continue_loc: SourceLocation; - semicolon_loc: SourceLocation; + continue_loc: uint32; + semicolon_loc: uint32; } table ReturnStatement /* StatementAST */ { expression: Expression; - return_loc: SourceLocation; - semicolon_loc: SourceLocation; + return_loc: uint32; + semicolon_loc: uint32; } table CoroutineReturnStatement /* StatementAST */ { expression: Expression; - coreturn_loc: SourceLocation; - semicolon_loc: SourceLocation; + coreturn_loc: uint32; + semicolon_loc: uint32; } table GotoStatement /* StatementAST */ { identifier: string; - goto_loc: SourceLocation; - identifier_loc: SourceLocation; - semicolon_loc: SourceLocation; + goto_loc: uint32; + identifier_loc: uint32; + semicolon_loc: uint32; } table DeclarationStatement /* StatementAST */ { @@ -1716,7 +1711,7 @@ table DeclarationStatement /* StatementAST */ { table TryBlockStatement /* StatementAST */ { statement: CompoundStatement; handler_list: [Handler]; - try_loc: SourceLocation; + try_loc: uint32; } table TypeTemplateArgument /* TemplateArgumentAST */ { @@ -1732,13 +1727,13 @@ table TemplateTypeParameter /* TemplateParameterAST */ { requires_clause: RequiresClause; id_expression: IdExpression; identifier: string; - template_loc: SourceLocation; - less_loc: SourceLocation; - greater_loc: SourceLocation; - class_key_loc: SourceLocation; - ellipsis_loc: SourceLocation; - identifier_loc: SourceLocation; - equal_loc: SourceLocation; + template_loc: uint32; + less_loc: uint32; + greater_loc: uint32; + class_key_loc: uint32; + ellipsis_loc: uint32; + identifier_loc: uint32; + equal_loc: uint32; } table NonTypeTemplateParameter /* TemplateParameterAST */ { @@ -1748,19 +1743,19 @@ table NonTypeTemplateParameter /* TemplateParameterAST */ { table TypenameTypeParameter /* TemplateParameterAST */ { type_id: TypeId; identifier: string; - class_key_loc: SourceLocation; - ellipsis_loc: SourceLocation; - identifier_loc: SourceLocation; - equal_loc: SourceLocation; + class_key_loc: uint32; + ellipsis_loc: uint32; + identifier_loc: uint32; + equal_loc: uint32; } table ConstraintTypeParameter /* TemplateParameterAST */ { type_constraint: TypeConstraint; type_id: TypeId; identifier: string; - ellipsis_loc: SourceLocation; - identifier_loc: SourceLocation; - equal_loc: SourceLocation; + ellipsis_loc: uint32; + identifier_loc: uint32; + equal_loc: uint32; } table TranslationUnit /* UnitAST */ { @@ -1776,12 +1771,12 @@ table ModuleUnit /* UnitAST */ { table NameId /* UnqualifiedIdAST */ { identifier: string; - identifier_loc: SourceLocation; + identifier_loc: uint32; } table DestructorId /* UnqualifiedIdAST */ { id: UnqualifiedId; - tilde_loc: SourceLocation; + tilde_loc: uint32; } table DecltypeId /* UnqualifiedIdAST */ { @@ -1790,44 +1785,44 @@ table DecltypeId /* UnqualifiedIdAST */ { table OperatorFunctionId /* UnqualifiedIdAST */ { op: uint32; - operator_loc: SourceLocation; - op_loc: SourceLocation; - open_loc: SourceLocation; - close_loc: SourceLocation; + operator_loc: uint32; + op_loc: uint32; + open_loc: uint32; + close_loc: uint32; } table LiteralOperatorId /* UnqualifiedIdAST */ { identifier: string; - operator_loc: SourceLocation; - literal_loc: SourceLocation; - identifier_loc: SourceLocation; + operator_loc: uint32; + literal_loc: uint32; + identifier_loc: uint32; } table ConversionFunctionId /* UnqualifiedIdAST */ { type_id: TypeId; - operator_loc: SourceLocation; + operator_loc: uint32; } table SimpleTemplateId /* UnqualifiedIdAST */ { template_argument_list: [TemplateArgument]; identifier: string; - identifier_loc: SourceLocation; - less_loc: SourceLocation; - greater_loc: SourceLocation; + identifier_loc: uint32; + less_loc: uint32; + greater_loc: uint32; } table LiteralOperatorTemplateId /* UnqualifiedIdAST */ { literal_operator_id: LiteralOperatorId; template_argument_list: [TemplateArgument]; - less_loc: SourceLocation; - greater_loc: SourceLocation; + less_loc: uint32; + greater_loc: uint32; } table OperatorFunctionTemplateId /* UnqualifiedIdAST */ { operator_function_id: OperatorFunctionId; template_argument_list: [TemplateArgument]; - less_loc: SourceLocation; - greater_loc: SourceLocation; + less_loc: uint32; + greater_loc: uint32; } @@ -1835,6 +1830,8 @@ table SerializedUnit { version: uint32; unit: Unit; file_name: string; + token_list: [uint64]; + source_list: [Source]; } root_type SerializedUnit; diff --git a/src/parser/cxx/flatbuffers/ast_decoder.cc b/src/parser/cxx/flatbuffers/ast_decoder.cc index acf87712..7fdaffbe 100644 --- a/src/parser/cxx/flatbuffers/ast_decoder.cc +++ b/src/parser/cxx/flatbuffers/ast_decoder.cc @@ -876,6 +876,7 @@ auto ASTDecoder::decodeSimpleDeclaration(const io::SimpleDeclaration* node) } } ast->requiresClause = decodeRequiresClause(node->requires_clause()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -901,6 +902,9 @@ auto ASTDecoder::decodeAsmDeclaration(const io::AsmDeclaration* node) inserter = &(*inserter)->next; } } + ast->asmLoc = SourceLocation(node->asm_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->literalLoc = SourceLocation(node->literal_loc()); if (node->output_operand_list()) { auto* inserter = &ast->outputOperandList; for (std::size_t i = 0; i < node->output_operand_list()->size(); ++i) { @@ -933,6 +937,8 @@ auto ASTDecoder::decodeAsmDeclaration(const io::AsmDeclaration* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -941,9 +947,13 @@ auto ASTDecoder::decodeNamespaceAliasDefinition( if (!node) return nullptr; auto ast = new (pool_) NamespaceAliasDefinitionAST(); + ast->namespaceLoc = SourceLocation(node->namespace_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->equalLoc = SourceLocation(node->equal_loc()); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeNameId(node->unqualified_id()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -956,6 +966,7 @@ auto ASTDecoder::decodeUsingDeclaration(const io::UsingDeclaration* node) if (!node) return nullptr; auto ast = new (pool_) UsingDeclarationAST(); + ast->usingLoc = SourceLocation(node->using_loc()); if (node->using_declarator_list()) { auto* inserter = &ast->usingDeclaratorList; for (std::size_t i = 0; i < node->using_declarator_list()->size(); ++i) { @@ -964,6 +975,7 @@ auto ASTDecoder::decodeUsingDeclaration(const io::UsingDeclaration* node) inserter = &(*inserter)->next; } } + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -972,8 +984,10 @@ auto ASTDecoder::decodeUsingEnumDeclaration( if (!node) return nullptr; auto ast = new (pool_) UsingEnumDeclarationAST(); + ast->usingLoc = SourceLocation(node->using_loc()); ast->enumTypeSpecifier = decodeElaboratedTypeSpecifier(node->enum_type_specifier()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -991,9 +1005,12 @@ auto ASTDecoder::decodeUsingDirective(const io::UsingDirective* node) inserter = &(*inserter)->next; } } + ast->usingLoc = SourceLocation(node->using_loc()); + ast->namespaceLoc = SourceLocation(node->namespace_loc()); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeNameId(node->unqualified_id()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1002,8 +1019,14 @@ auto ASTDecoder::decodeStaticAssertDeclaration( if (!node) return nullptr; auto ast = new (pool_) StaticAssertDeclarationAST(); + ast->staticAssertLoc = SourceLocation(node->static_assert_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->commaLoc = SourceLocation(node->comma_loc()); + ast->literalLoc = SourceLocation(node->literal_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1012,6 +1035,8 @@ auto ASTDecoder::decodeAliasDeclaration(const io::AliasDeclaration* node) if (!node) return nullptr; auto ast = new (pool_) AliasDeclarationAST(); + ast->usingLoc = SourceLocation(node->using_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -1021,6 +1046,7 @@ auto ASTDecoder::decodeAliasDeclaration(const io::AliasDeclaration* node) inserter = &(*inserter)->next; } } + ast->equalLoc = SourceLocation(node->equal_loc()); if (node->gnu_attribute_list()) { auto* inserter = &ast->gnuAttributeList; for (std::size_t i = 0; i < node->gnu_attribute_list()->size(); ++i) { @@ -1031,6 +1057,7 @@ auto ASTDecoder::decodeAliasDeclaration(const io::AliasDeclaration* node) } } ast->typeId = decodeTypeId(node->type_id()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -1043,6 +1070,8 @@ auto ASTDecoder::decodeOpaqueEnumDeclaration( if (!node) return nullptr; auto ast = new (pool_) OpaqueEnumDeclarationAST(); + ast->enumLoc = SourceLocation(node->enum_loc()); + ast->classLoc = SourceLocation(node->class_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -1055,6 +1084,7 @@ auto ASTDecoder::decodeOpaqueEnumDeclaration( ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeNameId(node->unqualified_id()); + ast->colonLoc = SourceLocation(node->colon_loc()); if (node->type_specifier_list()) { auto* inserter = &ast->typeSpecifierList; for (std::size_t i = 0; i < node->type_specifier_list()->size(); ++i) { @@ -1064,6 +1094,7 @@ auto ASTDecoder::decodeOpaqueEnumDeclaration( inserter = &(*inserter)->next; } } + ast->emicolonLoc = SourceLocation(node->emicolon_loc()); return ast; } @@ -1102,6 +1133,8 @@ auto ASTDecoder::decodeTemplateDeclaration(const io::TemplateDeclaration* node) if (!node) return nullptr; auto ast = new (pool_) TemplateDeclarationAST(); + ast->templateLoc = SourceLocation(node->template_loc()); + ast->lessLoc = SourceLocation(node->less_loc()); if (node->template_parameter_list()) { auto* inserter = &ast->templateParameterList; for (std::size_t i = 0; i < node->template_parameter_list()->size(); ++i) { @@ -1111,6 +1144,7 @@ auto ASTDecoder::decodeTemplateDeclaration(const io::TemplateDeclaration* node) inserter = &(*inserter)->next; } } + ast->greaterLoc = SourceLocation(node->greater_loc()); ast->requiresClause = decodeRequiresClause(node->requires_clause()); ast->declaration = decodeDeclaration(node->declaration(), node->declaration_type()); @@ -1122,8 +1156,12 @@ auto ASTDecoder::decodeConceptDefinition(const io::ConceptDefinition* node) if (!node) return nullptr; auto ast = new (pool_) ConceptDefinitionAST(); + ast->conceptLoc = SourceLocation(node->concept_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->equalLoc = SourceLocation(node->equal_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -1138,9 +1176,14 @@ auto ASTDecoder::decodeDeductionGuide(const io::DeductionGuide* node) auto ast = new (pool_) DeductionGuideAST(); ast->explicitSpecifier = decodeSpecifier(node->explicit_specifier(), node->explicit_specifier_type()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->parameterDeclarationClause = decodeParameterDeclarationClause(node->parameter_declaration_clause()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); + ast->arrowLoc = SourceLocation(node->arrow_loc()); ast->templateId = decodeSimpleTemplateId(node->template_id()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -1153,6 +1196,8 @@ auto ASTDecoder::decodeExplicitInstantiation( if (!node) return nullptr; auto ast = new (pool_) ExplicitInstantiationAST(); + ast->externLoc = SourceLocation(node->extern_loc()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->declaration = decodeDeclaration(node->declaration(), node->declaration_type()); return ast; @@ -1163,6 +1208,7 @@ auto ASTDecoder::decodeExportDeclaration(const io::ExportDeclaration* node) if (!node) return nullptr; auto ast = new (pool_) ExportDeclarationAST(); + ast->exportLoc = SourceLocation(node->export_loc()); ast->declaration = decodeDeclaration(node->declaration(), node->declaration_type()); return ast; @@ -1174,6 +1220,8 @@ auto ASTDecoder::decodeExportCompoundDeclaration( if (!node) return nullptr; auto ast = new (pool_) ExportCompoundDeclarationAST(); + ast->exportLoc = SourceLocation(node->export_loc()); + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); if (node->declaration_list()) { auto* inserter = &ast->declarationList; for (std::size_t i = 0; i < node->declaration_list()->size(); ++i) { @@ -1183,6 +1231,7 @@ auto ASTDecoder::decodeExportCompoundDeclaration( inserter = &(*inserter)->next; } } + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); return ast; } @@ -1191,6 +1240,9 @@ auto ASTDecoder::decodeLinkageSpecification( if (!node) return nullptr; auto ast = new (pool_) LinkageSpecificationAST(); + ast->externLoc = SourceLocation(node->extern_loc()); + ast->stringliteralLoc = SourceLocation(node->stringliteral_loc()); + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); if (node->declaration_list()) { auto* inserter = &ast->declarationList; for (std::size_t i = 0; i < node->declaration_list()->size(); ++i) { @@ -1200,6 +1252,7 @@ auto ASTDecoder::decodeLinkageSpecification( inserter = &(*inserter)->next; } } + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); if (node->string_literal()) { ast->stringLiteral = unit_->control()->stringLiteral(node->string_literal()->str()); @@ -1212,6 +1265,8 @@ auto ASTDecoder::decodeNamespaceDefinition(const io::NamespaceDefinition* node) if (!node) return nullptr; auto ast = new (pool_) NamespaceDefinitionAST(); + ast->inlineLoc = SourceLocation(node->inline_loc()); + ast->namespaceLoc = SourceLocation(node->namespace_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -1230,6 +1285,7 @@ auto ASTDecoder::decodeNamespaceDefinition(const io::NamespaceDefinition* node) inserter = &(*inserter)->next; } } + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->extra_attribute_list()) { auto* inserter = &ast->extraAttributeList; for (std::size_t i = 0; i < node->extra_attribute_list()->size(); ++i) { @@ -1239,6 +1295,7 @@ auto ASTDecoder::decodeNamespaceDefinition(const io::NamespaceDefinition* node) inserter = &(*inserter)->next; } } + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); if (node->declaration_list()) { auto* inserter = &ast->declarationList; for (std::size_t i = 0; i < node->declaration_list()->size(); ++i) { @@ -1248,6 +1305,7 @@ auto ASTDecoder::decodeNamespaceDefinition(const io::NamespaceDefinition* node) inserter = &(*inserter)->next; } } + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -1260,6 +1318,7 @@ auto ASTDecoder::decodeEmptyDeclaration(const io::EmptyDeclaration* node) if (!node) return nullptr; auto ast = new (pool_) EmptyDeclarationAST(); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1277,6 +1336,7 @@ auto ASTDecoder::decodeAttributeDeclaration( inserter = &(*inserter)->next; } } + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1285,6 +1345,7 @@ auto ASTDecoder::decodeModuleImportDeclaration( if (!node) return nullptr; auto ast = new (pool_) ModuleImportDeclarationAST(); + ast->importLoc = SourceLocation(node->import_loc()); ast->importName = decodeImportName(node->import_name()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; @@ -1295,6 +1356,7 @@ auto ASTDecoder::decodeModuleImportDeclaration( inserter = &(*inserter)->next; } } + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1312,6 +1374,7 @@ auto ASTDecoder::decodeParameterDeclaration( inserter = &(*inserter)->next; } } + ast->thisLoc = SourceLocation(node->this_loc()); if (node->type_specifier_list()) { auto* inserter = &ast->typeSpecifierList; for (std::size_t i = 0; i < node->type_specifier_list()->size(); ++i) { @@ -1322,6 +1385,7 @@ auto ASTDecoder::decodeParameterDeclaration( } } ast->declarator = decodeDeclarator(node->declarator()); + ast->equalLoc = SourceLocation(node->equal_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); if (node->identifier()) { @@ -1336,6 +1400,8 @@ auto ASTDecoder::decodeAccessDeclaration(const io::AccessDeclaration* node) if (!node) return nullptr; auto ast = new (pool_) AccessDeclarationAST(); + ast->accessLoc = SourceLocation(node->access_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); ast->accessSpecifier = static_cast(node->access_specifier()); return ast; } @@ -1372,6 +1438,8 @@ auto ASTDecoder::decodeStructuredBindingDeclaration( inserter = &(*inserter)->next; } } + ast->refQualifierLoc = SourceLocation(node->ref_qualifier_loc()); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); if (node->binding_list()) { auto* inserter = &ast->bindingList; for (std::size_t i = 0; i < node->binding_list()->size(); ++i) { @@ -1379,8 +1447,10 @@ auto ASTDecoder::decodeStructuredBindingDeclaration( inserter = &(*inserter)->next; } } + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); ast->initializer = decodeExpression(node->initializer(), node->initializer_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1389,8 +1459,14 @@ auto ASTDecoder::decodeAsmOperand(const io::AsmOperand* node) if (!node) return nullptr; auto ast = new (pool_) AsmOperandAST(); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); + ast->symbolicNameLoc = SourceLocation(node->symbolic_name_loc()); + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); + ast->constraintLiteralLoc = SourceLocation(node->constraint_literal_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); if (node->symbolic_name()) { ast->symbolicName = unit_->control()->getIdentifier(node->symbolic_name()->str()); @@ -1403,6 +1479,7 @@ auto ASTDecoder::decodeAsmQualifier(const io::AsmQualifier* node) if (!node) return nullptr; auto ast = new (pool_) AsmQualifierAST(); + ast->qualifierLoc = SourceLocation(node->qualifier_loc()); ast->qualifier = static_cast(node->qualifier()); return ast; } @@ -1412,6 +1489,7 @@ auto ASTDecoder::decodeAsmClobber(const io::AsmClobber* node) if (!node) return nullptr; auto ast = new (pool_) AsmClobberAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); if (node->literal()) { ast->literal = unit_->control()->stringLiteral(node->literal()->str()); } @@ -1423,6 +1501,7 @@ auto ASTDecoder::decodeAsmGotoLabel(const io::AsmGotoLabel* node) if (!node) return nullptr; auto ast = new (pool_) AsmGotoLabelAST(); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -1435,6 +1514,8 @@ auto ASTDecoder::decodeLabeledStatement(const io::LabeledStatement* node) if (!node) return nullptr; auto ast = new (pool_) LabeledStatementAST(); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -1447,8 +1528,10 @@ auto ASTDecoder::decodeCaseStatement(const io::CaseStatement* node) if (!node) return nullptr; auto ast = new (pool_) CaseStatementAST(); + ast->caseLoc = SourceLocation(node->case_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->colonLoc = SourceLocation(node->colon_loc()); return ast; } @@ -1457,6 +1540,8 @@ auto ASTDecoder::decodeDefaultStatement(const io::DefaultStatement* node) if (!node) return nullptr; auto ast = new (pool_) DefaultStatementAST(); + ast->defaultLoc = SourceLocation(node->default_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); return ast; } @@ -1467,6 +1552,7 @@ auto ASTDecoder::decodeExpressionStatement(const io::ExpressionStatement* node) auto ast = new (pool_) ExpressionStatementAST(); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1475,6 +1561,7 @@ auto ASTDecoder::decodeCompoundStatement(const io::CompoundStatement* node) if (!node) return nullptr; auto ast = new (pool_) CompoundStatementAST(); + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); if (node->statement_list()) { auto* inserter = &ast->statementList; for (std::size_t i = 0; i < node->statement_list()->size(); ++i) { @@ -1484,6 +1571,7 @@ auto ASTDecoder::decodeCompoundStatement(const io::CompoundStatement* node) inserter = &(*inserter)->next; } } + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); return ast; } @@ -1492,10 +1580,15 @@ auto ASTDecoder::decodeIfStatement(const io::IfStatement* node) if (!node) return nullptr; auto ast = new (pool_) IfStatementAST(); + ast->ifLoc = SourceLocation(node->if_loc()); + ast->constexprLoc = SourceLocation(node->constexpr_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->initializer = decodeStatement(node->initializer(), node->initializer_type()); ast->condition = decodeExpression(node->condition(), node->condition_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->statement = decodeStatement(node->statement(), node->statement_type()); + ast->elseLoc = SourceLocation(node->else_loc()); ast->elseStatement = decodeStatement(node->else_statement(), node->else_statement_type()); return ast; @@ -1506,7 +1599,11 @@ auto ASTDecoder::decodeConstevalIfStatement( if (!node) return nullptr; auto ast = new (pool_) ConstevalIfStatementAST(); + ast->ifLoc = SourceLocation(node->if_loc()); + ast->exclaimLoc = SourceLocation(node->exclaim_loc()); + ast->constvalLoc = SourceLocation(node->constval_loc()); ast->statement = decodeStatement(node->statement(), node->statement_type()); + ast->elseLoc = SourceLocation(node->else_loc()); ast->elseStatement = decodeStatement(node->else_statement(), node->else_statement_type()); return ast; @@ -1517,9 +1614,12 @@ auto ASTDecoder::decodeSwitchStatement(const io::SwitchStatement* node) if (!node) return nullptr; auto ast = new (pool_) SwitchStatementAST(); + ast->switchLoc = SourceLocation(node->switch_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->initializer = decodeStatement(node->initializer(), node->initializer_type()); ast->condition = decodeExpression(node->condition(), node->condition_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->statement = decodeStatement(node->statement(), node->statement_type()); return ast; } @@ -1529,7 +1629,10 @@ auto ASTDecoder::decodeWhileStatement(const io::WhileStatement* node) if (!node) return nullptr; auto ast = new (pool_) WhileStatementAST(); + ast->whileLoc = SourceLocation(node->while_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->condition = decodeExpression(node->condition(), node->condition_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->statement = decodeStatement(node->statement(), node->statement_type()); return ast; } @@ -1539,9 +1642,14 @@ auto ASTDecoder::decodeDoStatement(const io::DoStatement* node) if (!node) return nullptr; auto ast = new (pool_) DoStatementAST(); + ast->doLoc = SourceLocation(node->do_loc()); ast->statement = decodeStatement(node->statement(), node->statement_type()); + ast->whileLoc = SourceLocation(node->while_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1550,12 +1658,16 @@ auto ASTDecoder::decodeForRangeStatement(const io::ForRangeStatement* node) if (!node) return nullptr; auto ast = new (pool_) ForRangeStatementAST(); + ast->forLoc = SourceLocation(node->for_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->initializer = decodeStatement(node->initializer(), node->initializer_type()); ast->rangeDeclaration = decodeDeclaration(node->range_declaration(), node->range_declaration_type()); + ast->colonLoc = SourceLocation(node->colon_loc()); ast->rangeInitializer = decodeExpression(node->range_initializer(), node->range_initializer_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->statement = decodeStatement(node->statement(), node->statement_type()); return ast; } @@ -1565,11 +1677,15 @@ auto ASTDecoder::decodeForStatement(const io::ForStatement* node) if (!node) return nullptr; auto ast = new (pool_) ForStatementAST(); + ast->forLoc = SourceLocation(node->for_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->initializer = decodeStatement(node->initializer(), node->initializer_type()); ast->condition = decodeExpression(node->condition(), node->condition_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->statement = decodeStatement(node->statement(), node->statement_type()); return ast; } @@ -1579,6 +1695,8 @@ auto ASTDecoder::decodeBreakStatement(const io::BreakStatement* node) if (!node) return nullptr; auto ast = new (pool_) BreakStatementAST(); + ast->breakLoc = SourceLocation(node->break_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1587,6 +1705,8 @@ auto ASTDecoder::decodeContinueStatement(const io::ContinueStatement* node) if (!node) return nullptr; auto ast = new (pool_) ContinueStatementAST(); + ast->continueLoc = SourceLocation(node->continue_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1595,8 +1715,10 @@ auto ASTDecoder::decodeReturnStatement(const io::ReturnStatement* node) if (!node) return nullptr; auto ast = new (pool_) ReturnStatementAST(); + ast->returnLoc = SourceLocation(node->return_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1605,8 +1727,10 @@ auto ASTDecoder::decodeCoroutineReturnStatement( if (!node) return nullptr; auto ast = new (pool_) CoroutineReturnStatementAST(); + ast->coreturnLoc = SourceLocation(node->coreturn_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -1615,6 +1739,9 @@ auto ASTDecoder::decodeGotoStatement(const io::GotoStatement* node) if (!node) return nullptr; auto ast = new (pool_) GotoStatementAST(); + ast->gotoLoc = SourceLocation(node->goto_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -1637,6 +1764,7 @@ auto ASTDecoder::decodeTryBlockStatement(const io::TryBlockStatement* node) if (!node) return nullptr; auto ast = new (pool_) TryBlockStatementAST(); + ast->tryLoc = SourceLocation(node->try_loc()); ast->statement = decodeCompoundStatement(node->statement()); if (node->handler_list()) { auto* inserter = &ast->handlerList; @@ -1654,6 +1782,7 @@ auto ASTDecoder::decodeGeneratedLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) GeneratedLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); return ast; } @@ -1662,6 +1791,7 @@ auto ASTDecoder::decodeCharLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) CharLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); if (node->literal()) { ast->literal = unit_->control()->charLiteral(node->literal()->str()); } @@ -1673,6 +1803,7 @@ auto ASTDecoder::decodeBoolLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) BoolLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); return ast; } @@ -1681,6 +1812,7 @@ auto ASTDecoder::decodeIntLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) IntLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); if (node->literal()) { ast->literal = unit_->control()->integerLiteral(node->literal()->str()); } @@ -1692,6 +1824,7 @@ auto ASTDecoder::decodeFloatLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) FloatLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); if (node->literal()) { ast->literal = unit_->control()->floatLiteral(node->literal()->str()); } @@ -1703,6 +1836,7 @@ auto ASTDecoder::decodeNullptrLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) NullptrLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); ast->literal = static_cast(node->literal()); return ast; } @@ -1712,6 +1846,7 @@ auto ASTDecoder::decodeStringLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) StringLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); if (node->literal()) { ast->literal = unit_->control()->stringLiteral(node->literal()->str()); } @@ -1724,6 +1859,7 @@ auto ASTDecoder::decodeUserDefinedStringLiteralExpression( if (!node) return nullptr; auto ast = new (pool_) UserDefinedStringLiteralExpressionAST(); + ast->literalLoc = SourceLocation(node->literal_loc()); if (node->literal()) { ast->literal = unit_->control()->stringLiteral(node->literal()->str()); } @@ -1735,6 +1871,7 @@ auto ASTDecoder::decodeThisExpression(const io::ThisExpression* node) if (!node) return nullptr; auto ast = new (pool_) ThisExpressionAST(); + ast->thisLoc = SourceLocation(node->this_loc()); return ast; } @@ -1743,8 +1880,10 @@ auto ASTDecoder::decodeNestedExpression(const io::NestedExpression* node) if (!node) return nullptr; auto ast = new (pool_) NestedExpressionAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -1755,6 +1894,7 @@ auto ASTDecoder::decodeIdExpression(const io::IdExpression* node) auto ast = new (pool_) IdExpressionAST(); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); return ast; @@ -1765,6 +1905,8 @@ auto ASTDecoder::decodeLambdaExpression(const io::LambdaExpression* node) if (!node) return nullptr; auto ast = new (pool_) LambdaExpressionAST(); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); + ast->captureDefaultLoc = SourceLocation(node->capture_default_loc()); if (node->capture_list()) { auto* inserter = &ast->captureList; for (std::size_t i = 0; i < node->capture_list()->size(); ++i) { @@ -1774,6 +1916,8 @@ auto ASTDecoder::decodeLambdaExpression(const io::LambdaExpression* node) inserter = &(*inserter)->next; } } + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); + ast->lessLoc = SourceLocation(node->less_loc()); if (node->template_parameter_list()) { auto* inserter = &ast->templateParameterList; for (std::size_t i = 0; i < node->template_parameter_list()->size(); ++i) { @@ -1783,10 +1927,13 @@ auto ASTDecoder::decodeLambdaExpression(const io::LambdaExpression* node) inserter = &(*inserter)->next; } } + ast->greaterLoc = SourceLocation(node->greater_loc()); ast->templateRequiresClause = decodeRequiresClause(node->template_requires_clause()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->parameterDeclarationClause = decodeParameterDeclarationClause(node->parameter_declaration_clause()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); if (node->gnu_atribute_list()) { auto* inserter = &ast->gnuAtributeList; for (std::size_t i = 0; i < node->gnu_atribute_list()->size(); ++i) { @@ -1828,10 +1975,15 @@ auto ASTDecoder::decodeFoldExpression(const io::FoldExpression* node) if (!node) return nullptr; auto ast = new (pool_) FoldExpressionAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->leftExpression = decodeExpression(node->left_expression(), node->left_expression_type()); + ast->opLoc = SourceLocation(node->op_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->foldOpLoc = SourceLocation(node->fold_op_loc()); ast->rightExpression = decodeExpression(node->right_expression(), node->right_expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->op = static_cast(node->op()); ast->foldOp = static_cast(node->fold_op()); return ast; @@ -1842,8 +1994,12 @@ auto ASTDecoder::decodeRightFoldExpression(const io::RightFoldExpression* node) if (!node) return nullptr; auto ast = new (pool_) RightFoldExpressionAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->opLoc = SourceLocation(node->op_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->op = static_cast(node->op()); return ast; } @@ -1853,8 +2009,12 @@ auto ASTDecoder::decodeLeftFoldExpression(const io::LeftFoldExpression* node) if (!node) return nullptr; auto ast = new (pool_) LeftFoldExpressionAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->opLoc = SourceLocation(node->op_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->op = static_cast(node->op()); return ast; } @@ -1864,8 +2024,12 @@ auto ASTDecoder::decodeRequiresExpression(const io::RequiresExpression* node) if (!node) return nullptr; auto ast = new (pool_) RequiresExpressionAST(); + ast->requiresLoc = SourceLocation(node->requires_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->parameterDeclarationClause = decodeParameterDeclarationClause(node->parameter_declaration_clause()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); if (node->requirement_list()) { auto* inserter = &ast->requirementList; for (std::size_t i = 0; i < node->requirement_list()->size(); ++i) { @@ -1875,6 +2039,7 @@ auto ASTDecoder::decodeRequiresExpression(const io::RequiresExpression* node) inserter = &(*inserter)->next; } } + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); return ast; } @@ -1883,9 +2048,13 @@ auto ASTDecoder::decodeVaArgExpression(const io::VaArgExpression* node) if (!node) return nullptr; auto ast = new (pool_) VaArgExpressionAST(); + ast->vaArgLoc = SourceLocation(node->va_arg_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->commaLoc = SourceLocation(node->comma_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -1896,8 +2065,10 @@ auto ASTDecoder::decodeSubscriptExpression(const io::SubscriptExpression* node) auto ast = new (pool_) SubscriptExpressionAST(); ast->baseExpression = decodeExpression(node->base_expression(), node->base_expression_type()); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); ast->indexExpression = decodeExpression(node->index_expression(), node->index_expression_type()); + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); return ast; } @@ -1908,6 +2079,7 @@ auto ASTDecoder::decodeCallExpression(const io::CallExpression* node) auto ast = new (pool_) CallExpressionAST(); ast->baseExpression = decodeExpression(node->base_expression(), node->base_expression_type()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->expression_list()) { auto* inserter = &ast->expressionList; for (std::size_t i = 0; i < node->expression_list()->size(); ++i) { @@ -1917,6 +2089,7 @@ auto ASTDecoder::decodeCallExpression(const io::CallExpression* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -1927,6 +2100,7 @@ auto ASTDecoder::decodeTypeConstruction(const io::TypeConstruction* node) auto ast = new (pool_) TypeConstructionAST(); ast->typeSpecifier = decodeSpecifier(node->type_specifier(), node->type_specifier_type()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->expression_list()) { auto* inserter = &ast->expressionList; for (std::size_t i = 0; i < node->expression_list()->size(); ++i) { @@ -1936,6 +2110,7 @@ auto ASTDecoder::decodeTypeConstruction(const io::TypeConstruction* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -1957,6 +2132,8 @@ auto ASTDecoder::decodeSpliceMemberExpression( auto ast = new (pool_) SpliceMemberExpressionAST(); ast->baseExpression = decodeExpression(node->base_expression(), node->base_expression_type()); + ast->accessLoc = SourceLocation(node->access_loc()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->splicer = decodeSplicer(node->splicer()); ast->accessOp = static_cast(node->access_op()); return ast; @@ -1969,8 +2146,10 @@ auto ASTDecoder::decodeMemberExpression(const io::MemberExpression* node) auto ast = new (pool_) MemberExpressionAST(); ast->baseExpression = decodeExpression(node->base_expression(), node->base_expression_type()); + ast->accessLoc = SourceLocation(node->access_loc()); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); ast->accessOp = static_cast(node->access_op()); @@ -1984,6 +2163,7 @@ auto ASTDecoder::decodePostIncrExpression(const io::PostIncrExpression* node) auto ast = new (pool_) PostIncrExpressionAST(); ast->baseExpression = decodeExpression(node->base_expression(), node->base_expression_type()); + ast->opLoc = SourceLocation(node->op_loc()); ast->op = static_cast(node->op()); return ast; } @@ -1993,9 +2173,14 @@ auto ASTDecoder::decodeCppCastExpression(const io::CppCastExpression* node) if (!node) return nullptr; auto ast = new (pool_) CppCastExpressionAST(); + ast->castLoc = SourceLocation(node->cast_loc()); + ast->lessLoc = SourceLocation(node->less_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->greaterLoc = SourceLocation(node->greater_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2004,9 +2189,13 @@ auto ASTDecoder::decodeBuiltinBitCastExpression( if (!node) return nullptr; auto ast = new (pool_) BuiltinBitCastExpressionAST(); + ast->castLoc = SourceLocation(node->cast_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->commaLoc = SourceLocation(node->comma_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2015,8 +2204,11 @@ auto ASTDecoder::decodeTypeidExpression(const io::TypeidExpression* node) if (!node) return nullptr; auto ast = new (pool_) TypeidExpressionAST(); + ast->typeidLoc = SourceLocation(node->typeid_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2025,7 +2217,10 @@ auto ASTDecoder::decodeTypeidOfTypeExpression( if (!node) return nullptr; auto ast = new (pool_) TypeidOfTypeExpressionAST(); + ast->typeidLoc = SourceLocation(node->typeid_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2044,6 +2239,8 @@ auto ASTDecoder::decodeGlobalScopeReflectExpression( if (!node) return nullptr; auto ast = new (pool_) GlobalScopeReflectExpressionAST(); + ast->caretLoc = SourceLocation(node->caret_loc()); + ast->scopeLoc = SourceLocation(node->scope_loc()); return ast; } @@ -2053,6 +2250,8 @@ auto ASTDecoder::decodeNamespaceReflectExpression( if (!node) return nullptr; auto ast = new (pool_) NamespaceReflectExpressionAST(); + ast->caretLoc = SourceLocation(node->caret_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -2065,6 +2264,7 @@ auto ASTDecoder::decodeTypeIdReflectExpression( if (!node) return nullptr; auto ast = new (pool_) TypeIdReflectExpressionAST(); + ast->caretLoc = SourceLocation(node->caret_loc()); ast->typeId = decodeTypeId(node->type_id()); return ast; } @@ -2074,6 +2274,7 @@ auto ASTDecoder::decodeReflectExpression(const io::ReflectExpression* node) if (!node) return nullptr; auto ast = new (pool_) ReflectExpressionAST(); + ast->caretLoc = SourceLocation(node->caret_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2084,6 +2285,7 @@ auto ASTDecoder::decodeUnaryExpression(const io::UnaryExpression* node) if (!node) return nullptr; auto ast = new (pool_) UnaryExpressionAST(); + ast->opLoc = SourceLocation(node->op_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); ast->op = static_cast(node->op()); @@ -2095,6 +2297,7 @@ auto ASTDecoder::decodeAwaitExpression(const io::AwaitExpression* node) if (!node) return nullptr; auto ast = new (pool_) AwaitExpressionAST(); + ast->awaitLoc = SourceLocation(node->await_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2105,6 +2308,7 @@ auto ASTDecoder::decodeSizeofExpression(const io::SizeofExpression* node) if (!node) return nullptr; auto ast = new (pool_) SizeofExpressionAST(); + ast->sizeofLoc = SourceLocation(node->sizeof_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2115,7 +2319,10 @@ auto ASTDecoder::decodeSizeofTypeExpression( if (!node) return nullptr; auto ast = new (pool_) SizeofTypeExpressionAST(); + ast->sizeofLoc = SourceLocation(node->sizeof_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2124,6 +2331,11 @@ auto ASTDecoder::decodeSizeofPackExpression( if (!node) return nullptr; auto ast = new (pool_) SizeofPackExpressionAST(); + ast->sizeofLoc = SourceLocation(node->sizeof_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -2136,7 +2348,10 @@ auto ASTDecoder::decodeAlignofTypeExpression( if (!node) return nullptr; auto ast = new (pool_) AlignofTypeExpressionAST(); + ast->alignofLoc = SourceLocation(node->alignof_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2145,6 +2360,7 @@ auto ASTDecoder::decodeAlignofExpression(const io::AlignofExpression* node) if (!node) return nullptr; auto ast = new (pool_) AlignofExpressionAST(); + ast->alignofLoc = SourceLocation(node->alignof_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2155,8 +2371,11 @@ auto ASTDecoder::decodeNoexceptExpression(const io::NoexceptExpression* node) if (!node) return nullptr; auto ast = new (pool_) NoexceptExpressionAST(); + ast->noexceptLoc = SourceLocation(node->noexcept_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2165,7 +2384,10 @@ auto ASTDecoder::decodeNewExpression(const io::NewExpression* node) if (!node) return nullptr; auto ast = new (pool_) NewExpressionAST(); + ast->scopeLoc = SourceLocation(node->scope_loc()); + ast->newLoc = SourceLocation(node->new_loc()); ast->newPlacement = decodeNewPlacement(node->new_placement()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->type_specifier_list()) { auto* inserter = &ast->typeSpecifierList; for (std::size_t i = 0; i < node->type_specifier_list()->size(); ++i) { @@ -2176,6 +2398,7 @@ auto ASTDecoder::decodeNewExpression(const io::NewExpression* node) } } ast->declarator = decodeDeclarator(node->declarator()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->newInitalizer = decodeNewInitializer(node->new_initalizer(), node->new_initalizer_type()); return ast; @@ -2186,6 +2409,10 @@ auto ASTDecoder::decodeDeleteExpression(const io::DeleteExpression* node) if (!node) return nullptr; auto ast = new (pool_) DeleteExpressionAST(); + ast->scopeLoc = SourceLocation(node->scope_loc()); + ast->deleteLoc = SourceLocation(node->delete_loc()); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2196,7 +2423,9 @@ auto ASTDecoder::decodeCastExpression(const io::CastExpression* node) if (!node) return nullptr; auto ast = new (pool_) CastExpressionAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2219,6 +2448,7 @@ auto ASTDecoder::decodeBinaryExpression(const io::BinaryExpression* node) auto ast = new (pool_) BinaryExpressionAST(); ast->leftExpression = decodeExpression(node->left_expression(), node->left_expression_type()); + ast->opLoc = SourceLocation(node->op_loc()); ast->rightExpression = decodeExpression(node->right_expression(), node->right_expression_type()); ast->op = static_cast(node->op()); @@ -2231,8 +2461,10 @@ auto ASTDecoder::decodeConditionalExpression( auto ast = new (pool_) ConditionalExpressionAST(); ast->condition = decodeExpression(node->condition(), node->condition_type()); + ast->questionLoc = SourceLocation(node->question_loc()); ast->iftrueExpression = decodeExpression(node->iftrue_expression(), node->iftrue_expression_type()); + ast->colonLoc = SourceLocation(node->colon_loc()); ast->iffalseExpression = decodeExpression(node->iffalse_expression(), node->iffalse_expression_type()); return ast; @@ -2243,6 +2475,7 @@ auto ASTDecoder::decodeYieldExpression(const io::YieldExpression* node) if (!node) return nullptr; auto ast = new (pool_) YieldExpressionAST(); + ast->yieldLoc = SourceLocation(node->yield_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2253,6 +2486,7 @@ auto ASTDecoder::decodeThrowExpression(const io::ThrowExpression* node) if (!node) return nullptr; auto ast = new (pool_) ThrowExpressionAST(); + ast->throwLoc = SourceLocation(node->throw_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2265,6 +2499,7 @@ auto ASTDecoder::decodeAssignmentExpression( auto ast = new (pool_) AssignmentExpressionAST(); ast->leftExpression = decodeExpression(node->left_expression(), node->left_expression_type()); + ast->opLoc = SourceLocation(node->op_loc()); ast->rightExpression = decodeExpression(node->right_expression(), node->right_expression_type()); ast->op = static_cast(node->op()); @@ -2278,6 +2513,7 @@ auto ASTDecoder::decodePackExpansionExpression( auto ast = new (pool_) PackExpansionExpressionAST(); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); return ast; } @@ -2287,6 +2523,8 @@ auto ASTDecoder::decodeDesignatedInitializerClause( if (!node) return nullptr; auto ast = new (pool_) DesignatedInitializerClauseAST(); + ast->dotLoc = SourceLocation(node->dot_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -2301,6 +2539,8 @@ auto ASTDecoder::decodeTypeTraitExpression(const io::TypeTraitExpression* node) if (!node) return nullptr; auto ast = new (pool_) TypeTraitExpressionAST(); + ast->typeTraitLoc = SourceLocation(node->type_trait_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->type_id_list()) { auto* inserter = &ast->typeIdList; for (std::size_t i = 0; i < node->type_id_list()->size(); ++i) { @@ -2308,6 +2548,7 @@ auto ASTDecoder::decodeTypeTraitExpression(const io::TypeTraitExpression* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2345,6 +2586,7 @@ auto ASTDecoder::decodeEqualInitializer(const io::EqualInitializer* node) if (!node) return nullptr; auto ast = new (pool_) EqualInitializerAST(); + ast->equalLoc = SourceLocation(node->equal_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2355,6 +2597,7 @@ auto ASTDecoder::decodeBracedInitList(const io::BracedInitList* node) if (!node) return nullptr; auto ast = new (pool_) BracedInitListAST(); + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); if (node->expression_list()) { auto* inserter = &ast->expressionList; for (std::size_t i = 0; i < node->expression_list()->size(); ++i) { @@ -2364,6 +2607,8 @@ auto ASTDecoder::decodeBracedInitList(const io::BracedInitList* node) inserter = &(*inserter)->next; } } + ast->commaLoc = SourceLocation(node->comma_loc()); + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); return ast; } @@ -2372,6 +2617,7 @@ auto ASTDecoder::decodeParenInitializer(const io::ParenInitializer* node) if (!node) return nullptr; auto ast = new (pool_) ParenInitializerAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->expression_list()) { auto* inserter = &ast->expressionList; for (std::size_t i = 0; i < node->expression_list()->size(); ++i) { @@ -2381,6 +2627,7 @@ auto ASTDecoder::decodeParenInitializer(const io::ParenInitializer* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2388,8 +2635,13 @@ auto ASTDecoder::decodeSplicer(const io::Splicer* node) -> SplicerAST* { if (!node) return nullptr; auto ast = new (pool_) SplicerAST(); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->secondColonLoc = SourceLocation(node->second_colon_loc()); + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); return ast; } @@ -2398,6 +2650,8 @@ auto ASTDecoder::decodeGlobalModuleFragment( if (!node) return nullptr; auto ast = new (pool_) GlobalModuleFragmentAST(); + ast->moduleLoc = SourceLocation(node->module_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); if (node->declaration_list()) { auto* inserter = &ast->declarationList; for (std::size_t i = 0; i < node->declaration_list()->size(); ++i) { @@ -2415,6 +2669,10 @@ auto ASTDecoder::decodePrivateModuleFragment( if (!node) return nullptr; auto ast = new (pool_) PrivateModuleFragmentAST(); + ast->moduleLoc = SourceLocation(node->module_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); + ast->privateLoc = SourceLocation(node->private_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); if (node->declaration_list()) { auto* inserter = &ast->declarationList; for (std::size_t i = 0; i < node->declaration_list()->size(); ++i) { @@ -2432,6 +2690,8 @@ auto ASTDecoder::decodeModuleDeclaration(const io::ModuleDeclaration* node) if (!node) return nullptr; auto ast = new (pool_) ModuleDeclarationAST(); + ast->exportLoc = SourceLocation(node->export_loc()); + ast->moduleLoc = SourceLocation(node->module_loc()); ast->moduleName = decodeModuleName(node->module_name()); ast->modulePartition = decodeModulePartition(node->module_partition()); if (node->attribute_list()) { @@ -2443,6 +2703,7 @@ auto ASTDecoder::decodeModuleDeclaration(const io::ModuleDeclaration* node) inserter = &(*inserter)->next; } } + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -2452,6 +2713,7 @@ auto ASTDecoder::decodeModuleName(const io::ModuleName* node) auto ast = new (pool_) ModuleNameAST(); ast->moduleQualifier = decodeModuleQualifier(node->module_qualifier()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -2465,6 +2727,8 @@ auto ASTDecoder::decodeModuleQualifier(const io::ModuleQualifier* node) auto ast = new (pool_) ModuleQualifierAST(); ast->moduleQualifier = decodeModuleQualifier(node->module_qualifier()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->dotLoc = SourceLocation(node->dot_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -2477,6 +2741,7 @@ auto ASTDecoder::decodeModulePartition(const io::ModulePartition* node) if (!node) return nullptr; auto ast = new (pool_) ModulePartitionAST(); + ast->colonLoc = SourceLocation(node->colon_loc()); ast->moduleName = decodeModuleName(node->module_name()); return ast; } @@ -2486,6 +2751,7 @@ auto ASTDecoder::decodeImportName(const io::ImportName* node) if (!node) return nullptr; auto ast = new (pool_) ImportNameAST(); + ast->headerLoc = SourceLocation(node->header_loc()); ast->modulePartition = decodeModulePartition(node->module_partition()); ast->moduleName = decodeModuleName(node->module_name()); return ast; @@ -2536,10 +2802,12 @@ auto ASTDecoder::decodeUsingDeclarator(const io::UsingDeclarator* node) if (!node) return nullptr; auto ast = new (pool_) UsingDeclaratorAST(); + ast->typenameLoc = SourceLocation(node->typename_loc()); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); return ast; } @@ -2548,6 +2816,7 @@ auto ASTDecoder::decodeEnumerator(const io::Enumerator* node) if (!node) return nullptr; auto ast = new (pool_) EnumeratorAST(); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -2557,6 +2826,7 @@ auto ASTDecoder::decodeEnumerator(const io::Enumerator* node) inserter = &(*inserter)->next; } } + ast->equalLoc = SourceLocation(node->equal_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); if (node->identifier()) { @@ -2587,8 +2857,11 @@ auto ASTDecoder::decodeHandler(const io::Handler* node) -> HandlerAST* { if (!node) return nullptr; auto ast = new (pool_) HandlerAST(); + ast->catchLoc = SourceLocation(node->catch_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->exceptionDeclaration = decodeExceptionDeclaration( node->exception_declaration(), node->exception_declaration_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); ast->statement = decodeCompoundStatement(node->statement()); return ast; } @@ -2609,6 +2882,7 @@ auto ASTDecoder::decodeBaseSpecifier(const io::BaseSpecifier* node) } ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); ast->accessSpecifier = static_cast(node->access_specifier()); @@ -2620,6 +2894,7 @@ auto ASTDecoder::decodeRequiresClause(const io::RequiresClause* node) if (!node) return nullptr; auto ast = new (pool_) RequiresClauseAST(); + ast->requiresLoc = SourceLocation(node->requires_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); return ast; @@ -2640,6 +2915,8 @@ auto ASTDecoder::decodeParameterDeclarationClause( inserter = &(*inserter)->next; } } + ast->commaLoc = SourceLocation(node->comma_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); return ast; } @@ -2648,6 +2925,7 @@ auto ASTDecoder::decodeTrailingReturnType(const io::TrailingReturnType* node) if (!node) return nullptr; auto ast = new (pool_) TrailingReturnTypeAST(); + ast->minusGreaterLoc = SourceLocation(node->minus_greater_loc()); ast->typeId = decodeTypeId(node->type_id()); return ast; } @@ -2657,6 +2935,7 @@ auto ASTDecoder::decodeLambdaSpecifier(const io::LambdaSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) LambdaSpecifierAST(); + ast->specifierLoc = SourceLocation(node->specifier_loc()); ast->specifier = static_cast(node->specifier()); return ast; } @@ -2668,6 +2947,8 @@ auto ASTDecoder::decodeTypeConstraint(const io::TypeConstraint* node) auto ast = new (pool_) TypeConstraintAST(); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->lessLoc = SourceLocation(node->less_loc()); if (node->template_argument_list()) { auto* inserter = &ast->templateArgumentList; for (std::size_t i = 0; i < node->template_argument_list()->size(); ++i) { @@ -2677,6 +2958,7 @@ auto ASTDecoder::decodeTypeConstraint(const io::TypeConstraint* node) inserter = &(*inserter)->next; } } + ast->greaterLoc = SourceLocation(node->greater_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -2689,6 +2971,8 @@ auto ASTDecoder::decodeAttributeArgumentClause( if (!node) return nullptr; auto ast = new (pool_) AttributeArgumentClauseAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2700,6 +2984,7 @@ auto ASTDecoder::decodeAttribute(const io::Attribute* node) -> AttributeAST* { node->attribute_token_type()); ast->attributeArgumentClause = decodeAttributeArgumentClause(node->attribute_argument_clause()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); return ast; } @@ -2708,6 +2993,9 @@ auto ASTDecoder::decodeAttributeUsingPrefix( if (!node) return nullptr; auto ast = new (pool_) AttributeUsingPrefixAST(); + ast->usingLoc = SourceLocation(node->using_loc()); + ast->attributeNamespaceLoc = SourceLocation(node->attribute_namespace_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); return ast; } @@ -2716,6 +3004,7 @@ auto ASTDecoder::decodeNewPlacement(const io::NewPlacement* node) if (!node) return nullptr; auto ast = new (pool_) NewPlacementAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->expression_list()) { auto* inserter = &ast->expressionList; for (std::size_t i = 0; i < node->expression_list()->size(); ++i) { @@ -2725,6 +3014,7 @@ auto ASTDecoder::decodeNewPlacement(const io::NewPlacement* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2733,6 +3023,9 @@ auto ASTDecoder::decodeNestedNamespaceSpecifier( if (!node) return nullptr; auto ast = new (pool_) NestedNamespaceSpecifierAST(); + ast->inlineLoc = SourceLocation(node->inline_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->scopeLoc = SourceLocation(node->scope_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -2745,6 +3038,8 @@ auto ASTDecoder::decodeTemplateTypeParameter( if (!node) return nullptr; auto ast = new (pool_) TemplateTypeParameterAST(); + ast->templateLoc = SourceLocation(node->template_loc()); + ast->lessLoc = SourceLocation(node->less_loc()); if (node->template_parameter_list()) { auto* inserter = &ast->templateParameterList; for (std::size_t i = 0; i < node->template_parameter_list()->size(); ++i) { @@ -2754,7 +3049,12 @@ auto ASTDecoder::decodeTemplateTypeParameter( inserter = &(*inserter)->next; } } + ast->greaterLoc = SourceLocation(node->greater_loc()); ast->requiresClause = decodeRequiresClause(node->requires_clause()); + ast->classKeyLoc = SourceLocation(node->class_key_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->equalLoc = SourceLocation(node->equal_loc()); ast->idExpression = decodeIdExpression(node->id_expression()); if (node->identifier()) { ast->identifier = @@ -2777,6 +3077,10 @@ auto ASTDecoder::decodeTypenameTypeParameter( if (!node) return nullptr; auto ast = new (pool_) TypenameTypeParameterAST(); + ast->classKeyLoc = SourceLocation(node->class_key_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->equalLoc = SourceLocation(node->equal_loc()); ast->typeId = decodeTypeId(node->type_id()); if (node->identifier()) { ast->identifier = @@ -2791,6 +3095,9 @@ auto ASTDecoder::decodeConstraintTypeParameter( auto ast = new (pool_) ConstraintTypeParameterAST(); ast->typeConstraint = decodeTypeConstraint(node->type_constraint()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->equalLoc = SourceLocation(node->equal_loc()); ast->typeId = decodeTypeId(node->type_id()); if (node->identifier()) { ast->identifier = @@ -2804,6 +3111,7 @@ auto ASTDecoder::decodeGeneratedTypeSpecifier( if (!node) return nullptr; auto ast = new (pool_) GeneratedTypeSpecifierAST(); + ast->typeLoc = SourceLocation(node->type_loc()); return ast; } @@ -2812,6 +3120,7 @@ auto ASTDecoder::decodeTypedefSpecifier(const io::TypedefSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) TypedefSpecifierAST(); + ast->typedefLoc = SourceLocation(node->typedef_loc()); return ast; } @@ -2820,6 +3129,7 @@ auto ASTDecoder::decodeFriendSpecifier(const io::FriendSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) FriendSpecifierAST(); + ast->friendLoc = SourceLocation(node->friend_loc()); return ast; } @@ -2828,6 +3138,7 @@ auto ASTDecoder::decodeConstevalSpecifier(const io::ConstevalSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) ConstevalSpecifierAST(); + ast->constevalLoc = SourceLocation(node->consteval_loc()); return ast; } @@ -2836,6 +3147,7 @@ auto ASTDecoder::decodeConstinitSpecifier(const io::ConstinitSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) ConstinitSpecifierAST(); + ast->constinitLoc = SourceLocation(node->constinit_loc()); return ast; } @@ -2844,6 +3156,7 @@ auto ASTDecoder::decodeConstexprSpecifier(const io::ConstexprSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) ConstexprSpecifierAST(); + ast->constexprLoc = SourceLocation(node->constexpr_loc()); return ast; } @@ -2852,6 +3165,7 @@ auto ASTDecoder::decodeInlineSpecifier(const io::InlineSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) InlineSpecifierAST(); + ast->inlineLoc = SourceLocation(node->inline_loc()); return ast; } @@ -2860,6 +3174,7 @@ auto ASTDecoder::decodeStaticSpecifier(const io::StaticSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) StaticSpecifierAST(); + ast->staticLoc = SourceLocation(node->static_loc()); return ast; } @@ -2868,6 +3183,7 @@ auto ASTDecoder::decodeExternSpecifier(const io::ExternSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) ExternSpecifierAST(); + ast->externLoc = SourceLocation(node->extern_loc()); return ast; } @@ -2876,6 +3192,7 @@ auto ASTDecoder::decodeThreadLocalSpecifier( if (!node) return nullptr; auto ast = new (pool_) ThreadLocalSpecifierAST(); + ast->threadLocalLoc = SourceLocation(node->thread_local_loc()); return ast; } @@ -2884,6 +3201,7 @@ auto ASTDecoder::decodeThreadSpecifier(const io::ThreadSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) ThreadSpecifierAST(); + ast->threadLoc = SourceLocation(node->thread_loc()); return ast; } @@ -2892,6 +3210,7 @@ auto ASTDecoder::decodeMutableSpecifier(const io::MutableSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) MutableSpecifierAST(); + ast->mutableLoc = SourceLocation(node->mutable_loc()); return ast; } @@ -2900,6 +3219,7 @@ auto ASTDecoder::decodeVirtualSpecifier(const io::VirtualSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) VirtualSpecifierAST(); + ast->virtualLoc = SourceLocation(node->virtual_loc()); return ast; } @@ -2908,8 +3228,11 @@ auto ASTDecoder::decodeExplicitSpecifier(const io::ExplicitSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) ExplicitSpecifierAST(); + ast->explicitLoc = SourceLocation(node->explicit_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -2918,6 +3241,7 @@ auto ASTDecoder::decodeAutoTypeSpecifier(const io::AutoTypeSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) AutoTypeSpecifierAST(); + ast->autoLoc = SourceLocation(node->auto_loc()); return ast; } @@ -2926,6 +3250,7 @@ auto ASTDecoder::decodeVoidTypeSpecifier(const io::VoidTypeSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) VoidTypeSpecifierAST(); + ast->voidLoc = SourceLocation(node->void_loc()); return ast; } @@ -2934,6 +3259,7 @@ auto ASTDecoder::decodeSizeTypeSpecifier(const io::SizeTypeSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) SizeTypeSpecifierAST(); + ast->specifierLoc = SourceLocation(node->specifier_loc()); ast->specifier = static_cast(node->specifier()); return ast; } @@ -2943,6 +3269,7 @@ auto ASTDecoder::decodeSignTypeSpecifier(const io::SignTypeSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) SignTypeSpecifierAST(); + ast->specifierLoc = SourceLocation(node->specifier_loc()); ast->specifier = static_cast(node->specifier()); return ast; } @@ -2952,6 +3279,7 @@ auto ASTDecoder::decodeVaListTypeSpecifier(const io::VaListTypeSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) VaListTypeSpecifierAST(); + ast->specifierLoc = SourceLocation(node->specifier_loc()); ast->specifier = static_cast(node->specifier()); return ast; } @@ -2961,6 +3289,7 @@ auto ASTDecoder::decodeIntegralTypeSpecifier( if (!node) return nullptr; auto ast = new (pool_) IntegralTypeSpecifierAST(); + ast->specifierLoc = SourceLocation(node->specifier_loc()); ast->specifier = static_cast(node->specifier()); return ast; } @@ -2971,6 +3300,7 @@ auto ASTDecoder::decodeFloatingPointTypeSpecifier( if (!node) return nullptr; auto ast = new (pool_) FloatingPointTypeSpecifierAST(); + ast->specifierLoc = SourceLocation(node->specifier_loc()); ast->specifier = static_cast(node->specifier()); return ast; } @@ -2980,6 +3310,7 @@ auto ASTDecoder::decodeComplexTypeSpecifier( if (!node) return nullptr; auto ast = new (pool_) ComplexTypeSpecifierAST(); + ast->complexLoc = SourceLocation(node->complex_loc()); return ast; } @@ -2990,6 +3321,7 @@ auto ASTDecoder::decodeNamedTypeSpecifier(const io::NamedTypeSpecifier* node) auto ast = new (pool_) NamedTypeSpecifierAST(); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); return ast; @@ -3000,7 +3332,10 @@ auto ASTDecoder::decodeAtomicTypeSpecifier(const io::AtomicTypeSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) AtomicTypeSpecifierAST(); + ast->atomicLoc = SourceLocation(node->atomic_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3009,7 +3344,10 @@ auto ASTDecoder::decodeUnderlyingTypeSpecifier( if (!node) return nullptr; auto ast = new (pool_) UnderlyingTypeSpecifierAST(); + ast->underlyingTypeLoc = SourceLocation(node->underlying_type_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3018,6 +3356,7 @@ auto ASTDecoder::decodeElaboratedTypeSpecifier( if (!node) return nullptr; auto ast = new (pool_) ElaboratedTypeSpecifierAST(); + ast->classLoc = SourceLocation(node->class_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -3029,6 +3368,7 @@ auto ASTDecoder::decodeElaboratedTypeSpecifier( } ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); ast->classKey = static_cast(node->class_key()); @@ -3040,6 +3380,10 @@ auto ASTDecoder::decodeDecltypeAutoSpecifier( if (!node) return nullptr; auto ast = new (pool_) DecltypeAutoSpecifierAST(); + ast->decltypeLoc = SourceLocation(node->decltype_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->autoLoc = SourceLocation(node->auto_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3048,8 +3392,11 @@ auto ASTDecoder::decodeDecltypeSpecifier(const io::DecltypeSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) DecltypeSpecifierAST(); + ast->decltypeLoc = SourceLocation(node->decltype_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3068,6 +3415,7 @@ auto ASTDecoder::decodeConstQualifier(const io::ConstQualifier* node) if (!node) return nullptr; auto ast = new (pool_) ConstQualifierAST(); + ast->constLoc = SourceLocation(node->const_loc()); return ast; } @@ -3076,6 +3424,7 @@ auto ASTDecoder::decodeVolatileQualifier(const io::VolatileQualifier* node) if (!node) return nullptr; auto ast = new (pool_) VolatileQualifierAST(); + ast->volatileLoc = SourceLocation(node->volatile_loc()); return ast; } @@ -3084,6 +3433,7 @@ auto ASTDecoder::decodeRestrictQualifier(const io::RestrictQualifier* node) if (!node) return nullptr; auto ast = new (pool_) RestrictQualifierAST(); + ast->restrictLoc = SourceLocation(node->restrict_loc()); return ast; } @@ -3092,6 +3442,8 @@ auto ASTDecoder::decodeEnumSpecifier(const io::EnumSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) EnumSpecifierAST(); + ast->enumLoc = SourceLocation(node->enum_loc()); + ast->classLoc = SourceLocation(node->class_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -3104,6 +3456,7 @@ auto ASTDecoder::decodeEnumSpecifier(const io::EnumSpecifier* node) ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeNameId(node->unqualified_id()); + ast->colonLoc = SourceLocation(node->colon_loc()); if (node->type_specifier_list()) { auto* inserter = &ast->typeSpecifierList; for (std::size_t i = 0; i < node->type_specifier_list()->size(); ++i) { @@ -3113,6 +3466,8 @@ auto ASTDecoder::decodeEnumSpecifier(const io::EnumSpecifier* node) inserter = &(*inserter)->next; } } + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); + ast->commaLoc = SourceLocation(node->comma_loc()); if (node->enumerator_list()) { auto* inserter = &ast->enumeratorList; for (std::size_t i = 0; i < node->enumerator_list()->size(); ++i) { @@ -3121,6 +3476,7 @@ auto ASTDecoder::decodeEnumSpecifier(const io::EnumSpecifier* node) inserter = &(*inserter)->next; } } + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); return ast; } @@ -3129,6 +3485,7 @@ auto ASTDecoder::decodeClassSpecifier(const io::ClassSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) ClassSpecifierAST(); + ast->classLoc = SourceLocation(node->class_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -3142,6 +3499,8 @@ auto ASTDecoder::decodeClassSpecifier(const io::ClassSpecifier* node) node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); + ast->finalLoc = SourceLocation(node->final_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); if (node->base_specifier_list()) { auto* inserter = &ast->baseSpecifierList; for (std::size_t i = 0; i < node->base_specifier_list()->size(); ++i) { @@ -3150,6 +3509,7 @@ auto ASTDecoder::decodeClassSpecifier(const io::ClassSpecifier* node) inserter = &(*inserter)->next; } } + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); if (node->declaration_list()) { auto* inserter = &ast->declarationList; for (std::size_t i = 0; i < node->declaration_list()->size(); ++i) { @@ -3159,6 +3519,7 @@ auto ASTDecoder::decodeClassSpecifier(const io::ClassSpecifier* node) inserter = &(*inserter)->next; } } + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); ast->classKey = static_cast(node->class_key()); return ast; } @@ -3168,6 +3529,7 @@ auto ASTDecoder::decodeTypenameSpecifier(const io::TypenameSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) TypenameSpecifierAST(); + ast->typenameLoc = SourceLocation(node->typename_loc()); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = @@ -3180,6 +3542,7 @@ auto ASTDecoder::decodeSplicerTypeSpecifier( if (!node) return nullptr; auto ast = new (pool_) SplicerTypeSpecifierAST(); + ast->typenameLoc = SourceLocation(node->typename_loc()); ast->splicer = decodeSplicer(node->splicer()); return ast; } @@ -3189,6 +3552,7 @@ auto ASTDecoder::decodePointerOperator(const io::PointerOperator* node) if (!node) return nullptr; auto ast = new (pool_) PointerOperatorAST(); + ast->starLoc = SourceLocation(node->star_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -3215,6 +3579,7 @@ auto ASTDecoder::decodeReferenceOperator(const io::ReferenceOperator* node) if (!node) return nullptr; auto ast = new (pool_) ReferenceOperatorAST(); + ast->refLoc = SourceLocation(node->ref_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -3235,6 +3600,7 @@ auto ASTDecoder::decodePtrToMemberOperator(const io::PtrToMemberOperator* node) auto ast = new (pool_) PtrToMemberOperatorAST(); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->starLoc = SourceLocation(node->star_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -3262,6 +3628,7 @@ auto ASTDecoder::decodeBitfieldDeclarator(const io::BitfieldDeclarator* node) auto ast = new (pool_) BitfieldDeclaratorAST(); ast->unqualifiedId = decodeNameId(node->unqualified_id()); + ast->colonLoc = SourceLocation(node->colon_loc()); ast->sizeExpression = decodeExpression(node->size_expression(), node->size_expression_type()); return ast; @@ -3272,6 +3639,7 @@ auto ASTDecoder::decodeParameterPack(const io::ParameterPack* node) if (!node) return nullptr; auto ast = new (pool_) ParameterPackAST(); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); ast->coreDeclarator = decodeCoreDeclarator(node->core_declarator(), node->core_declarator_type()); return ast; @@ -3284,6 +3652,7 @@ auto ASTDecoder::decodeIdDeclarator(const io::IdDeclarator* node) auto ast = new (pool_) IdDeclaratorAST(); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); if (node->attribute_list()) { @@ -3303,7 +3672,9 @@ auto ASTDecoder::decodeNestedDeclarator(const io::NestedDeclarator* node) if (!node) return nullptr; auto ast = new (pool_) NestedDeclaratorAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->declarator = decodeDeclarator(node->declarator()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3312,8 +3683,10 @@ auto ASTDecoder::decodeFunctionDeclaratorChunk( if (!node) return nullptr; auto ast = new (pool_) FunctionDeclaratorChunkAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->parameterDeclarationClause = decodeParameterDeclarationClause(node->parameter_declaration_clause()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); if (node->cv_qualifier_list()) { auto* inserter = &ast->cvQualifierList; for (std::size_t i = 0; i < node->cv_qualifier_list()->size(); ++i) { @@ -3323,6 +3696,7 @@ auto ASTDecoder::decodeFunctionDeclaratorChunk( inserter = &(*inserter)->next; } } + ast->refLoc = SourceLocation(node->ref_loc()); ast->exceptionSpecifier = decodeExceptionSpecifier( node->exception_specifier(), node->exception_specifier_type()); if (node->attribute_list()) { @@ -3344,8 +3718,10 @@ auto ASTDecoder::decodeArrayDeclaratorChunk( if (!node) return nullptr; auto ast = new (pool_) ArrayDeclaratorChunkAST(); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); if (node->attribute_list()) { auto* inserter = &ast->attributeList; for (std::size_t i = 0; i < node->attribute_list()->size(); ++i) { @@ -3362,6 +3738,7 @@ auto ASTDecoder::decodeNameId(const io::NameId* node) -> NameIdAST* { if (!node) return nullptr; auto ast = new (pool_) NameIdAST(); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -3374,6 +3751,7 @@ auto ASTDecoder::decodeDestructorId(const io::DestructorId* node) if (!node) return nullptr; auto ast = new (pool_) DestructorIdAST(); + ast->tildeLoc = SourceLocation(node->tilde_loc()); ast->id = decodeUnqualifiedId(node->id(), node->id_type()); return ast; } @@ -3392,6 +3770,10 @@ auto ASTDecoder::decodeOperatorFunctionId(const io::OperatorFunctionId* node) if (!node) return nullptr; auto ast = new (pool_) OperatorFunctionIdAST(); + ast->operatorLoc = SourceLocation(node->operator_loc()); + ast->opLoc = SourceLocation(node->op_loc()); + ast->openLoc = SourceLocation(node->open_loc()); + ast->closeLoc = SourceLocation(node->close_loc()); ast->op = static_cast(node->op()); return ast; } @@ -3401,6 +3783,9 @@ auto ASTDecoder::decodeLiteralOperatorId(const io::LiteralOperatorId* node) if (!node) return nullptr; auto ast = new (pool_) LiteralOperatorIdAST(); + ast->operatorLoc = SourceLocation(node->operator_loc()); + ast->literalLoc = SourceLocation(node->literal_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -3413,6 +3798,7 @@ auto ASTDecoder::decodeConversionFunctionId( if (!node) return nullptr; auto ast = new (pool_) ConversionFunctionIdAST(); + ast->operatorLoc = SourceLocation(node->operator_loc()); ast->typeId = decodeTypeId(node->type_id()); return ast; } @@ -3422,6 +3808,8 @@ auto ASTDecoder::decodeSimpleTemplateId(const io::SimpleTemplateId* node) if (!node) return nullptr; auto ast = new (pool_) SimpleTemplateIdAST(); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->lessLoc = SourceLocation(node->less_loc()); if (node->template_argument_list()) { auto* inserter = &ast->templateArgumentList; for (std::size_t i = 0; i < node->template_argument_list()->size(); ++i) { @@ -3431,6 +3819,7 @@ auto ASTDecoder::decodeSimpleTemplateId(const io::SimpleTemplateId* node) inserter = &(*inserter)->next; } } + ast->greaterLoc = SourceLocation(node->greater_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -3445,6 +3834,7 @@ auto ASTDecoder::decodeLiteralOperatorTemplateId( auto ast = new (pool_) LiteralOperatorTemplateIdAST(); ast->literalOperatorId = decodeLiteralOperatorId(node->literal_operator_id()); + ast->lessLoc = SourceLocation(node->less_loc()); if (node->template_argument_list()) { auto* inserter = &ast->templateArgumentList; for (std::size_t i = 0; i < node->template_argument_list()->size(); ++i) { @@ -3454,6 +3844,7 @@ auto ASTDecoder::decodeLiteralOperatorTemplateId( inserter = &(*inserter)->next; } } + ast->greaterLoc = SourceLocation(node->greater_loc()); return ast; } @@ -3465,6 +3856,7 @@ auto ASTDecoder::decodeOperatorFunctionTemplateId( auto ast = new (pool_) OperatorFunctionTemplateIdAST(); ast->operatorFunctionId = decodeOperatorFunctionId(node->operator_function_id()); + ast->lessLoc = SourceLocation(node->less_loc()); if (node->template_argument_list()) { auto* inserter = &ast->templateArgumentList; for (std::size_t i = 0; i < node->template_argument_list()->size(); ++i) { @@ -3474,6 +3866,7 @@ auto ASTDecoder::decodeOperatorFunctionTemplateId( inserter = &(*inserter)->next; } } + ast->greaterLoc = SourceLocation(node->greater_loc()); return ast; } @@ -3483,6 +3876,7 @@ auto ASTDecoder::decodeGlobalNestedNameSpecifier( if (!node) return nullptr; auto ast = new (pool_) GlobalNestedNameSpecifierAST(); + ast->scopeLoc = SourceLocation(node->scope_loc()); return ast; } @@ -3494,10 +3888,12 @@ auto ASTDecoder::decodeSimpleNestedNameSpecifier( auto ast = new (pool_) SimpleNestedNameSpecifierAST(); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); } + ast->scopeLoc = SourceLocation(node->scope_loc()); return ast; } @@ -3510,6 +3906,7 @@ auto ASTDecoder::decodeDecltypeNestedNameSpecifier( ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->decltypeSpecifier = decodeDecltypeSpecifier(node->decltype_specifier()); + ast->scopeLoc = SourceLocation(node->scope_loc()); return ast; } @@ -3521,7 +3918,9 @@ auto ASTDecoder::decodeTemplateNestedNameSpecifier( auto ast = new (pool_) TemplateNestedNameSpecifierAST(); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); + ast->templateLoc = SourceLocation(node->template_loc()); ast->templateId = decodeSimpleTemplateId(node->template_id()); + ast->scopeLoc = SourceLocation(node->scope_loc()); return ast; } @@ -3530,6 +3929,9 @@ auto ASTDecoder::decodeDefaultFunctionBody(const io::DefaultFunctionBody* node) if (!node) return nullptr; auto ast = new (pool_) DefaultFunctionBodyAST(); + ast->equalLoc = SourceLocation(node->equal_loc()); + ast->defaultLoc = SourceLocation(node->default_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -3539,6 +3941,7 @@ auto ASTDecoder::decodeCompoundStatementFunctionBody( if (!node) return nullptr; auto ast = new (pool_) CompoundStatementFunctionBodyAST(); + ast->colonLoc = SourceLocation(node->colon_loc()); if (node->mem_initializer_list()) { auto* inserter = &ast->memInitializerList; for (std::size_t i = 0; i < node->mem_initializer_list()->size(); ++i) { @@ -3557,6 +3960,8 @@ auto ASTDecoder::decodeTryStatementFunctionBody( if (!node) return nullptr; auto ast = new (pool_) TryStatementFunctionBodyAST(); + ast->tryLoc = SourceLocation(node->try_loc()); + ast->colonLoc = SourceLocation(node->colon_loc()); if (node->mem_initializer_list()) { auto* inserter = &ast->memInitializerList; for (std::size_t i = 0; i < node->mem_initializer_list()->size(); ++i) { @@ -3582,6 +3987,9 @@ auto ASTDecoder::decodeDeleteFunctionBody(const io::DeleteFunctionBody* node) if (!node) return nullptr; auto ast = new (pool_) DeleteFunctionBodyAST(); + ast->equalLoc = SourceLocation(node->equal_loc()); + ast->deleteLoc = SourceLocation(node->delete_loc()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -3610,6 +4018,9 @@ auto ASTDecoder::decodeThrowExceptionSpecifier( if (!node) return nullptr; auto ast = new (pool_) ThrowExceptionSpecifierAST(); + ast->throwLoc = SourceLocation(node->throw_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3618,8 +4029,11 @@ auto ASTDecoder::decodeNoexceptSpecifier(const io::NoexceptSpecifier* node) if (!node) return nullptr; auto ast = new (pool_) NoexceptSpecifierAST(); + ast->noexceptLoc = SourceLocation(node->noexcept_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3630,6 +4044,7 @@ auto ASTDecoder::decodeSimpleRequirement(const io::SimpleRequirement* node) auto ast = new (pool_) SimpleRequirementAST(); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -3638,9 +4053,14 @@ auto ASTDecoder::decodeCompoundRequirement(const io::CompoundRequirement* node) if (!node) return nullptr; auto ast = new (pool_) CompoundRequirementAST(); + ast->lbraceLoc = SourceLocation(node->lbrace_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->rbraceLoc = SourceLocation(node->rbrace_loc()); + ast->noexceptLoc = SourceLocation(node->noexcept_loc()); + ast->minusGreaterLoc = SourceLocation(node->minus_greater_loc()); ast->typeConstraint = decodeTypeConstraint(node->type_constraint()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -3649,10 +4069,12 @@ auto ASTDecoder::decodeTypeRequirement(const io::TypeRequirement* node) if (!node) return nullptr; auto ast = new (pool_) TypeRequirementAST(); + ast->typenameLoc = SourceLocation(node->typename_loc()); ast->nestedNameSpecifier = decodeNestedNameSpecifier( node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -3661,8 +4083,10 @@ auto ASTDecoder::decodeNestedRequirement(const io::NestedRequirement* node) if (!node) return nullptr; auto ast = new (pool_) NestedRequirementAST(); + ast->requiresLoc = SourceLocation(node->requires_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->semicolonLoc = SourceLocation(node->semicolon_loc()); return ast; } @@ -3671,6 +4095,7 @@ auto ASTDecoder::decodeNewParenInitializer(const io::NewParenInitializer* node) if (!node) return nullptr; auto ast = new (pool_) NewParenInitializerAST(); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->expression_list()) { auto* inserter = &ast->expressionList; for (std::size_t i = 0; i < node->expression_list()->size(); ++i) { @@ -3680,6 +4105,7 @@ auto ASTDecoder::decodeNewParenInitializer(const io::NewParenInitializer* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3701,6 +4127,7 @@ auto ASTDecoder::decodeParenMemInitializer(const io::ParenMemInitializer* node) node->nested_name_specifier(), node->nested_name_specifier_type()); ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); if (node->expression_list()) { auto* inserter = &ast->expressionList; for (std::size_t i = 0; i < node->expression_list()->size(); ++i) { @@ -3710,6 +4137,8 @@ auto ASTDecoder::decodeParenMemInitializer(const io::ParenMemInitializer* node) inserter = &(*inserter)->next; } } + ast->rparenLoc = SourceLocation(node->rparen_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); return ast; } @@ -3723,6 +4152,7 @@ auto ASTDecoder::decodeBracedMemInitializer( ast->unqualifiedId = decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type()); ast->bracedInitList = decodeBracedInitList(node->braced_init_list()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); return ast; } @@ -3731,6 +4161,7 @@ auto ASTDecoder::decodeThisLambdaCapture(const io::ThisLambdaCapture* node) if (!node) return nullptr; auto ast = new (pool_) ThisLambdaCaptureAST(); + ast->thisLoc = SourceLocation(node->this_loc()); return ast; } @@ -3739,6 +4170,8 @@ auto ASTDecoder::decodeDerefThisLambdaCapture( if (!node) return nullptr; auto ast = new (pool_) DerefThisLambdaCaptureAST(); + ast->starLoc = SourceLocation(node->star_loc()); + ast->thisLoc = SourceLocation(node->this_loc()); return ast; } @@ -3747,6 +4180,8 @@ auto ASTDecoder::decodeSimpleLambdaCapture(const io::SimpleLambdaCapture* node) if (!node) return nullptr; auto ast = new (pool_) SimpleLambdaCaptureAST(); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -3759,6 +4194,9 @@ auto ASTDecoder::decodeRefLambdaCapture(const io::RefLambdaCapture* node) if (!node) return nullptr; auto ast = new (pool_) RefLambdaCaptureAST(); + ast->ampLoc = SourceLocation(node->amp_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); @@ -3771,6 +4209,9 @@ auto ASTDecoder::decodeRefInitLambdaCapture( if (!node) return nullptr; auto ast = new (pool_) RefInitLambdaCaptureAST(); + ast->ampLoc = SourceLocation(node->amp_loc()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); ast->initializer = decodeExpression(node->initializer(), node->initializer_type()); if (node->identifier()) { @@ -3785,6 +4226,8 @@ auto ASTDecoder::decodeInitLambdaCapture(const io::InitLambdaCapture* node) if (!node) return nullptr; auto ast = new (pool_) InitLambdaCaptureAST(); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); ast->initializer = decodeExpression(node->initializer(), node->initializer_type()); if (node->identifier()) { @@ -3800,6 +4243,7 @@ auto ASTDecoder::decodeEllipsisExceptionDeclaration( if (!node) return nullptr; auto ast = new (pool_) EllipsisExceptionDeclarationAST(); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); return ast; } @@ -3835,6 +4279,8 @@ auto ASTDecoder::decodeCxxAttribute(const io::CxxAttribute* node) if (!node) return nullptr; auto ast = new (pool_) CxxAttributeAST(); + ast->lbracketLoc = SourceLocation(node->lbracket_loc()); + ast->lbracket2Loc = SourceLocation(node->lbracket2_loc()); ast->attributeUsingPrefix = decodeAttributeUsingPrefix(node->attribute_using_prefix()); if (node->attribute_list()) { @@ -3845,6 +4291,8 @@ auto ASTDecoder::decodeCxxAttribute(const io::CxxAttribute* node) inserter = &(*inserter)->next; } } + ast->rbracketLoc = SourceLocation(node->rbracket_loc()); + ast->rbracket2Loc = SourceLocation(node->rbracket2_loc()); return ast; } @@ -3853,6 +4301,11 @@ auto ASTDecoder::decodeGccAttribute(const io::GccAttribute* node) if (!node) return nullptr; auto ast = new (pool_) GccAttributeAST(); + ast->attributeLoc = SourceLocation(node->attribute_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->lparen2Loc = SourceLocation(node->lparen2_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); + ast->rparen2Loc = SourceLocation(node->rparen2_loc()); return ast; } @@ -3861,8 +4314,12 @@ auto ASTDecoder::decodeAlignasAttribute(const io::AlignasAttribute* node) if (!node) return nullptr; auto ast = new (pool_) AlignasAttributeAST(); + ast->alignasLoc = SourceLocation(node->alignas_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->expression = decodeExpression(node->expression(), node->expression_type()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3871,7 +4328,11 @@ auto ASTDecoder::decodeAlignasTypeAttribute( if (!node) return nullptr; auto ast = new (pool_) AlignasTypeAttributeAST(); + ast->alignasLoc = SourceLocation(node->alignas_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); ast->typeId = decodeTypeId(node->type_id()); + ast->ellipsisLoc = SourceLocation(node->ellipsis_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3880,6 +4341,10 @@ auto ASTDecoder::decodeAsmAttribute(const io::AsmAttribute* node) if (!node) return nullptr; auto ast = new (pool_) AsmAttributeAST(); + ast->asmLoc = SourceLocation(node->asm_loc()); + ast->lparenLoc = SourceLocation(node->lparen_loc()); + ast->literalLoc = SourceLocation(node->literal_loc()); + ast->rparenLoc = SourceLocation(node->rparen_loc()); return ast; } @@ -3888,6 +4353,9 @@ auto ASTDecoder::decodeScopedAttributeToken( if (!node) return nullptr; auto ast = new (pool_) ScopedAttributeTokenAST(); + ast->attributeNamespaceLoc = SourceLocation(node->attribute_namespace_loc()); + ast->scopeLoc = SourceLocation(node->scope_loc()); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->attribute_namespace()) { ast->attributeNamespace = unit_->control()->getIdentifier(node->attribute_namespace()->str()); @@ -3904,6 +4372,7 @@ auto ASTDecoder::decodeSimpleAttributeToken( if (!node) return nullptr; auto ast = new (pool_) SimpleAttributeTokenAST(); + ast->identifierLoc = SourceLocation(node->identifier_loc()); if (node->identifier()) { ast->identifier = unit_->control()->getIdentifier(node->identifier()->str()); diff --git a/src/parser/cxx/flatbuffers/ast_encoder.cc b/src/parser/cxx/flatbuffers/ast_encoder.cc index ae31aeab..59adac11 100644 --- a/src/parser/cxx/flatbuffers/ast_encoder.cc +++ b/src/parser/cxx/flatbuffers/ast_encoder.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -40,8 +41,6 @@ auto ASTEncoder::operator()(TranslationUnit* unit) Table stringLiterals; Table integerLiterals; Table floatLiterals; - SourceFiles sourceFiles; - SourceLines sourceLines; std::swap(unit_, unit); std::swap(identifiers_, identifiers); @@ -49,8 +48,25 @@ auto ASTEncoder::operator()(TranslationUnit* unit) std::swap(stringLiterals_, stringLiterals); std::swap(integerLiterals_, integerLiterals); std::swap(floatLiterals_, floatLiterals); - std::swap(sourceFiles_, sourceFiles); - std::swap(sourceLines_, sourceLines); + + std::vector> sources; + for (const auto& source : unit_->preprocessor()->sources()) { + auto file_name = fbb_.CreateString(source.fileName); + std::vector lineOffsets(source.lineOffsets.begin(), + source.lineOffsets.end()); + auto line_offsets = fbb_.CreateVector(lineOffsets); + sources.push_back(io::CreateSource(fbb_, file_name, line_offsets)); + } + + auto source_list = fbb_.CreateVector(sources); + + std::vector tokens; + for (std::uint32_t i = 0; i < unit_->tokenCount(); ++i) { + const auto& token = unit_->tokenAt(SourceLocation(i)); + tokens.push_back(token.raw()); + } + + auto token_list = fbb_.CreateVector(tokens); auto [unitOffset, unitType] = acceptUnit(unit_->ast()); @@ -60,6 +76,8 @@ auto ASTEncoder::operator()(TranslationUnit* unit) builder.add_unit(unitOffset); builder.add_unit_type(static_cast(unitType)); builder.add_file_name(file_name); + builder.add_source_list(source_list); + builder.add_token_list(token_list); std::swap(unit_, unit); std::swap(identifiers_, identifiers); @@ -67,8 +85,6 @@ auto ASTEncoder::operator()(TranslationUnit* unit) std::swap(stringLiterals_, stringLiterals); std::swap(integerLiterals_, integerLiterals); std::swap(floatLiterals_, floatLiterals); - std::swap(sourceFiles_, sourceFiles); - std::swap(sourceLines_, sourceLines); fbb_.Finish(builder.Finish(), io::SerializedUnitIdentifier()); @@ -84,46 +100,6 @@ auto ASTEncoder::accept(AST* ast) -> flatbuffers::Offset<> { return offset; } -auto ASTEncoder::encodeSourceLocation(const SourceLocation& loc) - -> flatbuffers::Offset<> { - if (!loc) { - return {}; - } - - const auto start = unit_->tokenStartPosition(loc); - - flatbuffers::Offset sourceLineOffset; - - auto key = std::tuple(start.fileName, start.line); - - if (sourceLines_.contains(key)) { - sourceLineOffset = sourceLines_.at(key).o; - } else { - flatbuffers::Offset fileNameOffset; - - if (sourceFiles_.contains(start.fileName)) { - fileNameOffset = sourceFiles_.at(start.fileName); - } else { - fileNameOffset = fbb_.CreateString(start.fileName); - sourceFiles_.emplace(start.fileName, fileNameOffset.o); - } - - io::SourceLineBuilder sourceLineBuilder{fbb_}; - sourceLineBuilder.add_file_name(fileNameOffset); - sourceLineBuilder.add_line(start.line); - sourceLineOffset = sourceLineBuilder.Finish(); - sourceLines_.emplace(std::move(key), sourceLineOffset.o); - } - - io::SourceLocationBuilder sourceLocationBuilder{fbb_}; - sourceLocationBuilder.add_source_line(sourceLineOffset); - sourceLocationBuilder.add_column(start.column); - - auto offset = sourceLocationBuilder.Finish(); - - return offset.Union(); -} - auto ASTEncoder::acceptUnit(UnitAST* ast) -> std::tuple, std::uint32_t> { if (!ast) return {}; @@ -491,8 +467,6 @@ void ASTEncoder::visit(SimpleDeclarationAST* ast) { const auto requiresClause = accept(ast->requiresClause); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::SimpleDeclaration::Builder builder{fbb_}; builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); @@ -500,7 +474,7 @@ void ASTEncoder::visit(SimpleDeclarationAST* ast) { builder.add_decl_specifier_list_type(declSpecifierListTypesVector); builder.add_init_declarator_list(initDeclaratorListOffsetsVector); builder.add_requires_clause(requiresClause.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_SimpleDeclaration; @@ -530,12 +504,6 @@ void ASTEncoder::visit(AsmDeclarationAST* ast) { auto asmQualifierListOffsetsVector = fbb_.CreateVector(asmQualifierListOffsets); - auto asmLoc = encodeSourceLocation(ast->asmLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto literalLoc = encodeSourceLocation(ast->literalLoc); - std::vector> outputOperandListOffsets; for (auto node : ListView{ast->outputOperandList}) { if (!node) continue; @@ -570,42 +538,30 @@ void ASTEncoder::visit(AsmDeclarationAST* ast) { auto gotoLabelListOffsetsVector = fbb_.CreateVector(gotoLabelListOffsets); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::AsmDeclaration::Builder builder{fbb_}; builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_asm_qualifier_list(asmQualifierListOffsetsVector); - builder.add_asm_loc(asmLoc.o); - builder.add_lparen_loc(lparenLoc.o); - builder.add_literal_loc(literalLoc.o); + builder.add_asm_loc(ast->asmLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_literal_loc(ast->literalLoc.index()); builder.add_output_operand_list(outputOperandListOffsetsVector); builder.add_input_operand_list(inputOperandListOffsetsVector); builder.add_clobber_list(clobberListOffsetsVector); builder.add_goto_label_list(gotoLabelListOffsetsVector); - builder.add_rparen_loc(rparenLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_AsmDeclaration; } void ASTEncoder::visit(NamespaceAliasDefinitionAST* ast) { - auto namespaceLoc = encodeSourceLocation(ast->namespaceLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); const auto unqualifiedId = accept(ast->unqualifiedId); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -617,14 +573,14 @@ void ASTEncoder::visit(NamespaceAliasDefinitionAST* ast) { } io::NamespaceAliasDefinition::Builder builder{fbb_}; - builder.add_namespace_loc(namespaceLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_equal_loc(equalLoc.o); + builder.add_namespace_loc(ast->namespaceLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); builder.add_unqualified_id(unqualifiedId.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -634,8 +590,6 @@ void ASTEncoder::visit(NamespaceAliasDefinitionAST* ast) { } void ASTEncoder::visit(UsingDeclarationAST* ast) { - auto usingLoc = encodeSourceLocation(ast->usingLoc); - std::vector> usingDeclaratorListOffsets; for (auto node : ListView{ast->usingDeclaratorList}) { @@ -646,28 +600,22 @@ void ASTEncoder::visit(UsingDeclarationAST* ast) { auto usingDeclaratorListOffsetsVector = fbb_.CreateVector(usingDeclaratorListOffsets); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::UsingDeclaration::Builder builder{fbb_}; - builder.add_using_loc(usingLoc.o); + builder.add_using_loc(ast->usingLoc.index()); builder.add_using_declarator_list(usingDeclaratorListOffsetsVector); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_UsingDeclaration; } void ASTEncoder::visit(UsingEnumDeclarationAST* ast) { - auto usingLoc = encodeSourceLocation(ast->usingLoc); - const auto enumTypeSpecifier = accept(ast->enumTypeSpecifier); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::UsingEnumDeclaration::Builder builder{fbb_}; - builder.add_using_loc(usingLoc.o); + builder.add_using_loc(ast->usingLoc.index()); builder.add_enum_type_specifier(enumTypeSpecifier.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_UsingEnumDeclaration; @@ -688,66 +636,44 @@ void ASTEncoder::visit(UsingDirectiveAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); - auto usingLoc = encodeSourceLocation(ast->usingLoc); - - auto namespaceLoc = encodeSourceLocation(ast->namespaceLoc); - const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); const auto unqualifiedId = accept(ast->unqualifiedId); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::UsingDirective::Builder builder{fbb_}; builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); - builder.add_using_loc(usingLoc.o); - builder.add_namespace_loc(namespaceLoc.o); + builder.add_using_loc(ast->usingLoc.index()); + builder.add_namespace_loc(ast->namespaceLoc.index()); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); builder.add_unqualified_id(unqualifiedId.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_UsingDirective; } void ASTEncoder::visit(StaticAssertDeclarationAST* ast) { - auto staticAssertLoc = encodeSourceLocation(ast->staticAssertLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto commaLoc = encodeSourceLocation(ast->commaLoc); - - auto literalLoc = encodeSourceLocation(ast->literalLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::StaticAssertDeclaration::Builder builder{fbb_}; - builder.add_static_assert_loc(staticAssertLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_static_assert_loc(ast->staticAssertLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_comma_loc(commaLoc.o); - builder.add_literal_loc(literalLoc.o); - builder.add_rparen_loc(rparenLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_comma_loc(ast->commaLoc.index()); + builder.add_literal_loc(ast->literalLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_StaticAssertDeclaration; } void ASTEncoder::visit(AliasDeclarationAST* ast) { - auto usingLoc = encodeSourceLocation(ast->usingLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -762,8 +688,6 @@ void ASTEncoder::visit(AliasDeclarationAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); - auto equalLoc = encodeSourceLocation(ast->equalLoc); - std::vector> gnuAttributeListOffsets; std::vector> gnuAttributeListTypes; @@ -781,8 +705,6 @@ void ASTEncoder::visit(AliasDeclarationAST* ast) { const auto typeId = accept(ast->typeId); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -794,15 +716,15 @@ void ASTEncoder::visit(AliasDeclarationAST* ast) { } io::AliasDeclaration::Builder builder{fbb_}; - builder.add_using_loc(usingLoc.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_using_loc(ast->usingLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); - builder.add_equal_loc(equalLoc.o); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_gnu_attribute_list(gnuAttributeListOffsetsVector); builder.add_gnu_attribute_list_type(gnuAttributeListTypesVector); builder.add_type_id(typeId.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -812,10 +734,6 @@ void ASTEncoder::visit(AliasDeclarationAST* ast) { } void ASTEncoder::visit(OpaqueEnumDeclarationAST* ast) { - auto enumLoc = encodeSourceLocation(ast->enumLoc); - - auto classLoc = encodeSourceLocation(ast->classLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -835,8 +753,6 @@ void ASTEncoder::visit(OpaqueEnumDeclarationAST* ast) { const auto unqualifiedId = accept(ast->unqualifiedId); - auto colonLoc = encodeSourceLocation(ast->colonLoc); - std::vector> typeSpecifierListOffsets; std::vector> typeSpecifierListTypes; @@ -851,21 +767,19 @@ void ASTEncoder::visit(OpaqueEnumDeclarationAST* ast) { fbb_.CreateVector(typeSpecifierListOffsets); auto typeSpecifierListTypesVector = fbb_.CreateVector(typeSpecifierListTypes); - auto emicolonLoc = encodeSourceLocation(ast->emicolonLoc); - io::OpaqueEnumDeclaration::Builder builder{fbb_}; - builder.add_enum_loc(enumLoc.o); - builder.add_class_loc(classLoc.o); + builder.add_enum_loc(ast->enumLoc.index()); + builder.add_class_loc(ast->classLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); builder.add_unqualified_id(unqualifiedId.o); - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_type_specifier_list(typeSpecifierListOffsetsVector); builder.add_type_specifier_list_type(typeSpecifierListTypesVector); - builder.add_emicolon_loc(emicolonLoc.o); + builder.add_emicolon_loc(ast->emicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_OpaqueEnumDeclaration; @@ -923,10 +837,6 @@ void ASTEncoder::visit(FunctionDefinitionAST* ast) { } void ASTEncoder::visit(TemplateDeclarationAST* ast) { - auto templateLoc = encodeSourceLocation(ast->templateLoc); - - auto lessLoc = encodeSourceLocation(ast->lessLoc); - std::vector> templateParameterListOffsets; std::vector> templateParameterListTypes; @@ -943,19 +853,17 @@ void ASTEncoder::visit(TemplateDeclarationAST* ast) { auto templateParameterListTypesVector = fbb_.CreateVector(templateParameterListTypes); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - const auto requiresClause = accept(ast->requiresClause); const auto [declaration, declarationType] = acceptDeclaration(ast->declaration); io::TemplateDeclaration::Builder builder{fbb_}; - builder.add_template_loc(templateLoc.o); - builder.add_less_loc(lessLoc.o); + builder.add_template_loc(ast->templateLoc.index()); + builder.add_less_loc(ast->lessLoc.index()); builder.add_template_parameter_list(templateParameterListOffsetsVector); builder.add_template_parameter_list_type(templateParameterListTypesVector); - builder.add_greater_loc(greaterLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); builder.add_requires_clause(requiresClause.o); builder.add_declaration(declaration); builder.add_declaration_type(static_cast(declarationType)); @@ -965,16 +873,8 @@ void ASTEncoder::visit(TemplateDeclarationAST* ast) { } void ASTEncoder::visit(ConceptDefinitionAST* ast) { - auto conceptLoc = encodeSourceLocation(ast->conceptLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -986,12 +886,12 @@ void ASTEncoder::visit(ConceptDefinitionAST* ast) { } io::ConceptDefinition::Builder builder{fbb_}; - builder.add_concept_loc(conceptLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_equal_loc(equalLoc.o); + builder.add_concept_loc(ast->conceptLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -1004,21 +904,11 @@ void ASTEncoder::visit(DeductionGuideAST* ast) { const auto [explicitSpecifier, explicitSpecifierType] = acceptSpecifier(ast->explicitSpecifier); - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto parameterDeclarationClause = accept(ast->parameterDeclarationClause); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - - auto arrowLoc = encodeSourceLocation(ast->arrowLoc); - const auto templateId = accept(ast->templateId); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -1033,13 +923,13 @@ void ASTEncoder::visit(DeductionGuideAST* ast) { builder.add_explicit_specifier(explicitSpecifier); builder.add_explicit_specifier_type( static_cast(explicitSpecifierType)); - builder.add_identifier_loc(identifierLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_parameter_declaration_clause(parameterDeclarationClause.o); - builder.add_rparen_loc(rparenLoc.o); - builder.add_arrow_loc(arrowLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); + builder.add_arrow_loc(ast->arrowLoc.index()); builder.add_template_id(templateId.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -1049,16 +939,12 @@ void ASTEncoder::visit(DeductionGuideAST* ast) { } void ASTEncoder::visit(ExplicitInstantiationAST* ast) { - auto externLoc = encodeSourceLocation(ast->externLoc); - - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto [declaration, declarationType] = acceptDeclaration(ast->declaration); io::ExplicitInstantiation::Builder builder{fbb_}; - builder.add_extern_loc(externLoc.o); - builder.add_template_loc(templateLoc.o); + builder.add_extern_loc(ast->externLoc.index()); + builder.add_template_loc(ast->templateLoc.index()); builder.add_declaration(declaration); builder.add_declaration_type(static_cast(declarationType)); @@ -1067,13 +953,11 @@ void ASTEncoder::visit(ExplicitInstantiationAST* ast) { } void ASTEncoder::visit(ExportDeclarationAST* ast) { - auto exportLoc = encodeSourceLocation(ast->exportLoc); - const auto [declaration, declarationType] = acceptDeclaration(ast->declaration); io::ExportDeclaration::Builder builder{fbb_}; - builder.add_export_loc(exportLoc.o); + builder.add_export_loc(ast->exportLoc.index()); builder.add_declaration(declaration); builder.add_declaration_type(static_cast(declarationType)); @@ -1082,10 +966,6 @@ void ASTEncoder::visit(ExportDeclarationAST* ast) { } void ASTEncoder::visit(ExportCompoundDeclarationAST* ast) { - auto exportLoc = encodeSourceLocation(ast->exportLoc); - - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - std::vector> declarationListOffsets; std::vector> declarationListTypes; @@ -1099,26 +979,18 @@ void ASTEncoder::visit(ExportCompoundDeclarationAST* ast) { auto declarationListOffsetsVector = fbb_.CreateVector(declarationListOffsets); auto declarationListTypesVector = fbb_.CreateVector(declarationListTypes); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - io::ExportCompoundDeclaration::Builder builder{fbb_}; - builder.add_export_loc(exportLoc.o); - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_export_loc(ast->exportLoc.index()); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_declaration_list(declarationListOffsetsVector); builder.add_declaration_list_type(declarationListTypesVector); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_ExportCompoundDeclaration; } void ASTEncoder::visit(LinkageSpecificationAST* ast) { - auto externLoc = encodeSourceLocation(ast->externLoc); - - auto stringliteralLoc = encodeSourceLocation(ast->stringliteralLoc); - - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - std::vector> declarationListOffsets; std::vector> declarationListTypes; @@ -1132,8 +1004,6 @@ void ASTEncoder::visit(LinkageSpecificationAST* ast) { auto declarationListOffsetsVector = fbb_.CreateVector(declarationListOffsets); auto declarationListTypesVector = fbb_.CreateVector(declarationListTypes); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - flatbuffers::Offset stringLiteral; if (ast->stringLiteral) { if (stringLiterals_.contains(ast->stringLiteral)) { @@ -1145,12 +1015,12 @@ void ASTEncoder::visit(LinkageSpecificationAST* ast) { } io::LinkageSpecification::Builder builder{fbb_}; - builder.add_extern_loc(externLoc.o); - builder.add_stringliteral_loc(stringliteralLoc.o); - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_extern_loc(ast->externLoc.index()); + builder.add_stringliteral_loc(ast->stringliteralLoc.index()); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_declaration_list(declarationListOffsetsVector); builder.add_declaration_list_type(declarationListTypesVector); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); if (ast->stringLiteral) { builder.add_string_literal(stringLiteral); } @@ -1160,10 +1030,6 @@ void ASTEncoder::visit(LinkageSpecificationAST* ast) { } void ASTEncoder::visit(NamespaceDefinitionAST* ast) { - auto inlineLoc = encodeSourceLocation(ast->inlineLoc); - - auto namespaceLoc = encodeSourceLocation(ast->namespaceLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -1188,8 +1054,6 @@ void ASTEncoder::visit(NamespaceDefinitionAST* ast) { auto nestedNamespaceSpecifierListOffsetsVector = fbb_.CreateVector(nestedNamespaceSpecifierListOffsets); - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - std::vector> extraAttributeListOffsets; std::vector> extraAttributeListTypes; @@ -1206,8 +1070,6 @@ void ASTEncoder::visit(NamespaceDefinitionAST* ast) { auto extraAttributeListTypesVector = fbb_.CreateVector(extraAttributeListTypes); - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - std::vector> declarationListOffsets; std::vector> declarationListTypes; @@ -1221,8 +1083,6 @@ void ASTEncoder::visit(NamespaceDefinitionAST* ast) { auto declarationListOffsetsVector = fbb_.CreateVector(declarationListOffsets); auto declarationListTypesVector = fbb_.CreateVector(declarationListTypes); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -1234,19 +1094,19 @@ void ASTEncoder::visit(NamespaceDefinitionAST* ast) { } io::NamespaceDefinition::Builder builder{fbb_}; - builder.add_inline_loc(inlineLoc.o); - builder.add_namespace_loc(namespaceLoc.o); + builder.add_inline_loc(ast->inlineLoc.index()); + builder.add_namespace_loc(ast->namespaceLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_nested_namespace_specifier_list( nestedNamespaceSpecifierListOffsetsVector); - builder.add_identifier_loc(identifierLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); builder.add_extra_attribute_list(extraAttributeListOffsetsVector); builder.add_extra_attribute_list_type(extraAttributeListTypesVector); - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_declaration_list(declarationListOffsetsVector); builder.add_declaration_list_type(declarationListTypesVector); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -1256,10 +1116,8 @@ void ASTEncoder::visit(NamespaceDefinitionAST* ast) { } void ASTEncoder::visit(EmptyDeclarationAST* ast) { - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::EmptyDeclaration::Builder builder{fbb_}; - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_EmptyDeclaration; @@ -1280,20 +1138,16 @@ void ASTEncoder::visit(AttributeDeclarationAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::AttributeDeclaration::Builder builder{fbb_}; builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_AttributeDeclaration; } void ASTEncoder::visit(ModuleImportDeclarationAST* ast) { - auto importLoc = encodeSourceLocation(ast->importLoc); - const auto importName = accept(ast->importName); std::vector> attributeListOffsets; @@ -1310,14 +1164,12 @@ void ASTEncoder::visit(ModuleImportDeclarationAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::ModuleImportDeclaration::Builder builder{fbb_}; - builder.add_import_loc(importLoc.o); + builder.add_import_loc(ast->importLoc.index()); builder.add_import_name(importName.o); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_ModuleImportDeclaration; @@ -1338,8 +1190,6 @@ void ASTEncoder::visit(ParameterDeclarationAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); - auto thisLoc = encodeSourceLocation(ast->thisLoc); - std::vector> typeSpecifierListOffsets; std::vector> typeSpecifierListTypes; @@ -1356,8 +1206,6 @@ void ASTEncoder::visit(ParameterDeclarationAST* ast) { const auto declarator = accept(ast->declarator); - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); flatbuffers::Offset identifier; @@ -1373,11 +1221,11 @@ void ASTEncoder::visit(ParameterDeclarationAST* ast) { io::ParameterDeclaration::Builder builder{fbb_}; builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); - builder.add_this_loc(thisLoc.o); + builder.add_this_loc(ast->thisLoc.index()); builder.add_type_specifier_list(typeSpecifierListOffsetsVector); builder.add_type_specifier_list_type(typeSpecifierListTypesVector); builder.add_declarator(declarator.o); - builder.add_equal_loc(equalLoc.o); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); if (ast->identifier) { @@ -1389,13 +1237,9 @@ void ASTEncoder::visit(ParameterDeclarationAST* ast) { } void ASTEncoder::visit(AccessDeclarationAST* ast) { - auto accessLoc = encodeSourceLocation(ast->accessLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - io::AccessDeclaration::Builder builder{fbb_}; - builder.add_access_loc(accessLoc.o); - builder.add_colon_loc(colonLoc.o); + builder.add_access_loc(ast->accessLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_access_specifier( static_cast(ast->accessSpecifier)); @@ -1439,10 +1283,6 @@ void ASTEncoder::visit(StructuredBindingDeclarationAST* ast) { fbb_.CreateVector(declSpecifierListOffsets); auto declSpecifierListTypesVector = fbb_.CreateVector(declSpecifierListTypes); - auto refQualifierLoc = encodeSourceLocation(ast->refQualifierLoc); - - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - std::vector> bindingListOffsets; for (auto node : ListView{ast->bindingList}) { if (!node) continue; @@ -1451,45 +1291,29 @@ void ASTEncoder::visit(StructuredBindingDeclarationAST* ast) { auto bindingListOffsetsVector = fbb_.CreateVector(bindingListOffsets); - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - const auto [initializer, initializerType] = acceptExpression(ast->initializer); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::StructuredBindingDeclaration::Builder builder{fbb_}; builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_decl_specifier_list(declSpecifierListOffsetsVector); builder.add_decl_specifier_list_type(declSpecifierListTypesVector); - builder.add_ref_qualifier_loc(refQualifierLoc.o); - builder.add_lbracket_loc(lbracketLoc.o); + builder.add_ref_qualifier_loc(ast->refQualifierLoc.index()); + builder.add_lbracket_loc(ast->lbracketLoc.index()); builder.add_binding_list(bindingListOffsetsVector); - builder.add_rbracket_loc(rbracketLoc.o); + builder.add_rbracket_loc(ast->rbracketLoc.index()); builder.add_initializer(initializer); builder.add_initializer_type(static_cast(initializerType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Declaration_StructuredBindingDeclaration; } void ASTEncoder::visit(AsmOperandAST* ast) { - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - - auto symbolicNameLoc = encodeSourceLocation(ast->symbolicNameLoc); - - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - - auto constraintLiteralLoc = encodeSourceLocation(ast->constraintLiteralLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - flatbuffers::Offset symbolicName; if (ast->symbolicName) { if (identifiers_.contains(ast->symbolicName)) { @@ -1501,14 +1325,14 @@ void ASTEncoder::visit(AsmOperandAST* ast) { } io::AsmOperand::Builder builder{fbb_}; - builder.add_lbracket_loc(lbracketLoc.o); - builder.add_symbolic_name_loc(symbolicNameLoc.o); - builder.add_rbracket_loc(rbracketLoc.o); - builder.add_constraint_literal_loc(constraintLiteralLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_lbracket_loc(ast->lbracketLoc.index()); + builder.add_symbolic_name_loc(ast->symbolicNameLoc.index()); + builder.add_rbracket_loc(ast->rbracketLoc.index()); + builder.add_constraint_literal_loc(ast->constraintLiteralLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); if (ast->symbolicName) { builder.add_symbolic_name(symbolicName); } @@ -1518,10 +1342,8 @@ void ASTEncoder::visit(AsmOperandAST* ast) { } void ASTEncoder::visit(AsmQualifierAST* ast) { - auto qualifierLoc = encodeSourceLocation(ast->qualifierLoc); - io::AsmQualifier::Builder builder{fbb_}; - builder.add_qualifier_loc(qualifierLoc.o); + builder.add_qualifier_loc(ast->qualifierLoc.index()); builder.add_qualifier(static_cast(ast->qualifier)); offset_ = builder.Finish().Union(); @@ -1529,8 +1351,6 @@ void ASTEncoder::visit(AsmQualifierAST* ast) { } void ASTEncoder::visit(AsmClobberAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - flatbuffers::Offset literal; if (ast->literal) { if (stringLiterals_.contains(ast->literal)) { @@ -1542,7 +1362,7 @@ void ASTEncoder::visit(AsmClobberAST* ast) { } io::AsmClobber::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); if (ast->literal) { builder.add_literal(literal); } @@ -1552,8 +1372,6 @@ void ASTEncoder::visit(AsmClobberAST* ast) { } void ASTEncoder::visit(AsmGotoLabelAST* ast) { - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -1565,7 +1383,7 @@ void ASTEncoder::visit(AsmGotoLabelAST* ast) { } io::AsmGotoLabel::Builder builder{fbb_}; - builder.add_identifier_loc(identifierLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -1575,10 +1393,6 @@ void ASTEncoder::visit(AsmGotoLabelAST* ast) { } void ASTEncoder::visit(LabeledStatementAST* ast) { - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -1590,8 +1404,8 @@ void ASTEncoder::visit(LabeledStatementAST* ast) { } io::LabeledStatement::Builder builder{fbb_}; - builder.add_identifier_loc(identifierLoc.o); - builder.add_colon_loc(colonLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -1601,30 +1415,22 @@ void ASTEncoder::visit(LabeledStatementAST* ast) { } void ASTEncoder::visit(CaseStatementAST* ast) { - auto caseLoc = encodeSourceLocation(ast->caseLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto colonLoc = encodeSourceLocation(ast->colonLoc); - io::CaseStatement::Builder builder{fbb_}; - builder.add_case_loc(caseLoc.o); + builder.add_case_loc(ast->caseLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_CaseStatement; } void ASTEncoder::visit(DefaultStatementAST* ast) { - auto defaultLoc = encodeSourceLocation(ast->defaultLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - io::DefaultStatement::Builder builder{fbb_}; - builder.add_default_loc(defaultLoc.o); - builder.add_colon_loc(colonLoc.o); + builder.add_default_loc(ast->defaultLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_DefaultStatement; @@ -1633,20 +1439,16 @@ void ASTEncoder::visit(DefaultStatementAST* ast) { void ASTEncoder::visit(ExpressionStatementAST* ast) { const auto [expression, expressionType] = acceptExpression(ast->expression); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::ExpressionStatement::Builder builder{fbb_}; builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_ExpressionStatement; } void ASTEncoder::visit(CompoundStatementAST* ast) { - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - std::vector> statementListOffsets; std::vector> statementListTypes; @@ -1660,50 +1462,38 @@ void ASTEncoder::visit(CompoundStatementAST* ast) { auto statementListOffsetsVector = fbb_.CreateVector(statementListOffsets); auto statementListTypesVector = fbb_.CreateVector(statementListTypes); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - io::CompoundStatement::Builder builder{fbb_}; - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_statement_list(statementListOffsetsVector); builder.add_statement_list_type(statementListTypesVector); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_CompoundStatement; } void ASTEncoder::visit(IfStatementAST* ast) { - auto ifLoc = encodeSourceLocation(ast->ifLoc); - - auto constexprLoc = encodeSourceLocation(ast->constexprLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [initializer, initializerType] = acceptStatement(ast->initializer); const auto [condition, conditionType] = acceptExpression(ast->condition); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto [statement, statementType] = acceptStatement(ast->statement); - auto elseLoc = encodeSourceLocation(ast->elseLoc); - const auto [elseStatement, elseStatementType] = acceptStatement(ast->elseStatement); io::IfStatement::Builder builder{fbb_}; - builder.add_if_loc(ifLoc.o); - builder.add_constexpr_loc(constexprLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_if_loc(ast->ifLoc.index()); + builder.add_constexpr_loc(ast->constexprLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_initializer(initializer); builder.add_initializer_type(static_cast(initializerType)); builder.add_condition(condition); builder.add_condition_type(static_cast(conditionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_statement(statement); builder.add_statement_type(static_cast(statementType)); - builder.add_else_loc(elseLoc.o); + builder.add_else_loc(ast->elseLoc.index()); builder.add_else_statement(elseStatement); builder.add_else_statement_type( static_cast(elseStatementType)); @@ -1713,26 +1503,18 @@ void ASTEncoder::visit(IfStatementAST* ast) { } void ASTEncoder::visit(ConstevalIfStatementAST* ast) { - auto ifLoc = encodeSourceLocation(ast->ifLoc); - - auto exclaimLoc = encodeSourceLocation(ast->exclaimLoc); - - auto constvalLoc = encodeSourceLocation(ast->constvalLoc); - const auto [statement, statementType] = acceptStatement(ast->statement); - auto elseLoc = encodeSourceLocation(ast->elseLoc); - const auto [elseStatement, elseStatementType] = acceptStatement(ast->elseStatement); io::ConstevalIfStatement::Builder builder{fbb_}; - builder.add_if_loc(ifLoc.o); - builder.add_exclaim_loc(exclaimLoc.o); - builder.add_constval_loc(constvalLoc.o); + builder.add_if_loc(ast->ifLoc.index()); + builder.add_exclaim_loc(ast->exclaimLoc.index()); + builder.add_constval_loc(ast->constvalLoc.index()); builder.add_statement(statement); builder.add_statement_type(static_cast(statementType)); - builder.add_else_loc(elseLoc.o); + builder.add_else_loc(ast->elseLoc.index()); builder.add_else_statement(elseStatement); builder.add_else_statement_type( static_cast(elseStatementType)); @@ -1742,26 +1524,20 @@ void ASTEncoder::visit(ConstevalIfStatementAST* ast) { } void ASTEncoder::visit(SwitchStatementAST* ast) { - auto switchLoc = encodeSourceLocation(ast->switchLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [initializer, initializerType] = acceptStatement(ast->initializer); const auto [condition, conditionType] = acceptExpression(ast->condition); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto [statement, statementType] = acceptStatement(ast->statement); io::SwitchStatement::Builder builder{fbb_}; - builder.add_switch_loc(switchLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_switch_loc(ast->switchLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_initializer(initializer); builder.add_initializer_type(static_cast(initializerType)); builder.add_condition(condition); builder.add_condition_type(static_cast(conditionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_statement(statement); builder.add_statement_type(static_cast(statementType)); @@ -1770,22 +1546,16 @@ void ASTEncoder::visit(SwitchStatementAST* ast) { } void ASTEncoder::visit(WhileStatementAST* ast) { - auto whileLoc = encodeSourceLocation(ast->whileLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [condition, conditionType] = acceptExpression(ast->condition); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto [statement, statementType] = acceptStatement(ast->statement); io::WhileStatement::Builder builder{fbb_}; - builder.add_while_loc(whileLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_while_loc(ast->whileLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_condition(condition); builder.add_condition_type(static_cast(conditionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_statement(statement); builder.add_statement_type(static_cast(statementType)); @@ -1794,67 +1564,49 @@ void ASTEncoder::visit(WhileStatementAST* ast) { } void ASTEncoder::visit(DoStatementAST* ast) { - auto doLoc = encodeSourceLocation(ast->doLoc); - const auto [statement, statementType] = acceptStatement(ast->statement); - auto whileLoc = encodeSourceLocation(ast->whileLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::DoStatement::Builder builder{fbb_}; - builder.add_do_loc(doLoc.o); + builder.add_do_loc(ast->doLoc.index()); builder.add_statement(statement); builder.add_statement_type(static_cast(statementType)); - builder.add_while_loc(whileLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_while_loc(ast->whileLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_DoStatement; } void ASTEncoder::visit(ForRangeStatementAST* ast) { - auto forLoc = encodeSourceLocation(ast->forLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [initializer, initializerType] = acceptStatement(ast->initializer); const auto [rangeDeclaration, rangeDeclarationType] = acceptDeclaration(ast->rangeDeclaration); - auto colonLoc = encodeSourceLocation(ast->colonLoc); - const auto [rangeInitializer, rangeInitializerType] = acceptExpression(ast->rangeInitializer); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto [statement, statementType] = acceptStatement(ast->statement); io::ForRangeStatement::Builder builder{fbb_}; - builder.add_for_loc(forLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_for_loc(ast->forLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_initializer(initializer); builder.add_initializer_type(static_cast(initializerType)); builder.add_range_declaration(rangeDeclaration); builder.add_range_declaration_type( static_cast(rangeDeclarationType)); - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_range_initializer(rangeInitializer); builder.add_range_initializer_type( static_cast(rangeInitializerType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_statement(statement); builder.add_statement_type(static_cast(statementType)); @@ -1863,33 +1615,25 @@ void ASTEncoder::visit(ForRangeStatementAST* ast) { } void ASTEncoder::visit(ForStatementAST* ast) { - auto forLoc = encodeSourceLocation(ast->forLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [initializer, initializerType] = acceptStatement(ast->initializer); const auto [condition, conditionType] = acceptExpression(ast->condition); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto [statement, statementType] = acceptStatement(ast->statement); io::ForStatement::Builder builder{fbb_}; - builder.add_for_loc(forLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_for_loc(ast->forLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_initializer(initializer); builder.add_initializer_type(static_cast(initializerType)); builder.add_condition(condition); builder.add_condition_type(static_cast(conditionType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_statement(statement); builder.add_statement_type(static_cast(statementType)); @@ -1898,72 +1642,50 @@ void ASTEncoder::visit(ForStatementAST* ast) { } void ASTEncoder::visit(BreakStatementAST* ast) { - auto breakLoc = encodeSourceLocation(ast->breakLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::BreakStatement::Builder builder{fbb_}; - builder.add_break_loc(breakLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_break_loc(ast->breakLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_BreakStatement; } void ASTEncoder::visit(ContinueStatementAST* ast) { - auto continueLoc = encodeSourceLocation(ast->continueLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::ContinueStatement::Builder builder{fbb_}; - builder.add_continue_loc(continueLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_continue_loc(ast->continueLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_ContinueStatement; } void ASTEncoder::visit(ReturnStatementAST* ast) { - auto returnLoc = encodeSourceLocation(ast->returnLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::ReturnStatement::Builder builder{fbb_}; - builder.add_return_loc(returnLoc.o); + builder.add_return_loc(ast->returnLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_ReturnStatement; } void ASTEncoder::visit(CoroutineReturnStatementAST* ast) { - auto coreturnLoc = encodeSourceLocation(ast->coreturnLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::CoroutineReturnStatement::Builder builder{fbb_}; - builder.add_coreturn_loc(coreturnLoc.o); + builder.add_coreturn_loc(ast->coreturnLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Statement_CoroutineReturnStatement; } void ASTEncoder::visit(GotoStatementAST* ast) { - auto gotoLoc = encodeSourceLocation(ast->gotoLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -1975,9 +1697,9 @@ void ASTEncoder::visit(GotoStatementAST* ast) { } io::GotoStatement::Builder builder{fbb_}; - builder.add_goto_loc(gotoLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_goto_loc(ast->gotoLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -1999,8 +1721,6 @@ void ASTEncoder::visit(DeclarationStatementAST* ast) { } void ASTEncoder::visit(TryBlockStatementAST* ast) { - auto tryLoc = encodeSourceLocation(ast->tryLoc); - const auto statement = accept(ast->statement); std::vector> handlerListOffsets; @@ -2012,7 +1732,7 @@ void ASTEncoder::visit(TryBlockStatementAST* ast) { auto handlerListOffsetsVector = fbb_.CreateVector(handlerListOffsets); io::TryBlockStatement::Builder builder{fbb_}; - builder.add_try_loc(tryLoc.o); + builder.add_try_loc(ast->tryLoc.index()); builder.add_statement(statement.o); builder.add_handler_list(handlerListOffsetsVector); @@ -2021,18 +1741,14 @@ void ASTEncoder::visit(TryBlockStatementAST* ast) { } void ASTEncoder::visit(GeneratedLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - io::GeneratedLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_GeneratedLiteralExpression; } void ASTEncoder::visit(CharLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - flatbuffers::Offset literal; if (ast->literal) { if (charLiterals_.contains(ast->literal)) { @@ -2044,7 +1760,7 @@ void ASTEncoder::visit(CharLiteralExpressionAST* ast) { } io::CharLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); if (ast->literal) { builder.add_literal(literal); } @@ -2054,18 +1770,14 @@ void ASTEncoder::visit(CharLiteralExpressionAST* ast) { } void ASTEncoder::visit(BoolLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - io::BoolLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_BoolLiteralExpression; } void ASTEncoder::visit(IntLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - flatbuffers::Offset literal; if (ast->literal) { if (integerLiterals_.contains(ast->literal)) { @@ -2077,7 +1789,7 @@ void ASTEncoder::visit(IntLiteralExpressionAST* ast) { } io::IntLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); if (ast->literal) { builder.add_literal(literal); } @@ -2087,8 +1799,6 @@ void ASTEncoder::visit(IntLiteralExpressionAST* ast) { } void ASTEncoder::visit(FloatLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - flatbuffers::Offset literal; if (ast->literal) { if (floatLiterals_.contains(ast->literal)) { @@ -2100,7 +1810,7 @@ void ASTEncoder::visit(FloatLiteralExpressionAST* ast) { } io::FloatLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); if (ast->literal) { builder.add_literal(literal); } @@ -2110,10 +1820,8 @@ void ASTEncoder::visit(FloatLiteralExpressionAST* ast) { } void ASTEncoder::visit(NullptrLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - io::NullptrLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); builder.add_literal(static_cast(ast->literal)); offset_ = builder.Finish().Union(); @@ -2121,8 +1829,6 @@ void ASTEncoder::visit(NullptrLiteralExpressionAST* ast) { } void ASTEncoder::visit(StringLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - flatbuffers::Offset literal; if (ast->literal) { if (stringLiterals_.contains(ast->literal)) { @@ -2134,7 +1840,7 @@ void ASTEncoder::visit(StringLiteralExpressionAST* ast) { } io::StringLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); if (ast->literal) { builder.add_literal(literal); } @@ -2144,8 +1850,6 @@ void ASTEncoder::visit(StringLiteralExpressionAST* ast) { } void ASTEncoder::visit(UserDefinedStringLiteralExpressionAST* ast) { - auto literalLoc = encodeSourceLocation(ast->literalLoc); - flatbuffers::Offset literal; if (ast->literal) { if (stringLiterals_.contains(ast->literal)) { @@ -2157,7 +1861,7 @@ void ASTEncoder::visit(UserDefinedStringLiteralExpressionAST* ast) { } io::UserDefinedStringLiteralExpression::Builder builder{fbb_}; - builder.add_literal_loc(literalLoc.o); + builder.add_literal_loc(ast->literalLoc.index()); if (ast->literal) { builder.add_literal(literal); } @@ -2167,27 +1871,21 @@ void ASTEncoder::visit(UserDefinedStringLiteralExpressionAST* ast) { } void ASTEncoder::visit(ThisExpressionAST* ast) { - auto thisLoc = encodeSourceLocation(ast->thisLoc); - io::ThisExpression::Builder builder{fbb_}; - builder.add_this_loc(thisLoc.o); + builder.add_this_loc(ast->thisLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_ThisExpression; } void ASTEncoder::visit(NestedExpressionAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::NestedExpression::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_NestedExpression; @@ -2197,8 +1895,6 @@ void ASTEncoder::visit(IdExpressionAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); @@ -2206,7 +1902,7 @@ void ASTEncoder::visit(IdExpressionAST* ast) { builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_template_loc(templateLoc.o); + builder.add_template_loc(ast->templateLoc.index()); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); @@ -2216,10 +1912,6 @@ void ASTEncoder::visit(IdExpressionAST* ast) { } void ASTEncoder::visit(LambdaExpressionAST* ast) { - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - - auto captureDefaultLoc = encodeSourceLocation(ast->captureDefaultLoc); - std::vector> captureListOffsets; std::vector> captureListTypes; @@ -2233,10 +1925,6 @@ void ASTEncoder::visit(LambdaExpressionAST* ast) { auto captureListOffsetsVector = fbb_.CreateVector(captureListOffsets); auto captureListTypesVector = fbb_.CreateVector(captureListTypes); - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - - auto lessLoc = encodeSourceLocation(ast->lessLoc); - std::vector> templateParameterListOffsets; std::vector> templateParameterListTypes; @@ -2253,17 +1941,11 @@ void ASTEncoder::visit(LambdaExpressionAST* ast) { auto templateParameterListTypesVector = fbb_.CreateVector(templateParameterListTypes); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - const auto templateRequiresClause = accept(ast->templateRequiresClause); - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto parameterDeclarationClause = accept(ast->parameterDeclarationClause); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - std::vector> gnuAtributeListOffsets; std::vector> gnuAtributeListTypes; @@ -2312,19 +1994,19 @@ void ASTEncoder::visit(LambdaExpressionAST* ast) { const auto statement = accept(ast->statement); io::LambdaExpression::Builder builder{fbb_}; - builder.add_lbracket_loc(lbracketLoc.o); - builder.add_capture_default_loc(captureDefaultLoc.o); + builder.add_lbracket_loc(ast->lbracketLoc.index()); + builder.add_capture_default_loc(ast->captureDefaultLoc.index()); builder.add_capture_list(captureListOffsetsVector); builder.add_capture_list_type(captureListTypesVector); - builder.add_rbracket_loc(rbracketLoc.o); - builder.add_less_loc(lessLoc.o); + builder.add_rbracket_loc(ast->rbracketLoc.index()); + builder.add_less_loc(ast->lessLoc.index()); builder.add_template_parameter_list(templateParameterListOffsetsVector); builder.add_template_parameter_list_type(templateParameterListTypesVector); - builder.add_greater_loc(greaterLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); builder.add_template_requires_clause(templateRequiresClause.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_parameter_declaration_clause(parameterDeclarationClause.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_gnu_atribute_list(gnuAtributeListOffsetsVector); builder.add_gnu_atribute_list_type(gnuAtributeListTypesVector); builder.add_lambda_specifier_list(lambdaSpecifierListOffsetsVector); @@ -2343,34 +2025,24 @@ void ASTEncoder::visit(LambdaExpressionAST* ast) { } void ASTEncoder::visit(FoldExpressionAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [leftExpression, leftExpressionType] = acceptExpression(ast->leftExpression); - auto opLoc = encodeSourceLocation(ast->opLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto foldOpLoc = encodeSourceLocation(ast->foldOpLoc); - const auto [rightExpression, rightExpressionType] = acceptExpression(ast->rightExpression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::FoldExpression::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_left_expression(leftExpression); builder.add_left_expression_type( static_cast(leftExpressionType)); - builder.add_op_loc(opLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_fold_op_loc(foldOpLoc.o); + builder.add_op_loc(ast->opLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_fold_op_loc(ast->foldOpLoc.index()); builder.add_right_expression(rightExpression); builder.add_right_expression_type( static_cast(rightExpressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_op(static_cast(ast->op)); builder.add_fold_op(static_cast(ast->foldOp)); @@ -2379,23 +2051,15 @@ void ASTEncoder::visit(FoldExpressionAST* ast) { } void ASTEncoder::visit(RightFoldExpressionAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto opLoc = encodeSourceLocation(ast->opLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::RightFoldExpression::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_op_loc(opLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_op_loc(ast->opLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_op(static_cast(ast->op)); offset_ = builder.Finish().Union(); @@ -2403,23 +2067,15 @@ void ASTEncoder::visit(RightFoldExpressionAST* ast) { } void ASTEncoder::visit(LeftFoldExpressionAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto opLoc = encodeSourceLocation(ast->opLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::LeftFoldExpression::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_op_loc(opLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_op_loc(ast->opLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_op(static_cast(ast->op)); offset_ = builder.Finish().Union(); @@ -2427,17 +2083,9 @@ void ASTEncoder::visit(LeftFoldExpressionAST* ast) { } void ASTEncoder::visit(RequiresExpressionAST* ast) { - auto requiresLoc = encodeSourceLocation(ast->requiresLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto parameterDeclarationClause = accept(ast->parameterDeclarationClause); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - std::vector> requirementListOffsets; std::vector> requirementListTypes; @@ -2451,43 +2099,33 @@ void ASTEncoder::visit(RequiresExpressionAST* ast) { auto requirementListOffsetsVector = fbb_.CreateVector(requirementListOffsets); auto requirementListTypesVector = fbb_.CreateVector(requirementListTypes); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - io::RequiresExpression::Builder builder{fbb_}; - builder.add_requires_loc(requiresLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_requires_loc(ast->requiresLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_parameter_declaration_clause(parameterDeclarationClause.o); - builder.add_rparen_loc(rparenLoc.o); - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_requirement_list(requirementListOffsetsVector); builder.add_requirement_list_type(requirementListTypesVector); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_RequiresExpression; } void ASTEncoder::visit(VaArgExpressionAST* ast) { - auto vaArgLoc = encodeSourceLocation(ast->vaArgLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto commaLoc = encodeSourceLocation(ast->commaLoc); - const auto typeId = accept(ast->typeId); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::VaArgExpression::Builder builder{fbb_}; - builder.add_va_arg_loc(vaArgLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_va_arg_loc(ast->vaArgLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_comma_loc(commaLoc.o); + builder.add_comma_loc(ast->commaLoc.index()); builder.add_type_id(typeId.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_VaArgExpression; @@ -2497,22 +2135,18 @@ void ASTEncoder::visit(SubscriptExpressionAST* ast) { const auto [baseExpression, baseExpressionType] = acceptExpression(ast->baseExpression); - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - const auto [indexExpression, indexExpressionType] = acceptExpression(ast->indexExpression); - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - io::SubscriptExpression::Builder builder{fbb_}; builder.add_base_expression(baseExpression); builder.add_base_expression_type( static_cast(baseExpressionType)); - builder.add_lbracket_loc(lbracketLoc.o); + builder.add_lbracket_loc(ast->lbracketLoc.index()); builder.add_index_expression(indexExpression); builder.add_index_expression_type( static_cast(indexExpressionType)); - builder.add_rbracket_loc(rbracketLoc.o); + builder.add_rbracket_loc(ast->rbracketLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_SubscriptExpression; @@ -2522,8 +2156,6 @@ void ASTEncoder::visit(CallExpressionAST* ast) { const auto [baseExpression, baseExpressionType] = acceptExpression(ast->baseExpression); - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> expressionListOffsets; std::vector> expressionListTypes; @@ -2537,16 +2169,14 @@ void ASTEncoder::visit(CallExpressionAST* ast) { auto expressionListOffsetsVector = fbb_.CreateVector(expressionListOffsets); auto expressionListTypesVector = fbb_.CreateVector(expressionListTypes); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::CallExpression::Builder builder{fbb_}; builder.add_base_expression(baseExpression); builder.add_base_expression_type( static_cast(baseExpressionType)); - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression_list(expressionListOffsetsVector); builder.add_expression_list_type(expressionListTypesVector); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_CallExpression; @@ -2556,8 +2186,6 @@ void ASTEncoder::visit(TypeConstructionAST* ast) { const auto [typeSpecifier, typeSpecifierType] = acceptSpecifier(ast->typeSpecifier); - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> expressionListOffsets; std::vector> expressionListTypes; @@ -2571,16 +2199,14 @@ void ASTEncoder::visit(TypeConstructionAST* ast) { auto expressionListOffsetsVector = fbb_.CreateVector(expressionListOffsets); auto expressionListTypesVector = fbb_.CreateVector(expressionListTypes); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::TypeConstruction::Builder builder{fbb_}; builder.add_type_specifier(typeSpecifier); builder.add_type_specifier_type( static_cast(typeSpecifierType)); - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression_list(expressionListOffsetsVector); builder.add_expression_list_type(expressionListTypesVector); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_TypeConstruction; @@ -2606,18 +2232,14 @@ void ASTEncoder::visit(SpliceMemberExpressionAST* ast) { const auto [baseExpression, baseExpressionType] = acceptExpression(ast->baseExpression); - auto accessLoc = encodeSourceLocation(ast->accessLoc); - - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto splicer = accept(ast->splicer); io::SpliceMemberExpression::Builder builder{fbb_}; builder.add_base_expression(baseExpression); builder.add_base_expression_type( static_cast(baseExpressionType)); - builder.add_access_loc(accessLoc.o); - builder.add_template_loc(templateLoc.o); + builder.add_access_loc(ast->accessLoc.index()); + builder.add_template_loc(ast->templateLoc.index()); builder.add_splicer(splicer.o); builder.add_access_op(static_cast(ast->accessOp)); @@ -2629,13 +2251,9 @@ void ASTEncoder::visit(MemberExpressionAST* ast) { const auto [baseExpression, baseExpressionType] = acceptExpression(ast->baseExpression); - auto accessLoc = encodeSourceLocation(ast->accessLoc); - const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); @@ -2643,11 +2261,11 @@ void ASTEncoder::visit(MemberExpressionAST* ast) { builder.add_base_expression(baseExpression); builder.add_base_expression_type( static_cast(baseExpressionType)); - builder.add_access_loc(accessLoc.o); + builder.add_access_loc(ast->accessLoc.index()); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_template_loc(templateLoc.o); + builder.add_template_loc(ast->templateLoc.index()); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); @@ -2661,13 +2279,11 @@ void ASTEncoder::visit(PostIncrExpressionAST* ast) { const auto [baseExpression, baseExpressionType] = acceptExpression(ast->baseExpression); - auto opLoc = encodeSourceLocation(ast->opLoc); - io::PostIncrExpression::Builder builder{fbb_}; builder.add_base_expression(baseExpression); builder.add_base_expression_type( static_cast(baseExpressionType)); - builder.add_op_loc(opLoc.o); + builder.add_op_loc(ast->opLoc.index()); builder.add_op(static_cast(ast->op)); offset_ = builder.Finish().Union(); @@ -2675,94 +2291,64 @@ void ASTEncoder::visit(PostIncrExpressionAST* ast) { } void ASTEncoder::visit(CppCastExpressionAST* ast) { - auto castLoc = encodeSourceLocation(ast->castLoc); - - auto lessLoc = encodeSourceLocation(ast->lessLoc); - const auto typeId = accept(ast->typeId); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::CppCastExpression::Builder builder{fbb_}; - builder.add_cast_loc(castLoc.o); - builder.add_less_loc(lessLoc.o); + builder.add_cast_loc(ast->castLoc.index()); + builder.add_less_loc(ast->lessLoc.index()); builder.add_type_id(typeId.o); - builder.add_greater_loc(greaterLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_CppCastExpression; } void ASTEncoder::visit(BuiltinBitCastExpressionAST* ast) { - auto castLoc = encodeSourceLocation(ast->castLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto commaLoc = encodeSourceLocation(ast->commaLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::BuiltinBitCastExpression::Builder builder{fbb_}; - builder.add_cast_loc(castLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_cast_loc(ast->castLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_comma_loc(commaLoc.o); + builder.add_comma_loc(ast->commaLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_BuiltinBitCastExpression; } void ASTEncoder::visit(TypeidExpressionAST* ast) { - auto typeidLoc = encodeSourceLocation(ast->typeidLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::TypeidExpression::Builder builder{fbb_}; - builder.add_typeid_loc(typeidLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_typeid_loc(ast->typeidLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_TypeidExpression; } void ASTEncoder::visit(TypeidOfTypeExpressionAST* ast) { - auto typeidLoc = encodeSourceLocation(ast->typeidLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::TypeidOfTypeExpression::Builder builder{fbb_}; - builder.add_typeid_loc(typeidLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_typeid_loc(ast->typeidLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_TypeidOfTypeExpression; @@ -2779,23 +2365,15 @@ void ASTEncoder::visit(SpliceExpressionAST* ast) { } void ASTEncoder::visit(GlobalScopeReflectExpressionAST* ast) { - auto caretLoc = encodeSourceLocation(ast->caretLoc); - - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - io::GlobalScopeReflectExpression::Builder builder{fbb_}; - builder.add_caret_loc(caretLoc.o); - builder.add_scope_loc(scopeLoc.o); + builder.add_caret_loc(ast->caretLoc.index()); + builder.add_scope_loc(ast->scopeLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_GlobalScopeReflectExpression; } void ASTEncoder::visit(NamespaceReflectExpressionAST* ast) { - auto caretLoc = encodeSourceLocation(ast->caretLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -2807,8 +2385,8 @@ void ASTEncoder::visit(NamespaceReflectExpressionAST* ast) { } io::NamespaceReflectExpression::Builder builder{fbb_}; - builder.add_caret_loc(caretLoc.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_caret_loc(ast->caretLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -2818,12 +2396,10 @@ void ASTEncoder::visit(NamespaceReflectExpressionAST* ast) { } void ASTEncoder::visit(TypeIdReflectExpressionAST* ast) { - auto caretLoc = encodeSourceLocation(ast->caretLoc); - const auto typeId = accept(ast->typeId); io::TypeIdReflectExpression::Builder builder{fbb_}; - builder.add_caret_loc(caretLoc.o); + builder.add_caret_loc(ast->caretLoc.index()); builder.add_type_id(typeId.o); offset_ = builder.Finish().Union(); @@ -2831,12 +2407,10 @@ void ASTEncoder::visit(TypeIdReflectExpressionAST* ast) { } void ASTEncoder::visit(ReflectExpressionAST* ast) { - auto caretLoc = encodeSourceLocation(ast->caretLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::ReflectExpression::Builder builder{fbb_}; - builder.add_caret_loc(caretLoc.o); + builder.add_caret_loc(ast->caretLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -2845,12 +2419,10 @@ void ASTEncoder::visit(ReflectExpressionAST* ast) { } void ASTEncoder::visit(UnaryExpressionAST* ast) { - auto opLoc = encodeSourceLocation(ast->opLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::UnaryExpression::Builder builder{fbb_}; - builder.add_op_loc(opLoc.o); + builder.add_op_loc(ast->opLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); builder.add_op(static_cast(ast->op)); @@ -2860,12 +2432,10 @@ void ASTEncoder::visit(UnaryExpressionAST* ast) { } void ASTEncoder::visit(AwaitExpressionAST* ast) { - auto awaitLoc = encodeSourceLocation(ast->awaitLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::AwaitExpression::Builder builder{fbb_}; - builder.add_await_loc(awaitLoc.o); + builder.add_await_loc(ast->awaitLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -2874,12 +2444,10 @@ void ASTEncoder::visit(AwaitExpressionAST* ast) { } void ASTEncoder::visit(SizeofExpressionAST* ast) { - auto sizeofLoc = encodeSourceLocation(ast->sizeofLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::SizeofExpression::Builder builder{fbb_}; - builder.add_sizeof_loc(sizeofLoc.o); + builder.add_sizeof_loc(ast->sizeofLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -2888,35 +2456,19 @@ void ASTEncoder::visit(SizeofExpressionAST* ast) { } void ASTEncoder::visit(SizeofTypeExpressionAST* ast) { - auto sizeofLoc = encodeSourceLocation(ast->sizeofLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::SizeofTypeExpression::Builder builder{fbb_}; - builder.add_sizeof_loc(sizeofLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_sizeof_loc(ast->sizeofLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_SizeofTypeExpression; } void ASTEncoder::visit(SizeofPackExpressionAST* ast) { - auto sizeofLoc = encodeSourceLocation(ast->sizeofLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -2928,11 +2480,11 @@ void ASTEncoder::visit(SizeofPackExpressionAST* ast) { } io::SizeofPackExpression::Builder builder{fbb_}; - builder.add_sizeof_loc(sizeofLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_lparen_loc(lparenLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_sizeof_loc(ast->sizeofLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -2942,31 +2494,23 @@ void ASTEncoder::visit(SizeofPackExpressionAST* ast) { } void ASTEncoder::visit(AlignofTypeExpressionAST* ast) { - auto alignofLoc = encodeSourceLocation(ast->alignofLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::AlignofTypeExpression::Builder builder{fbb_}; - builder.add_alignof_loc(alignofLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_alignof_loc(ast->alignofLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_AlignofTypeExpression; } void ASTEncoder::visit(AlignofExpressionAST* ast) { - auto alignofLoc = encodeSourceLocation(ast->alignofLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::AlignofExpression::Builder builder{fbb_}; - builder.add_alignof_loc(alignofLoc.o); + builder.add_alignof_loc(ast->alignofLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -2975,34 +2519,22 @@ void ASTEncoder::visit(AlignofExpressionAST* ast) { } void ASTEncoder::visit(NoexceptExpressionAST* ast) { - auto noexceptLoc = encodeSourceLocation(ast->noexceptLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::NoexceptExpression::Builder builder{fbb_}; - builder.add_noexcept_loc(noexceptLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_noexcept_loc(ast->noexceptLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_NoexceptExpression; } void ASTEncoder::visit(NewExpressionAST* ast) { - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - - auto newLoc = encodeSourceLocation(ast->newLoc); - const auto newPlacement = accept(ast->newPlacement); - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> typeSpecifierListOffsets; std::vector> typeSpecifierListTypes; @@ -3019,20 +2551,18 @@ void ASTEncoder::visit(NewExpressionAST* ast) { const auto declarator = accept(ast->declarator); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto [newInitalizer, newInitalizerType] = acceptNewInitializer(ast->newInitalizer); io::NewExpression::Builder builder{fbb_}; - builder.add_scope_loc(scopeLoc.o); - builder.add_new_loc(newLoc.o); + builder.add_scope_loc(ast->scopeLoc.index()); + builder.add_new_loc(ast->newLoc.index()); builder.add_new_placement(newPlacement.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_specifier_list(typeSpecifierListOffsetsVector); builder.add_type_specifier_list_type(typeSpecifierListTypesVector); builder.add_declarator(declarator.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_new_initalizer(newInitalizer); builder.add_new_initalizer_type( static_cast(newInitalizerType)); @@ -3042,21 +2572,13 @@ void ASTEncoder::visit(NewExpressionAST* ast) { } void ASTEncoder::visit(DeleteExpressionAST* ast) { - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - - auto deleteLoc = encodeSourceLocation(ast->deleteLoc); - - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::DeleteExpression::Builder builder{fbb_}; - builder.add_scope_loc(scopeLoc.o); - builder.add_delete_loc(deleteLoc.o); - builder.add_lbracket_loc(lbracketLoc.o); - builder.add_rbracket_loc(rbracketLoc.o); + builder.add_scope_loc(ast->scopeLoc.index()); + builder.add_delete_loc(ast->deleteLoc.index()); + builder.add_lbracket_loc(ast->lbracketLoc.index()); + builder.add_rbracket_loc(ast->rbracketLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -3065,18 +2587,14 @@ void ASTEncoder::visit(DeleteExpressionAST* ast) { } void ASTEncoder::visit(CastExpressionAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::CastExpression::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -3099,8 +2617,6 @@ void ASTEncoder::visit(BinaryExpressionAST* ast) { const auto [leftExpression, leftExpressionType] = acceptExpression(ast->leftExpression); - auto opLoc = encodeSourceLocation(ast->opLoc); - const auto [rightExpression, rightExpressionType] = acceptExpression(ast->rightExpression); @@ -3108,7 +2624,7 @@ void ASTEncoder::visit(BinaryExpressionAST* ast) { builder.add_left_expression(leftExpression); builder.add_left_expression_type( static_cast(leftExpressionType)); - builder.add_op_loc(opLoc.o); + builder.add_op_loc(ast->opLoc.index()); builder.add_right_expression(rightExpression); builder.add_right_expression_type( static_cast(rightExpressionType)); @@ -3121,24 +2637,20 @@ void ASTEncoder::visit(BinaryExpressionAST* ast) { void ASTEncoder::visit(ConditionalExpressionAST* ast) { const auto [condition, conditionType] = acceptExpression(ast->condition); - auto questionLoc = encodeSourceLocation(ast->questionLoc); - const auto [iftrueExpression, iftrueExpressionType] = acceptExpression(ast->iftrueExpression); - auto colonLoc = encodeSourceLocation(ast->colonLoc); - const auto [iffalseExpression, iffalseExpressionType] = acceptExpression(ast->iffalseExpression); io::ConditionalExpression::Builder builder{fbb_}; builder.add_condition(condition); builder.add_condition_type(static_cast(conditionType)); - builder.add_question_loc(questionLoc.o); + builder.add_question_loc(ast->questionLoc.index()); builder.add_iftrue_expression(iftrueExpression); builder.add_iftrue_expression_type( static_cast(iftrueExpressionType)); - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_iffalse_expression(iffalseExpression); builder.add_iffalse_expression_type( static_cast(iffalseExpressionType)); @@ -3148,12 +2660,10 @@ void ASTEncoder::visit(ConditionalExpressionAST* ast) { } void ASTEncoder::visit(YieldExpressionAST* ast) { - auto yieldLoc = encodeSourceLocation(ast->yieldLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::YieldExpression::Builder builder{fbb_}; - builder.add_yield_loc(yieldLoc.o); + builder.add_yield_loc(ast->yieldLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -3162,12 +2672,10 @@ void ASTEncoder::visit(YieldExpressionAST* ast) { } void ASTEncoder::visit(ThrowExpressionAST* ast) { - auto throwLoc = encodeSourceLocation(ast->throwLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::ThrowExpression::Builder builder{fbb_}; - builder.add_throw_loc(throwLoc.o); + builder.add_throw_loc(ast->throwLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -3179,8 +2687,6 @@ void ASTEncoder::visit(AssignmentExpressionAST* ast) { const auto [leftExpression, leftExpressionType] = acceptExpression(ast->leftExpression); - auto opLoc = encodeSourceLocation(ast->opLoc); - const auto [rightExpression, rightExpressionType] = acceptExpression(ast->rightExpression); @@ -3188,7 +2694,7 @@ void ASTEncoder::visit(AssignmentExpressionAST* ast) { builder.add_left_expression(leftExpression); builder.add_left_expression_type( static_cast(leftExpressionType)); - builder.add_op_loc(opLoc.o); + builder.add_op_loc(ast->opLoc.index()); builder.add_right_expression(rightExpression); builder.add_right_expression_type( static_cast(rightExpressionType)); @@ -3201,22 +2707,16 @@ void ASTEncoder::visit(AssignmentExpressionAST* ast) { void ASTEncoder::visit(PackExpansionExpressionAST* ast) { const auto [expression, expressionType] = acceptExpression(ast->expression); - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - io::PackExpansionExpression::Builder builder{fbb_}; builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_PackExpansionExpression; } void ASTEncoder::visit(DesignatedInitializerClauseAST* ast) { - auto dotLoc = encodeSourceLocation(ast->dotLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -3231,8 +2731,8 @@ void ASTEncoder::visit(DesignatedInitializerClauseAST* ast) { acceptExpression(ast->initializer); io::DesignatedInitializerClause::Builder builder{fbb_}; - builder.add_dot_loc(dotLoc.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_dot_loc(ast->dotLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -3244,10 +2744,6 @@ void ASTEncoder::visit(DesignatedInitializerClauseAST* ast) { } void ASTEncoder::visit(TypeTraitExpressionAST* ast) { - auto typeTraitLoc = encodeSourceLocation(ast->typeTraitLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> typeIdListOffsets; for (auto node : ListView{ast->typeIdList}) { if (!node) continue; @@ -3256,13 +2752,11 @@ void ASTEncoder::visit(TypeTraitExpressionAST* ast) { auto typeIdListOffsetsVector = fbb_.CreateVector(typeIdListOffsets); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::TypeTraitExpression::Builder builder{fbb_}; - builder.add_type_trait_loc(typeTraitLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_type_trait_loc(ast->typeTraitLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id_list(typeIdListOffsetsVector); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_TypeTraitExpression; @@ -3316,12 +2810,10 @@ void ASTEncoder::visit(ConditionExpressionAST* ast) { } void ASTEncoder::visit(EqualInitializerAST* ast) { - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::EqualInitializer::Builder builder{fbb_}; - builder.add_equal_loc(equalLoc.o); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -3330,8 +2822,6 @@ void ASTEncoder::visit(EqualInitializerAST* ast) { } void ASTEncoder::visit(BracedInitListAST* ast) { - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - std::vector> expressionListOffsets; std::vector> expressionListTypes; @@ -3345,24 +2835,18 @@ void ASTEncoder::visit(BracedInitListAST* ast) { auto expressionListOffsetsVector = fbb_.CreateVector(expressionListOffsets); auto expressionListTypesVector = fbb_.CreateVector(expressionListTypes); - auto commaLoc = encodeSourceLocation(ast->commaLoc); - - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - io::BracedInitList::Builder builder{fbb_}; - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_expression_list(expressionListOffsetsVector); builder.add_expression_list_type(expressionListTypesVector); - builder.add_comma_loc(commaLoc.o); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_comma_loc(ast->commaLoc.index()); + builder.add_rbrace_loc(ast->rbraceLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_BracedInitList; } void ASTEncoder::visit(ParenInitializerAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> expressionListOffsets; std::vector> expressionListTypes; @@ -3376,48 +2860,32 @@ void ASTEncoder::visit(ParenInitializerAST* ast) { auto expressionListOffsetsVector = fbb_.CreateVector(expressionListOffsets); auto expressionListTypesVector = fbb_.CreateVector(expressionListTypes); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::ParenInitializer::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression_list(expressionListOffsetsVector); builder.add_expression_list_type(expressionListTypesVector); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Expression_ParenInitializer; } void ASTEncoder::visit(SplicerAST* ast) { - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto secondColonLoc = encodeSourceLocation(ast->secondColonLoc); - - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - io::Splicer::Builder builder{fbb_}; - builder.add_lbracket_loc(lbracketLoc.o); - builder.add_colon_loc(colonLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_lbracket_loc(ast->lbracketLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_second_colon_loc(secondColonLoc.o); - builder.add_rbracket_loc(rbracketLoc.o); + builder.add_second_colon_loc(ast->secondColonLoc.index()); + builder.add_rbracket_loc(ast->rbracketLoc.index()); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(GlobalModuleFragmentAST* ast) { - auto moduleLoc = encodeSourceLocation(ast->moduleLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - std::vector> declarationListOffsets; std::vector> declarationListTypes; @@ -3432,8 +2900,8 @@ void ASTEncoder::visit(GlobalModuleFragmentAST* ast) { auto declarationListTypesVector = fbb_.CreateVector(declarationListTypes); io::GlobalModuleFragment::Builder builder{fbb_}; - builder.add_module_loc(moduleLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_module_loc(ast->moduleLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); builder.add_declaration_list(declarationListOffsetsVector); builder.add_declaration_list_type(declarationListTypesVector); @@ -3441,14 +2909,6 @@ void ASTEncoder::visit(GlobalModuleFragmentAST* ast) { } void ASTEncoder::visit(PrivateModuleFragmentAST* ast) { - auto moduleLoc = encodeSourceLocation(ast->moduleLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - - auto privateLoc = encodeSourceLocation(ast->privateLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - std::vector> declarationListOffsets; std::vector> declarationListTypes; @@ -3463,10 +2923,10 @@ void ASTEncoder::visit(PrivateModuleFragmentAST* ast) { auto declarationListTypesVector = fbb_.CreateVector(declarationListTypes); io::PrivateModuleFragment::Builder builder{fbb_}; - builder.add_module_loc(moduleLoc.o); - builder.add_colon_loc(colonLoc.o); - builder.add_private_loc(privateLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_module_loc(ast->moduleLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); + builder.add_private_loc(ast->privateLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); builder.add_declaration_list(declarationListOffsetsVector); builder.add_declaration_list_type(declarationListTypesVector); @@ -3474,10 +2934,6 @@ void ASTEncoder::visit(PrivateModuleFragmentAST* ast) { } void ASTEncoder::visit(ModuleDeclarationAST* ast) { - auto exportLoc = encodeSourceLocation(ast->exportLoc); - - auto moduleLoc = encodeSourceLocation(ast->moduleLoc); - const auto moduleName = accept(ast->moduleName); const auto modulePartition = accept(ast->modulePartition); @@ -3496,16 +2952,14 @@ void ASTEncoder::visit(ModuleDeclarationAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::ModuleDeclaration::Builder builder{fbb_}; - builder.add_export_loc(exportLoc.o); - builder.add_module_loc(moduleLoc.o); + builder.add_export_loc(ast->exportLoc.index()); + builder.add_module_loc(ast->moduleLoc.index()); builder.add_module_name(moduleName.o); builder.add_module_partition(modulePartition.o); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); } @@ -3513,8 +2967,6 @@ void ASTEncoder::visit(ModuleDeclarationAST* ast) { void ASTEncoder::visit(ModuleNameAST* ast) { const auto moduleQualifier = accept(ast->moduleQualifier); - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -3527,7 +2979,7 @@ void ASTEncoder::visit(ModuleNameAST* ast) { io::ModuleName::Builder builder{fbb_}; builder.add_module_qualifier(moduleQualifier.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -3538,10 +2990,6 @@ void ASTEncoder::visit(ModuleNameAST* ast) { void ASTEncoder::visit(ModuleQualifierAST* ast) { const auto moduleQualifier = accept(ast->moduleQualifier); - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto dotLoc = encodeSourceLocation(ast->dotLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -3554,8 +3002,8 @@ void ASTEncoder::visit(ModuleQualifierAST* ast) { io::ModuleQualifier::Builder builder{fbb_}; builder.add_module_qualifier(moduleQualifier.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_dot_loc(dotLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_dot_loc(ast->dotLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -3564,26 +3012,22 @@ void ASTEncoder::visit(ModuleQualifierAST* ast) { } void ASTEncoder::visit(ModulePartitionAST* ast) { - auto colonLoc = encodeSourceLocation(ast->colonLoc); - const auto moduleName = accept(ast->moduleName); io::ModulePartition::Builder builder{fbb_}; - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_module_name(moduleName.o); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(ImportNameAST* ast) { - auto headerLoc = encodeSourceLocation(ast->headerLoc); - const auto modulePartition = accept(ast->modulePartition); const auto moduleName = accept(ast->moduleName); io::ImportName::Builder builder{fbb_}; - builder.add_header_loc(headerLoc.o); + builder.add_header_loc(ast->headerLoc.index()); builder.add_module_partition(modulePartition.o); builder.add_module_name(moduleName.o); @@ -3653,32 +3097,26 @@ void ASTEncoder::visit(DeclaratorAST* ast) { } void ASTEncoder::visit(UsingDeclaratorAST* ast) { - auto typenameLoc = encodeSourceLocation(ast->typenameLoc); - const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - io::UsingDeclarator::Builder builder{fbb_}; - builder.add_typename_loc(typenameLoc.o); + builder.add_typename_loc(ast->typenameLoc.index()); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(EnumeratorAST* ast) { - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -3693,8 +3131,6 @@ void ASTEncoder::visit(EnumeratorAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); flatbuffers::Offset identifier; @@ -3708,10 +3144,10 @@ void ASTEncoder::visit(EnumeratorAST* ast) { } io::Enumerator::Builder builder{fbb_}; - builder.add_identifier_loc(identifierLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); - builder.add_equal_loc(equalLoc.o); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); if (ast->identifier) { @@ -3747,24 +3183,18 @@ void ASTEncoder::visit(TypeIdAST* ast) { } void ASTEncoder::visit(HandlerAST* ast) { - auto catchLoc = encodeSourceLocation(ast->catchLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [exceptionDeclaration, exceptionDeclarationType] = acceptExceptionDeclaration(ast->exceptionDeclaration); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - const auto statement = accept(ast->statement); io::Handler::Builder builder{fbb_}; - builder.add_catch_loc(catchLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_catch_loc(ast->catchLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_exception_declaration(exceptionDeclaration); builder.add_exception_declaration_type( static_cast(exceptionDeclarationType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_statement(statement.o); offset_ = builder.Finish().Union(); @@ -3788,8 +3218,6 @@ void ASTEncoder::visit(BaseSpecifierAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); @@ -3799,7 +3227,7 @@ void ASTEncoder::visit(BaseSpecifierAST* ast) { builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_template_loc(templateLoc.o); + builder.add_template_loc(ast->templateLoc.index()); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); @@ -3810,12 +3238,10 @@ void ASTEncoder::visit(BaseSpecifierAST* ast) { } void ASTEncoder::visit(RequiresClauseAST* ast) { - auto requiresLoc = encodeSourceLocation(ast->requiresLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); io::RequiresClause::Builder builder{fbb_}; - builder.add_requires_loc(requiresLoc.o); + builder.add_requires_loc(ast->requiresLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); @@ -3833,35 +3259,27 @@ void ASTEncoder::visit(ParameterDeclarationClauseAST* ast) { auto parameterDeclarationListOffsetsVector = fbb_.CreateVector(parameterDeclarationListOffsets); - auto commaLoc = encodeSourceLocation(ast->commaLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - io::ParameterDeclarationClause::Builder builder{fbb_}; builder.add_parameter_declaration_list(parameterDeclarationListOffsetsVector); - builder.add_comma_loc(commaLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_comma_loc(ast->commaLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(TrailingReturnTypeAST* ast) { - auto minusGreaterLoc = encodeSourceLocation(ast->minusGreaterLoc); - const auto typeId = accept(ast->typeId); io::TrailingReturnType::Builder builder{fbb_}; - builder.add_minus_greater_loc(minusGreaterLoc.o); + builder.add_minus_greater_loc(ast->minusGreaterLoc.index()); builder.add_type_id(typeId.o); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(LambdaSpecifierAST* ast) { - auto specifierLoc = encodeSourceLocation(ast->specifierLoc); - io::LambdaSpecifier::Builder builder{fbb_}; - builder.add_specifier_loc(specifierLoc.o); + builder.add_specifier_loc(ast->specifierLoc.index()); builder.add_specifier(static_cast(ast->specifier)); offset_ = builder.Finish().Union(); @@ -3871,10 +3289,6 @@ void ASTEncoder::visit(TypeConstraintAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto lessLoc = encodeSourceLocation(ast->lessLoc); - std::vector> templateArgumentListOffsets; std::vector> templateArgumentListTypes; @@ -3891,8 +3305,6 @@ void ASTEncoder::visit(TypeConstraintAST* ast) { auto templateArgumentListTypesVector = fbb_.CreateVector(templateArgumentListTypes); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -3907,11 +3319,11 @@ void ASTEncoder::visit(TypeConstraintAST* ast) { builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_identifier_loc(identifierLoc.o); - builder.add_less_loc(lessLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_less_loc(ast->lessLoc.index()); builder.add_template_argument_list(templateArgumentListOffsetsVector); builder.add_template_argument_list_type(templateArgumentListTypesVector); - builder.add_greater_loc(greaterLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -3920,13 +3332,9 @@ void ASTEncoder::visit(TypeConstraintAST* ast) { } void ASTEncoder::visit(AttributeArgumentClauseAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::AttributeArgumentClause::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); } @@ -3937,36 +3345,26 @@ void ASTEncoder::visit(AttributeAST* ast) { const auto attributeArgumentClause = accept(ast->attributeArgumentClause); - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - io::Attribute::Builder builder{fbb_}; builder.add_attribute_token(attributeToken); builder.add_attribute_token_type( static_cast(attributeTokenType)); builder.add_attribute_argument_clause(attributeArgumentClause.o); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(AttributeUsingPrefixAST* ast) { - auto usingLoc = encodeSourceLocation(ast->usingLoc); - - auto attributeNamespaceLoc = encodeSourceLocation(ast->attributeNamespaceLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - io::AttributeUsingPrefix::Builder builder{fbb_}; - builder.add_using_loc(usingLoc.o); - builder.add_attribute_namespace_loc(attributeNamespaceLoc.o); - builder.add_colon_loc(colonLoc.o); + builder.add_using_loc(ast->usingLoc.index()); + builder.add_attribute_namespace_loc(ast->attributeNamespaceLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(NewPlacementAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> expressionListOffsets; std::vector> expressionListTypes; @@ -3980,24 +3378,16 @@ void ASTEncoder::visit(NewPlacementAST* ast) { auto expressionListOffsetsVector = fbb_.CreateVector(expressionListOffsets); auto expressionListTypesVector = fbb_.CreateVector(expressionListTypes); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::NewPlacement::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression_list(expressionListOffsetsVector); builder.add_expression_list_type(expressionListTypesVector); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); } void ASTEncoder::visit(NestedNamespaceSpecifierAST* ast) { - auto inlineLoc = encodeSourceLocation(ast->inlineLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -4009,9 +3399,9 @@ void ASTEncoder::visit(NestedNamespaceSpecifierAST* ast) { } io::NestedNamespaceSpecifier::Builder builder{fbb_}; - builder.add_inline_loc(inlineLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_scope_loc(scopeLoc.o); + builder.add_inline_loc(ast->inlineLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_scope_loc(ast->scopeLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -4020,10 +3410,6 @@ void ASTEncoder::visit(NestedNamespaceSpecifierAST* ast) { } void ASTEncoder::visit(TemplateTypeParameterAST* ast) { - auto templateLoc = encodeSourceLocation(ast->templateLoc); - - auto lessLoc = encodeSourceLocation(ast->lessLoc); - std::vector> templateParameterListOffsets; std::vector> templateParameterListTypes; @@ -4040,18 +3426,8 @@ void ASTEncoder::visit(TemplateTypeParameterAST* ast) { auto templateParameterListTypesVector = fbb_.CreateVector(templateParameterListTypes); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - const auto requiresClause = accept(ast->requiresClause); - auto classKeyLoc = encodeSourceLocation(ast->classKeyLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto idExpression = accept(ast->idExpression); flatbuffers::Offset identifier; @@ -4065,16 +3441,16 @@ void ASTEncoder::visit(TemplateTypeParameterAST* ast) { } io::TemplateTypeParameter::Builder builder{fbb_}; - builder.add_template_loc(templateLoc.o); - builder.add_less_loc(lessLoc.o); + builder.add_template_loc(ast->templateLoc.index()); + builder.add_less_loc(ast->lessLoc.index()); builder.add_template_parameter_list(templateParameterListOffsetsVector); builder.add_template_parameter_list_type(templateParameterListTypesVector); - builder.add_greater_loc(greaterLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); builder.add_requires_clause(requiresClause.o); - builder.add_class_key_loc(classKeyLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_equal_loc(equalLoc.o); + builder.add_class_key_loc(ast->classKeyLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_id_expression(idExpression.o); if (ast->identifier) { builder.add_identifier(identifier); @@ -4095,14 +3471,6 @@ void ASTEncoder::visit(NonTypeTemplateParameterAST* ast) { } void ASTEncoder::visit(TypenameTypeParameterAST* ast) { - auto classKeyLoc = encodeSourceLocation(ast->classKeyLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto typeId = accept(ast->typeId); flatbuffers::Offset identifier; @@ -4116,10 +3484,10 @@ void ASTEncoder::visit(TypenameTypeParameterAST* ast) { } io::TypenameTypeParameter::Builder builder{fbb_}; - builder.add_class_key_loc(classKeyLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_equal_loc(equalLoc.o); + builder.add_class_key_loc(ast->classKeyLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_type_id(typeId.o); if (ast->identifier) { builder.add_identifier(identifier); @@ -4132,12 +3500,6 @@ void ASTEncoder::visit(TypenameTypeParameterAST* ast) { void ASTEncoder::visit(ConstraintTypeParameterAST* ast) { const auto typeConstraint = accept(ast->typeConstraint); - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto equalLoc = encodeSourceLocation(ast->equalLoc); - const auto typeId = accept(ast->typeId); flatbuffers::Offset identifier; @@ -4152,9 +3514,9 @@ void ASTEncoder::visit(ConstraintTypeParameterAST* ast) { io::ConstraintTypeParameter::Builder builder{fbb_}; builder.add_type_constraint(typeConstraint.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_equal_loc(equalLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_equal_loc(ast->equalLoc.index()); builder.add_type_id(typeId.o); if (ast->identifier) { builder.add_identifier(identifier); @@ -4165,180 +3527,142 @@ void ASTEncoder::visit(ConstraintTypeParameterAST* ast) { } void ASTEncoder::visit(GeneratedTypeSpecifierAST* ast) { - auto typeLoc = encodeSourceLocation(ast->typeLoc); - io::GeneratedTypeSpecifier::Builder builder{fbb_}; - builder.add_type_loc(typeLoc.o); + builder.add_type_loc(ast->typeLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_GeneratedTypeSpecifier; } void ASTEncoder::visit(TypedefSpecifierAST* ast) { - auto typedefLoc = encodeSourceLocation(ast->typedefLoc); - io::TypedefSpecifier::Builder builder{fbb_}; - builder.add_typedef_loc(typedefLoc.o); + builder.add_typedef_loc(ast->typedefLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_TypedefSpecifier; } void ASTEncoder::visit(FriendSpecifierAST* ast) { - auto friendLoc = encodeSourceLocation(ast->friendLoc); - io::FriendSpecifier::Builder builder{fbb_}; - builder.add_friend_loc(friendLoc.o); + builder.add_friend_loc(ast->friendLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_FriendSpecifier; } void ASTEncoder::visit(ConstevalSpecifierAST* ast) { - auto constevalLoc = encodeSourceLocation(ast->constevalLoc); - io::ConstevalSpecifier::Builder builder{fbb_}; - builder.add_consteval_loc(constevalLoc.o); + builder.add_consteval_loc(ast->constevalLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ConstevalSpecifier; } void ASTEncoder::visit(ConstinitSpecifierAST* ast) { - auto constinitLoc = encodeSourceLocation(ast->constinitLoc); - io::ConstinitSpecifier::Builder builder{fbb_}; - builder.add_constinit_loc(constinitLoc.o); + builder.add_constinit_loc(ast->constinitLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ConstinitSpecifier; } void ASTEncoder::visit(ConstexprSpecifierAST* ast) { - auto constexprLoc = encodeSourceLocation(ast->constexprLoc); - io::ConstexprSpecifier::Builder builder{fbb_}; - builder.add_constexpr_loc(constexprLoc.o); + builder.add_constexpr_loc(ast->constexprLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ConstexprSpecifier; } void ASTEncoder::visit(InlineSpecifierAST* ast) { - auto inlineLoc = encodeSourceLocation(ast->inlineLoc); - io::InlineSpecifier::Builder builder{fbb_}; - builder.add_inline_loc(inlineLoc.o); + builder.add_inline_loc(ast->inlineLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_InlineSpecifier; } void ASTEncoder::visit(StaticSpecifierAST* ast) { - auto staticLoc = encodeSourceLocation(ast->staticLoc); - io::StaticSpecifier::Builder builder{fbb_}; - builder.add_static_loc(staticLoc.o); + builder.add_static_loc(ast->staticLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_StaticSpecifier; } void ASTEncoder::visit(ExternSpecifierAST* ast) { - auto externLoc = encodeSourceLocation(ast->externLoc); - io::ExternSpecifier::Builder builder{fbb_}; - builder.add_extern_loc(externLoc.o); + builder.add_extern_loc(ast->externLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ExternSpecifier; } void ASTEncoder::visit(ThreadLocalSpecifierAST* ast) { - auto threadLocalLoc = encodeSourceLocation(ast->threadLocalLoc); - io::ThreadLocalSpecifier::Builder builder{fbb_}; - builder.add_thread_local_loc(threadLocalLoc.o); + builder.add_thread_local_loc(ast->threadLocalLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ThreadLocalSpecifier; } void ASTEncoder::visit(ThreadSpecifierAST* ast) { - auto threadLoc = encodeSourceLocation(ast->threadLoc); - io::ThreadSpecifier::Builder builder{fbb_}; - builder.add_thread_loc(threadLoc.o); + builder.add_thread_loc(ast->threadLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ThreadSpecifier; } void ASTEncoder::visit(MutableSpecifierAST* ast) { - auto mutableLoc = encodeSourceLocation(ast->mutableLoc); - io::MutableSpecifier::Builder builder{fbb_}; - builder.add_mutable_loc(mutableLoc.o); + builder.add_mutable_loc(ast->mutableLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_MutableSpecifier; } void ASTEncoder::visit(VirtualSpecifierAST* ast) { - auto virtualLoc = encodeSourceLocation(ast->virtualLoc); - io::VirtualSpecifier::Builder builder{fbb_}; - builder.add_virtual_loc(virtualLoc.o); + builder.add_virtual_loc(ast->virtualLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_VirtualSpecifier; } void ASTEncoder::visit(ExplicitSpecifierAST* ast) { - auto explicitLoc = encodeSourceLocation(ast->explicitLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::ExplicitSpecifier::Builder builder{fbb_}; - builder.add_explicit_loc(explicitLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_explicit_loc(ast->explicitLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ExplicitSpecifier; } void ASTEncoder::visit(AutoTypeSpecifierAST* ast) { - auto autoLoc = encodeSourceLocation(ast->autoLoc); - io::AutoTypeSpecifier::Builder builder{fbb_}; - builder.add_auto_loc(autoLoc.o); + builder.add_auto_loc(ast->autoLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_AutoTypeSpecifier; } void ASTEncoder::visit(VoidTypeSpecifierAST* ast) { - auto voidLoc = encodeSourceLocation(ast->voidLoc); - io::VoidTypeSpecifier::Builder builder{fbb_}; - builder.add_void_loc(voidLoc.o); + builder.add_void_loc(ast->voidLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_VoidTypeSpecifier; } void ASTEncoder::visit(SizeTypeSpecifierAST* ast) { - auto specifierLoc = encodeSourceLocation(ast->specifierLoc); - io::SizeTypeSpecifier::Builder builder{fbb_}; - builder.add_specifier_loc(specifierLoc.o); + builder.add_specifier_loc(ast->specifierLoc.index()); builder.add_specifier(static_cast(ast->specifier)); offset_ = builder.Finish().Union(); @@ -4346,10 +3670,8 @@ void ASTEncoder::visit(SizeTypeSpecifierAST* ast) { } void ASTEncoder::visit(SignTypeSpecifierAST* ast) { - auto specifierLoc = encodeSourceLocation(ast->specifierLoc); - io::SignTypeSpecifier::Builder builder{fbb_}; - builder.add_specifier_loc(specifierLoc.o); + builder.add_specifier_loc(ast->specifierLoc.index()); builder.add_specifier(static_cast(ast->specifier)); offset_ = builder.Finish().Union(); @@ -4357,10 +3679,8 @@ void ASTEncoder::visit(SignTypeSpecifierAST* ast) { } void ASTEncoder::visit(VaListTypeSpecifierAST* ast) { - auto specifierLoc = encodeSourceLocation(ast->specifierLoc); - io::VaListTypeSpecifier::Builder builder{fbb_}; - builder.add_specifier_loc(specifierLoc.o); + builder.add_specifier_loc(ast->specifierLoc.index()); builder.add_specifier(static_cast(ast->specifier)); offset_ = builder.Finish().Union(); @@ -4368,10 +3688,8 @@ void ASTEncoder::visit(VaListTypeSpecifierAST* ast) { } void ASTEncoder::visit(IntegralTypeSpecifierAST* ast) { - auto specifierLoc = encodeSourceLocation(ast->specifierLoc); - io::IntegralTypeSpecifier::Builder builder{fbb_}; - builder.add_specifier_loc(specifierLoc.o); + builder.add_specifier_loc(ast->specifierLoc.index()); builder.add_specifier(static_cast(ast->specifier)); offset_ = builder.Finish().Union(); @@ -4379,10 +3697,8 @@ void ASTEncoder::visit(IntegralTypeSpecifierAST* ast) { } void ASTEncoder::visit(FloatingPointTypeSpecifierAST* ast) { - auto specifierLoc = encodeSourceLocation(ast->specifierLoc); - io::FloatingPointTypeSpecifier::Builder builder{fbb_}; - builder.add_specifier_loc(specifierLoc.o); + builder.add_specifier_loc(ast->specifierLoc.index()); builder.add_specifier(static_cast(ast->specifier)); offset_ = builder.Finish().Union(); @@ -4390,10 +3706,8 @@ void ASTEncoder::visit(FloatingPointTypeSpecifierAST* ast) { } void ASTEncoder::visit(ComplexTypeSpecifierAST* ast) { - auto complexLoc = encodeSourceLocation(ast->complexLoc); - io::ComplexTypeSpecifier::Builder builder{fbb_}; - builder.add_complex_loc(complexLoc.o); + builder.add_complex_loc(ast->complexLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ComplexTypeSpecifier; @@ -4403,8 +3717,6 @@ void ASTEncoder::visit(NamedTypeSpecifierAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); @@ -4412,7 +3724,7 @@ void ASTEncoder::visit(NamedTypeSpecifierAST* ast) { builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_template_loc(templateLoc.o); + builder.add_template_loc(ast->templateLoc.index()); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); @@ -4422,46 +3734,32 @@ void ASTEncoder::visit(NamedTypeSpecifierAST* ast) { } void ASTEncoder::visit(AtomicTypeSpecifierAST* ast) { - auto atomicLoc = encodeSourceLocation(ast->atomicLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::AtomicTypeSpecifier::Builder builder{fbb_}; - builder.add_atomic_loc(atomicLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_atomic_loc(ast->atomicLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_AtomicTypeSpecifier; } void ASTEncoder::visit(UnderlyingTypeSpecifierAST* ast) { - auto underlyingTypeLoc = encodeSourceLocation(ast->underlyingTypeLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::UnderlyingTypeSpecifier::Builder builder{fbb_}; - builder.add_underlying_type_loc(underlyingTypeLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_underlying_type_loc(ast->underlyingTypeLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_UnderlyingTypeSpecifier; } void ASTEncoder::visit(ElaboratedTypeSpecifierAST* ast) { - auto classLoc = encodeSourceLocation(ast->classLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -4479,19 +3777,17 @@ void ASTEncoder::visit(ElaboratedTypeSpecifierAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); io::ElaboratedTypeSpecifier::Builder builder{fbb_}; - builder.add_class_loc(classLoc.o); + builder.add_class_loc(ast->classLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_template_loc(templateLoc.o); + builder.add_template_loc(ast->templateLoc.index()); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); @@ -4502,39 +3798,25 @@ void ASTEncoder::visit(ElaboratedTypeSpecifierAST* ast) { } void ASTEncoder::visit(DecltypeAutoSpecifierAST* ast) { - auto decltypeLoc = encodeSourceLocation(ast->decltypeLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto autoLoc = encodeSourceLocation(ast->autoLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::DecltypeAutoSpecifier::Builder builder{fbb_}; - builder.add_decltype_loc(decltypeLoc.o); - builder.add_lparen_loc(lparenLoc.o); - builder.add_auto_loc(autoLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_decltype_loc(ast->decltypeLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_auto_loc(ast->autoLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_DecltypeAutoSpecifier; } void ASTEncoder::visit(DecltypeSpecifierAST* ast) { - auto decltypeLoc = encodeSourceLocation(ast->decltypeLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::DecltypeSpecifier::Builder builder{fbb_}; - builder.add_decltype_loc(decltypeLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_decltype_loc(ast->decltypeLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_DecltypeSpecifier; @@ -4555,40 +3837,30 @@ void ASTEncoder::visit(PlaceholderTypeSpecifierAST* ast) { } void ASTEncoder::visit(ConstQualifierAST* ast) { - auto constLoc = encodeSourceLocation(ast->constLoc); - io::ConstQualifier::Builder builder{fbb_}; - builder.add_const_loc(constLoc.o); + builder.add_const_loc(ast->constLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_ConstQualifier; } void ASTEncoder::visit(VolatileQualifierAST* ast) { - auto volatileLoc = encodeSourceLocation(ast->volatileLoc); - io::VolatileQualifier::Builder builder{fbb_}; - builder.add_volatile_loc(volatileLoc.o); + builder.add_volatile_loc(ast->volatileLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_VolatileQualifier; } void ASTEncoder::visit(RestrictQualifierAST* ast) { - auto restrictLoc = encodeSourceLocation(ast->restrictLoc); - io::RestrictQualifier::Builder builder{fbb_}; - builder.add_restrict_loc(restrictLoc.o); + builder.add_restrict_loc(ast->restrictLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_RestrictQualifier; } void ASTEncoder::visit(EnumSpecifierAST* ast) { - auto enumLoc = encodeSourceLocation(ast->enumLoc); - - auto classLoc = encodeSourceLocation(ast->classLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -4608,8 +3880,6 @@ void ASTEncoder::visit(EnumSpecifierAST* ast) { const auto unqualifiedId = accept(ast->unqualifiedId); - auto colonLoc = encodeSourceLocation(ast->colonLoc); - std::vector> typeSpecifierListOffsets; std::vector> typeSpecifierListTypes; @@ -4624,10 +3894,6 @@ void ASTEncoder::visit(EnumSpecifierAST* ast) { fbb_.CreateVector(typeSpecifierListOffsets); auto typeSpecifierListTypesVector = fbb_.CreateVector(typeSpecifierListTypes); - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - - auto commaLoc = encodeSourceLocation(ast->commaLoc); - std::vector> enumeratorListOffsets; for (auto node : ListView{ast->enumeratorList}) { if (!node) continue; @@ -4636,32 +3902,28 @@ void ASTEncoder::visit(EnumSpecifierAST* ast) { auto enumeratorListOffsetsVector = fbb_.CreateVector(enumeratorListOffsets); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - io::EnumSpecifier::Builder builder{fbb_}; - builder.add_enum_loc(enumLoc.o); - builder.add_class_loc(classLoc.o); + builder.add_enum_loc(ast->enumLoc.index()); + builder.add_class_loc(ast->classLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); builder.add_unqualified_id(unqualifiedId.o); - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_type_specifier_list(typeSpecifierListOffsetsVector); builder.add_type_specifier_list_type(typeSpecifierListTypesVector); - builder.add_lbrace_loc(lbraceLoc.o); - builder.add_comma_loc(commaLoc.o); + builder.add_lbrace_loc(ast->lbraceLoc.index()); + builder.add_comma_loc(ast->commaLoc.index()); builder.add_enumerator_list(enumeratorListOffsetsVector); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Specifier_EnumSpecifier; } void ASTEncoder::visit(ClassSpecifierAST* ast) { - auto classLoc = encodeSourceLocation(ast->classLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -4682,10 +3944,6 @@ void ASTEncoder::visit(ClassSpecifierAST* ast) { const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); - auto finalLoc = encodeSourceLocation(ast->finalLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - std::vector> baseSpecifierListOffsets; for (auto node : ListView{ast->baseSpecifierList}) { if (!node) continue; @@ -4695,8 +3953,6 @@ void ASTEncoder::visit(ClassSpecifierAST* ast) { auto baseSpecifierListOffsetsVector = fbb_.CreateVector(baseSpecifierListOffsets); - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - std::vector> declarationListOffsets; std::vector> declarationListTypes; @@ -4710,10 +3966,8 @@ void ASTEncoder::visit(ClassSpecifierAST* ast) { auto declarationListOffsetsVector = fbb_.CreateVector(declarationListOffsets); auto declarationListTypesVector = fbb_.CreateVector(declarationListTypes); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - io::ClassSpecifier::Builder builder{fbb_}; - builder.add_class_loc(classLoc.o); + builder.add_class_loc(ast->classLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_nested_name_specifier(nestedNameSpecifier); @@ -4722,13 +3976,13 @@ void ASTEncoder::visit(ClassSpecifierAST* ast) { builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); - builder.add_final_loc(finalLoc.o); - builder.add_colon_loc(colonLoc.o); + builder.add_final_loc(ast->finalLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_base_specifier_list(baseSpecifierListOffsetsVector); - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_declaration_list(declarationListOffsetsVector); builder.add_declaration_list_type(declarationListTypesVector); - builder.add_rbrace_loc(rbraceLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); builder.add_class_key(static_cast(ast->classKey)); offset_ = builder.Finish().Union(); @@ -4736,8 +3990,6 @@ void ASTEncoder::visit(ClassSpecifierAST* ast) { } void ASTEncoder::visit(TypenameSpecifierAST* ast) { - auto typenameLoc = encodeSourceLocation(ast->typenameLoc); - const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); @@ -4745,7 +3997,7 @@ void ASTEncoder::visit(TypenameSpecifierAST* ast) { acceptUnqualifiedId(ast->unqualifiedId); io::TypenameSpecifier::Builder builder{fbb_}; - builder.add_typename_loc(typenameLoc.o); + builder.add_typename_loc(ast->typenameLoc.index()); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); @@ -4758,12 +4010,10 @@ void ASTEncoder::visit(TypenameSpecifierAST* ast) { } void ASTEncoder::visit(SplicerTypeSpecifierAST* ast) { - auto typenameLoc = encodeSourceLocation(ast->typenameLoc); - const auto splicer = accept(ast->splicer); io::SplicerTypeSpecifier::Builder builder{fbb_}; - builder.add_typename_loc(typenameLoc.o); + builder.add_typename_loc(ast->typenameLoc.index()); builder.add_splicer(splicer.o); offset_ = builder.Finish().Union(); @@ -4771,8 +4021,6 @@ void ASTEncoder::visit(SplicerTypeSpecifierAST* ast) { } void ASTEncoder::visit(PointerOperatorAST* ast) { - auto starLoc = encodeSourceLocation(ast->starLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -4801,7 +4049,7 @@ void ASTEncoder::visit(PointerOperatorAST* ast) { auto cvQualifierListTypesVector = fbb_.CreateVector(cvQualifierListTypes); io::PointerOperator::Builder builder{fbb_}; - builder.add_star_loc(starLoc.o); + builder.add_star_loc(ast->starLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_cv_qualifier_list(cvQualifierListOffsetsVector); @@ -4812,8 +4060,6 @@ void ASTEncoder::visit(PointerOperatorAST* ast) { } void ASTEncoder::visit(ReferenceOperatorAST* ast) { - auto refLoc = encodeSourceLocation(ast->refLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -4829,7 +4075,7 @@ void ASTEncoder::visit(ReferenceOperatorAST* ast) { auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); io::ReferenceOperator::Builder builder{fbb_}; - builder.add_ref_loc(refLoc.o); + builder.add_ref_loc(ast->refLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_ref_op(static_cast(ast->refOp)); @@ -4842,8 +4088,6 @@ void ASTEncoder::visit(PtrToMemberOperatorAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto starLoc = encodeSourceLocation(ast->starLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -4875,7 +4119,7 @@ void ASTEncoder::visit(PtrToMemberOperatorAST* ast) { builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_star_loc(starLoc.o); + builder.add_star_loc(ast->starLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); builder.add_cv_qualifier_list(cvQualifierListOffsetsVector); @@ -4888,14 +4132,12 @@ void ASTEncoder::visit(PtrToMemberOperatorAST* ast) { void ASTEncoder::visit(BitfieldDeclaratorAST* ast) { const auto unqualifiedId = accept(ast->unqualifiedId); - auto colonLoc = encodeSourceLocation(ast->colonLoc); - const auto [sizeExpression, sizeExpressionType] = acceptExpression(ast->sizeExpression); io::BitfieldDeclarator::Builder builder{fbb_}; builder.add_unqualified_id(unqualifiedId.o); - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_size_expression(sizeExpression); builder.add_size_expression_type( static_cast(sizeExpressionType)); @@ -4905,13 +4147,11 @@ void ASTEncoder::visit(BitfieldDeclaratorAST* ast) { } void ASTEncoder::visit(ParameterPackAST* ast) { - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - const auto [coreDeclarator, coreDeclaratorType] = acceptCoreDeclarator(ast->coreDeclarator); io::ParameterPack::Builder builder{fbb_}; - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); builder.add_core_declarator(coreDeclarator); builder.add_core_declarator_type( static_cast(coreDeclaratorType)); @@ -4924,8 +4164,6 @@ void ASTEncoder::visit(IdDeclaratorAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); @@ -4947,7 +4185,7 @@ void ASTEncoder::visit(IdDeclaratorAST* ast) { builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_template_loc(templateLoc.o); + builder.add_template_loc(ast->templateLoc.index()); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); @@ -4959,29 +4197,21 @@ void ASTEncoder::visit(IdDeclaratorAST* ast) { } void ASTEncoder::visit(NestedDeclaratorAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto declarator = accept(ast->declarator); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::NestedDeclarator::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_declarator(declarator.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::CoreDeclarator_NestedDeclarator; } void ASTEncoder::visit(FunctionDeclaratorChunkAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto parameterDeclarationClause = accept(ast->parameterDeclarationClause); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - std::vector> cvQualifierListOffsets; std::vector> cvQualifierListTypes; @@ -4995,8 +4225,6 @@ void ASTEncoder::visit(FunctionDeclaratorChunkAST* ast) { auto cvQualifierListOffsetsVector = fbb_.CreateVector(cvQualifierListOffsets); auto cvQualifierListTypesVector = fbb_.CreateVector(cvQualifierListTypes); - auto refLoc = encodeSourceLocation(ast->refLoc); - const auto [exceptionSpecifier, exceptionSpecifierType] = acceptExceptionSpecifier(ast->exceptionSpecifier); @@ -5017,12 +4245,12 @@ void ASTEncoder::visit(FunctionDeclaratorChunkAST* ast) { const auto trailingReturnType = accept(ast->trailingReturnType); io::FunctionDeclaratorChunk::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_parameter_declaration_clause(parameterDeclarationClause.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); builder.add_cv_qualifier_list(cvQualifierListOffsetsVector); builder.add_cv_qualifier_list_type(cvQualifierListTypesVector); - builder.add_ref_loc(refLoc.o); + builder.add_ref_loc(ast->refLoc.index()); builder.add_exception_specifier(exceptionSpecifier); builder.add_exception_specifier_type( static_cast(exceptionSpecifierType)); @@ -5035,12 +4263,8 @@ void ASTEncoder::visit(FunctionDeclaratorChunkAST* ast) { } void ASTEncoder::visit(ArrayDeclaratorChunkAST* ast) { - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - std::vector> attributeListOffsets; std::vector> attributeListTypes; @@ -5056,10 +4280,10 @@ void ASTEncoder::visit(ArrayDeclaratorChunkAST* ast) { auto attributeListTypesVector = fbb_.CreateVector(attributeListTypes); io::ArrayDeclaratorChunk::Builder builder{fbb_}; - builder.add_lbracket_loc(lbracketLoc.o); + builder.add_lbracket_loc(ast->lbracketLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rbracket_loc(rbracketLoc.o); + builder.add_rbracket_loc(ast->rbracketLoc.index()); builder.add_attribute_list(attributeListOffsetsVector); builder.add_attribute_list_type(attributeListTypesVector); @@ -5068,8 +4292,6 @@ void ASTEncoder::visit(ArrayDeclaratorChunkAST* ast) { } void ASTEncoder::visit(NameIdAST* ast) { - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -5081,7 +4303,7 @@ void ASTEncoder::visit(NameIdAST* ast) { } io::NameId::Builder builder{fbb_}; - builder.add_identifier_loc(identifierLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -5091,12 +4313,10 @@ void ASTEncoder::visit(NameIdAST* ast) { } void ASTEncoder::visit(DestructorIdAST* ast) { - auto tildeLoc = encodeSourceLocation(ast->tildeLoc); - const auto [id, idType] = acceptUnqualifiedId(ast->id); io::DestructorId::Builder builder{fbb_}; - builder.add_tilde_loc(tildeLoc.o); + builder.add_tilde_loc(ast->tildeLoc.index()); builder.add_id(id); builder.add_id_type(static_cast(idType)); @@ -5115,19 +4335,11 @@ void ASTEncoder::visit(DecltypeIdAST* ast) { } void ASTEncoder::visit(OperatorFunctionIdAST* ast) { - auto operatorLoc = encodeSourceLocation(ast->operatorLoc); - - auto opLoc = encodeSourceLocation(ast->opLoc); - - auto openLoc = encodeSourceLocation(ast->openLoc); - - auto closeLoc = encodeSourceLocation(ast->closeLoc); - io::OperatorFunctionId::Builder builder{fbb_}; - builder.add_operator_loc(operatorLoc.o); - builder.add_op_loc(opLoc.o); - builder.add_open_loc(openLoc.o); - builder.add_close_loc(closeLoc.o); + builder.add_operator_loc(ast->operatorLoc.index()); + builder.add_op_loc(ast->opLoc.index()); + builder.add_open_loc(ast->openLoc.index()); + builder.add_close_loc(ast->closeLoc.index()); builder.add_op(static_cast(ast->op)); offset_ = builder.Finish().Union(); @@ -5135,12 +4347,6 @@ void ASTEncoder::visit(OperatorFunctionIdAST* ast) { } void ASTEncoder::visit(LiteralOperatorIdAST* ast) { - auto operatorLoc = encodeSourceLocation(ast->operatorLoc); - - auto literalLoc = encodeSourceLocation(ast->literalLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -5152,9 +4358,9 @@ void ASTEncoder::visit(LiteralOperatorIdAST* ast) { } io::LiteralOperatorId::Builder builder{fbb_}; - builder.add_operator_loc(operatorLoc.o); - builder.add_literal_loc(literalLoc.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_operator_loc(ast->operatorLoc.index()); + builder.add_literal_loc(ast->literalLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -5164,12 +4370,10 @@ void ASTEncoder::visit(LiteralOperatorIdAST* ast) { } void ASTEncoder::visit(ConversionFunctionIdAST* ast) { - auto operatorLoc = encodeSourceLocation(ast->operatorLoc); - const auto typeId = accept(ast->typeId); io::ConversionFunctionId::Builder builder{fbb_}; - builder.add_operator_loc(operatorLoc.o); + builder.add_operator_loc(ast->operatorLoc.index()); builder.add_type_id(typeId.o); offset_ = builder.Finish().Union(); @@ -5177,10 +4381,6 @@ void ASTEncoder::visit(ConversionFunctionIdAST* ast) { } void ASTEncoder::visit(SimpleTemplateIdAST* ast) { - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto lessLoc = encodeSourceLocation(ast->lessLoc); - std::vector> templateArgumentListOffsets; std::vector> templateArgumentListTypes; @@ -5197,8 +4397,6 @@ void ASTEncoder::visit(SimpleTemplateIdAST* ast) { auto templateArgumentListTypesVector = fbb_.CreateVector(templateArgumentListTypes); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -5210,11 +4408,11 @@ void ASTEncoder::visit(SimpleTemplateIdAST* ast) { } io::SimpleTemplateId::Builder builder{fbb_}; - builder.add_identifier_loc(identifierLoc.o); - builder.add_less_loc(lessLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_less_loc(ast->lessLoc.index()); builder.add_template_argument_list(templateArgumentListOffsetsVector); builder.add_template_argument_list_type(templateArgumentListTypesVector); - builder.add_greater_loc(greaterLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -5226,8 +4424,6 @@ void ASTEncoder::visit(SimpleTemplateIdAST* ast) { void ASTEncoder::visit(LiteralOperatorTemplateIdAST* ast) { const auto literalOperatorId = accept(ast->literalOperatorId); - auto lessLoc = encodeSourceLocation(ast->lessLoc); - std::vector> templateArgumentListOffsets; std::vector> templateArgumentListTypes; @@ -5244,14 +4440,12 @@ void ASTEncoder::visit(LiteralOperatorTemplateIdAST* ast) { auto templateArgumentListTypesVector = fbb_.CreateVector(templateArgumentListTypes); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - io::LiteralOperatorTemplateId::Builder builder{fbb_}; builder.add_literal_operator_id(literalOperatorId.o); - builder.add_less_loc(lessLoc.o); + builder.add_less_loc(ast->lessLoc.index()); builder.add_template_argument_list(templateArgumentListOffsetsVector); builder.add_template_argument_list_type(templateArgumentListTypesVector); - builder.add_greater_loc(greaterLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); offset_ = builder.Finish().Union(); type_ = io::UnqualifiedId_LiteralOperatorTemplateId; @@ -5260,8 +4454,6 @@ void ASTEncoder::visit(LiteralOperatorTemplateIdAST* ast) { void ASTEncoder::visit(OperatorFunctionTemplateIdAST* ast) { const auto operatorFunctionId = accept(ast->operatorFunctionId); - auto lessLoc = encodeSourceLocation(ast->lessLoc); - std::vector> templateArgumentListOffsets; std::vector> templateArgumentListTypes; @@ -5278,24 +4470,20 @@ void ASTEncoder::visit(OperatorFunctionTemplateIdAST* ast) { auto templateArgumentListTypesVector = fbb_.CreateVector(templateArgumentListTypes); - auto greaterLoc = encodeSourceLocation(ast->greaterLoc); - io::OperatorFunctionTemplateId::Builder builder{fbb_}; builder.add_operator_function_id(operatorFunctionId.o); - builder.add_less_loc(lessLoc.o); + builder.add_less_loc(ast->lessLoc.index()); builder.add_template_argument_list(templateArgumentListOffsetsVector); builder.add_template_argument_list_type(templateArgumentListTypesVector); - builder.add_greater_loc(greaterLoc.o); + builder.add_greater_loc(ast->greaterLoc.index()); offset_ = builder.Finish().Union(); type_ = io::UnqualifiedId_OperatorFunctionTemplateId; } void ASTEncoder::visit(GlobalNestedNameSpecifierAST* ast) { - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - io::GlobalNestedNameSpecifier::Builder builder{fbb_}; - builder.add_scope_loc(scopeLoc.o); + builder.add_scope_loc(ast->scopeLoc.index()); offset_ = builder.Finish().Union(); type_ = io::NestedNameSpecifier_GlobalNestedNameSpecifier; @@ -5305,8 +4493,6 @@ void ASTEncoder::visit(SimpleNestedNameSpecifierAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -5317,17 +4503,15 @@ void ASTEncoder::visit(SimpleNestedNameSpecifierAST* ast) { } } - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - io::SimpleNestedNameSpecifier::Builder builder{fbb_}; builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_identifier_loc(identifierLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } - builder.add_scope_loc(scopeLoc.o); + builder.add_scope_loc(ast->scopeLoc.index()); offset_ = builder.Finish().Union(); type_ = io::NestedNameSpecifier_SimpleNestedNameSpecifier; @@ -5339,14 +4523,12 @@ void ASTEncoder::visit(DecltypeNestedNameSpecifierAST* ast) { const auto decltypeSpecifier = accept(ast->decltypeSpecifier); - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - io::DecltypeNestedNameSpecifier::Builder builder{fbb_}; builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); builder.add_decltype_specifier(decltypeSpecifier.o); - builder.add_scope_loc(scopeLoc.o); + builder.add_scope_loc(ast->scopeLoc.index()); offset_ = builder.Finish().Union(); type_ = io::NestedNameSpecifier_DecltypeNestedNameSpecifier; @@ -5356,43 +4538,31 @@ void ASTEncoder::visit(TemplateNestedNameSpecifierAST* ast) { const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); - auto templateLoc = encodeSourceLocation(ast->templateLoc); - const auto templateId = accept(ast->templateId); - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - io::TemplateNestedNameSpecifier::Builder builder{fbb_}; builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); - builder.add_template_loc(templateLoc.o); + builder.add_template_loc(ast->templateLoc.index()); builder.add_template_id(templateId.o); - builder.add_scope_loc(scopeLoc.o); + builder.add_scope_loc(ast->scopeLoc.index()); offset_ = builder.Finish().Union(); type_ = io::NestedNameSpecifier_TemplateNestedNameSpecifier; } void ASTEncoder::visit(DefaultFunctionBodyAST* ast) { - auto equalLoc = encodeSourceLocation(ast->equalLoc); - - auto defaultLoc = encodeSourceLocation(ast->defaultLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::DefaultFunctionBody::Builder builder{fbb_}; - builder.add_equal_loc(equalLoc.o); - builder.add_default_loc(defaultLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_equal_loc(ast->equalLoc.index()); + builder.add_default_loc(ast->defaultLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::FunctionBody_DefaultFunctionBody; } void ASTEncoder::visit(CompoundStatementFunctionBodyAST* ast) { - auto colonLoc = encodeSourceLocation(ast->colonLoc); - std::vector> memInitializerListOffsets; std::vector> memInitializerListTypes; @@ -5412,7 +4582,7 @@ void ASTEncoder::visit(CompoundStatementFunctionBodyAST* ast) { const auto statement = accept(ast->statement); io::CompoundStatementFunctionBody::Builder builder{fbb_}; - builder.add_colon_loc(colonLoc.o); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_mem_initializer_list(memInitializerListOffsetsVector); builder.add_mem_initializer_list_type(memInitializerListTypesVector); builder.add_statement(statement.o); @@ -5422,10 +4592,6 @@ void ASTEncoder::visit(CompoundStatementFunctionBodyAST* ast) { } void ASTEncoder::visit(TryStatementFunctionBodyAST* ast) { - auto tryLoc = encodeSourceLocation(ast->tryLoc); - - auto colonLoc = encodeSourceLocation(ast->colonLoc); - std::vector> memInitializerListOffsets; std::vector> memInitializerListTypes; @@ -5453,8 +4619,8 @@ void ASTEncoder::visit(TryStatementFunctionBodyAST* ast) { auto handlerListOffsetsVector = fbb_.CreateVector(handlerListOffsets); io::TryStatementFunctionBody::Builder builder{fbb_}; - builder.add_try_loc(tryLoc.o); - builder.add_colon_loc(colonLoc.o); + builder.add_try_loc(ast->tryLoc.index()); + builder.add_colon_loc(ast->colonLoc.index()); builder.add_mem_initializer_list(memInitializerListOffsetsVector); builder.add_mem_initializer_list_type(memInitializerListTypesVector); builder.add_statement(statement.o); @@ -5465,16 +4631,10 @@ void ASTEncoder::visit(TryStatementFunctionBodyAST* ast) { } void ASTEncoder::visit(DeleteFunctionBodyAST* ast) { - auto equalLoc = encodeSourceLocation(ast->equalLoc); - - auto deleteLoc = encodeSourceLocation(ast->deleteLoc); - - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::DeleteFunctionBody::Builder builder{fbb_}; - builder.add_equal_loc(equalLoc.o); - builder.add_delete_loc(deleteLoc.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_equal_loc(ast->equalLoc.index()); + builder.add_delete_loc(ast->deleteLoc.index()); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::FunctionBody_DeleteFunctionBody; @@ -5502,36 +4662,24 @@ void ASTEncoder::visit(ExpressionTemplateArgumentAST* ast) { } void ASTEncoder::visit(ThrowExceptionSpecifierAST* ast) { - auto throwLoc = encodeSourceLocation(ast->throwLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::ThrowExceptionSpecifier::Builder builder{fbb_}; - builder.add_throw_loc(throwLoc.o); - builder.add_lparen_loc(lparenLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_throw_loc(ast->throwLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::ExceptionSpecifier_ThrowExceptionSpecifier; } void ASTEncoder::visit(NoexceptSpecifierAST* ast) { - auto noexceptLoc = encodeSourceLocation(ast->noexceptLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::NoexceptSpecifier::Builder builder{fbb_}; - builder.add_noexcept_loc(noexceptLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_noexcept_loc(ast->noexceptLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::ExceptionSpecifier_NoexceptSpecifier; @@ -5540,91 +4688,69 @@ void ASTEncoder::visit(NoexceptSpecifierAST* ast) { void ASTEncoder::visit(SimpleRequirementAST* ast) { const auto [expression, expressionType] = acceptExpression(ast->expression); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::SimpleRequirement::Builder builder{fbb_}; builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Requirement_SimpleRequirement; } void ASTEncoder::visit(CompoundRequirementAST* ast) { - auto lbraceLoc = encodeSourceLocation(ast->lbraceLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto rbraceLoc = encodeSourceLocation(ast->rbraceLoc); - - auto noexceptLoc = encodeSourceLocation(ast->noexceptLoc); - - auto minusGreaterLoc = encodeSourceLocation(ast->minusGreaterLoc); - const auto typeConstraint = accept(ast->typeConstraint); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::CompoundRequirement::Builder builder{fbb_}; - builder.add_lbrace_loc(lbraceLoc.o); + builder.add_lbrace_loc(ast->lbraceLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_rbrace_loc(rbraceLoc.o); - builder.add_noexcept_loc(noexceptLoc.o); - builder.add_minus_greater_loc(minusGreaterLoc.o); + builder.add_rbrace_loc(ast->rbraceLoc.index()); + builder.add_noexcept_loc(ast->noexceptLoc.index()); + builder.add_minus_greater_loc(ast->minusGreaterLoc.index()); builder.add_type_constraint(typeConstraint.o); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Requirement_CompoundRequirement; } void ASTEncoder::visit(TypeRequirementAST* ast) { - auto typenameLoc = encodeSourceLocation(ast->typenameLoc); - const auto [nestedNameSpecifier, nestedNameSpecifierType] = acceptNestedNameSpecifier(ast->nestedNameSpecifier); const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::TypeRequirement::Builder builder{fbb_}; - builder.add_typename_loc(typenameLoc.o); + builder.add_typename_loc(ast->typenameLoc.index()); builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( static_cast(nestedNameSpecifierType)); builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Requirement_TypeRequirement; } void ASTEncoder::visit(NestedRequirementAST* ast) { - auto requiresLoc = encodeSourceLocation(ast->requiresLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto semicolonLoc = encodeSourceLocation(ast->semicolonLoc); - io::NestedRequirement::Builder builder{fbb_}; - builder.add_requires_loc(requiresLoc.o); + builder.add_requires_loc(ast->requiresLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_semicolon_loc(semicolonLoc.o); + builder.add_semicolon_loc(ast->semicolonLoc.index()); offset_ = builder.Finish().Union(); type_ = io::Requirement_NestedRequirement; } void ASTEncoder::visit(NewParenInitializerAST* ast) { - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> expressionListOffsets; std::vector> expressionListTypes; @@ -5638,13 +4764,11 @@ void ASTEncoder::visit(NewParenInitializerAST* ast) { auto expressionListOffsetsVector = fbb_.CreateVector(expressionListOffsets); auto expressionListTypesVector = fbb_.CreateVector(expressionListTypes); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::NewParenInitializer::Builder builder{fbb_}; - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression_list(expressionListOffsetsVector); builder.add_expression_list_type(expressionListTypesVector); - builder.add_rparen_loc(rparenLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::NewInitializer_NewParenInitializer; @@ -5667,8 +4791,6 @@ void ASTEncoder::visit(ParenMemInitializerAST* ast) { const auto [unqualifiedId, unqualifiedIdType] = acceptUnqualifiedId(ast->unqualifiedId); - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - std::vector> expressionListOffsets; std::vector> expressionListTypes; @@ -5682,10 +4804,6 @@ void ASTEncoder::visit(ParenMemInitializerAST* ast) { auto expressionListOffsetsVector = fbb_.CreateVector(expressionListOffsets); auto expressionListTypesVector = fbb_.CreateVector(expressionListTypes); - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - io::ParenMemInitializer::Builder builder{fbb_}; builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( @@ -5693,11 +4811,11 @@ void ASTEncoder::visit(ParenMemInitializerAST* ast) { builder.add_unqualified_id(unqualifiedId); builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); - builder.add_lparen_loc(lparenLoc.o); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression_list(expressionListOffsetsVector); builder.add_expression_list_type(expressionListTypesVector); - builder.add_rparen_loc(rparenLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_rparen_loc(ast->rparenLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); offset_ = builder.Finish().Union(); type_ = io::MemInitializer_ParenMemInitializer; @@ -5712,8 +4830,6 @@ void ASTEncoder::visit(BracedMemInitializerAST* ast) { const auto bracedInitList = accept(ast->bracedInitList); - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - io::BracedMemInitializer::Builder builder{fbb_}; builder.add_nested_name_specifier(nestedNameSpecifier); builder.add_nested_name_specifier_type( @@ -5722,40 +4838,30 @@ void ASTEncoder::visit(BracedMemInitializerAST* ast) { builder.add_unqualified_id_type( static_cast(unqualifiedIdType)); builder.add_braced_init_list(bracedInitList.o); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); offset_ = builder.Finish().Union(); type_ = io::MemInitializer_BracedMemInitializer; } void ASTEncoder::visit(ThisLambdaCaptureAST* ast) { - auto thisLoc = encodeSourceLocation(ast->thisLoc); - io::ThisLambdaCapture::Builder builder{fbb_}; - builder.add_this_loc(thisLoc.o); + builder.add_this_loc(ast->thisLoc.index()); offset_ = builder.Finish().Union(); type_ = io::LambdaCapture_ThisLambdaCapture; } void ASTEncoder::visit(DerefThisLambdaCaptureAST* ast) { - auto starLoc = encodeSourceLocation(ast->starLoc); - - auto thisLoc = encodeSourceLocation(ast->thisLoc); - io::DerefThisLambdaCapture::Builder builder{fbb_}; - builder.add_star_loc(starLoc.o); - builder.add_this_loc(thisLoc.o); + builder.add_star_loc(ast->starLoc.index()); + builder.add_this_loc(ast->thisLoc.index()); offset_ = builder.Finish().Union(); type_ = io::LambdaCapture_DerefThisLambdaCapture; } void ASTEncoder::visit(SimpleLambdaCaptureAST* ast) { - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -5767,8 +4873,8 @@ void ASTEncoder::visit(SimpleLambdaCaptureAST* ast) { } io::SimpleLambdaCapture::Builder builder{fbb_}; - builder.add_identifier_loc(identifierLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -5778,12 +4884,6 @@ void ASTEncoder::visit(SimpleLambdaCaptureAST* ast) { } void ASTEncoder::visit(RefLambdaCaptureAST* ast) { - auto ampLoc = encodeSourceLocation(ast->ampLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -5795,9 +4895,9 @@ void ASTEncoder::visit(RefLambdaCaptureAST* ast) { } io::RefLambdaCapture::Builder builder{fbb_}; - builder.add_amp_loc(ampLoc.o); - builder.add_identifier_loc(identifierLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_amp_loc(ast->ampLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } @@ -5807,12 +4907,6 @@ void ASTEncoder::visit(RefLambdaCaptureAST* ast) { } void ASTEncoder::visit(RefInitLambdaCaptureAST* ast) { - auto ampLoc = encodeSourceLocation(ast->ampLoc); - - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - const auto [initializer, initializerType] = acceptExpression(ast->initializer); @@ -5827,9 +4921,9 @@ void ASTEncoder::visit(RefInitLambdaCaptureAST* ast) { } io::RefInitLambdaCapture::Builder builder{fbb_}; - builder.add_amp_loc(ampLoc.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_amp_loc(ast->ampLoc.index()); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); builder.add_initializer(initializer); builder.add_initializer_type(static_cast(initializerType)); if (ast->identifier) { @@ -5841,10 +4935,6 @@ void ASTEncoder::visit(RefInitLambdaCaptureAST* ast) { } void ASTEncoder::visit(InitLambdaCaptureAST* ast) { - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - const auto [initializer, initializerType] = acceptExpression(ast->initializer); @@ -5859,8 +4949,8 @@ void ASTEncoder::visit(InitLambdaCaptureAST* ast) { } io::InitLambdaCapture::Builder builder{fbb_}; - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); builder.add_initializer(initializer); builder.add_initializer_type(static_cast(initializerType)); if (ast->identifier) { @@ -5872,10 +4962,8 @@ void ASTEncoder::visit(InitLambdaCaptureAST* ast) { } void ASTEncoder::visit(EllipsisExceptionDeclarationAST* ast) { - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - io::EllipsisExceptionDeclaration::Builder builder{fbb_}; - builder.add_ellipsis_loc(ellipsisLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); offset_ = builder.Finish().Union(); type_ = io::ExceptionDeclaration_EllipsisExceptionDeclaration; @@ -5924,10 +5012,6 @@ void ASTEncoder::visit(TypeExceptionDeclarationAST* ast) { } void ASTEncoder::visit(CxxAttributeAST* ast) { - auto lbracketLoc = encodeSourceLocation(ast->lbracketLoc); - - auto lbracket2Loc = encodeSourceLocation(ast->lbracket2Loc); - const auto attributeUsingPrefix = accept(ast->attributeUsingPrefix); std::vector> attributeListOffsets; @@ -5938,115 +5022,71 @@ void ASTEncoder::visit(CxxAttributeAST* ast) { auto attributeListOffsetsVector = fbb_.CreateVector(attributeListOffsets); - auto rbracketLoc = encodeSourceLocation(ast->rbracketLoc); - - auto rbracket2Loc = encodeSourceLocation(ast->rbracket2Loc); - io::CxxAttribute::Builder builder{fbb_}; - builder.add_lbracket_loc(lbracketLoc.o); - builder.add_lbracket2_loc(lbracket2Loc.o); + builder.add_lbracket_loc(ast->lbracketLoc.index()); + builder.add_lbracket2_loc(ast->lbracket2Loc.index()); builder.add_attribute_using_prefix(attributeUsingPrefix.o); builder.add_attribute_list(attributeListOffsetsVector); - builder.add_rbracket_loc(rbracketLoc.o); - builder.add_rbracket2_loc(rbracket2Loc.o); + builder.add_rbracket_loc(ast->rbracketLoc.index()); + builder.add_rbracket2_loc(ast->rbracket2Loc.index()); offset_ = builder.Finish().Union(); type_ = io::AttributeSpecifier_CxxAttribute; } void ASTEncoder::visit(GccAttributeAST* ast) { - auto attributeLoc = encodeSourceLocation(ast->attributeLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto lparen2Loc = encodeSourceLocation(ast->lparen2Loc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - - auto rparen2Loc = encodeSourceLocation(ast->rparen2Loc); - io::GccAttribute::Builder builder{fbb_}; - builder.add_attribute_loc(attributeLoc.o); - builder.add_lparen_loc(lparenLoc.o); - builder.add_lparen2_loc(lparen2Loc.o); - builder.add_rparen_loc(rparenLoc.o); - builder.add_rparen2_loc(rparen2Loc.o); + builder.add_attribute_loc(ast->attributeLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_lparen2_loc(ast->lparen2Loc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); + builder.add_rparen2_loc(ast->rparen2Loc.index()); offset_ = builder.Finish().Union(); type_ = io::AttributeSpecifier_GccAttribute; } void ASTEncoder::visit(AlignasAttributeAST* ast) { - auto alignasLoc = encodeSourceLocation(ast->alignasLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto [expression, expressionType] = acceptExpression(ast->expression); - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::AlignasAttribute::Builder builder{fbb_}; - builder.add_alignas_loc(alignasLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_alignas_loc(ast->alignasLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_expression(expression); builder.add_expression_type(static_cast(expressionType)); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::AttributeSpecifier_AlignasAttribute; } void ASTEncoder::visit(AlignasTypeAttributeAST* ast) { - auto alignasLoc = encodeSourceLocation(ast->alignasLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - const auto typeId = accept(ast->typeId); - auto ellipsisLoc = encodeSourceLocation(ast->ellipsisLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::AlignasTypeAttribute::Builder builder{fbb_}; - builder.add_alignas_loc(alignasLoc.o); - builder.add_lparen_loc(lparenLoc.o); + builder.add_alignas_loc(ast->alignasLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); builder.add_type_id(typeId.o); - builder.add_ellipsis_loc(ellipsisLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_ellipsis_loc(ast->ellipsisLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::AttributeSpecifier_AlignasTypeAttribute; } void ASTEncoder::visit(AsmAttributeAST* ast) { - auto asmLoc = encodeSourceLocation(ast->asmLoc); - - auto lparenLoc = encodeSourceLocation(ast->lparenLoc); - - auto literalLoc = encodeSourceLocation(ast->literalLoc); - - auto rparenLoc = encodeSourceLocation(ast->rparenLoc); - io::AsmAttribute::Builder builder{fbb_}; - builder.add_asm_loc(asmLoc.o); - builder.add_lparen_loc(lparenLoc.o); - builder.add_literal_loc(literalLoc.o); - builder.add_rparen_loc(rparenLoc.o); + builder.add_asm_loc(ast->asmLoc.index()); + builder.add_lparen_loc(ast->lparenLoc.index()); + builder.add_literal_loc(ast->literalLoc.index()); + builder.add_rparen_loc(ast->rparenLoc.index()); offset_ = builder.Finish().Union(); type_ = io::AttributeSpecifier_AsmAttribute; } void ASTEncoder::visit(ScopedAttributeTokenAST* ast) { - auto attributeNamespaceLoc = encodeSourceLocation(ast->attributeNamespaceLoc); - - auto scopeLoc = encodeSourceLocation(ast->scopeLoc); - - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset attributeNamespace; if (ast->attributeNamespace) { if (identifiers_.contains(ast->attributeNamespace)) { @@ -6068,9 +5108,9 @@ void ASTEncoder::visit(ScopedAttributeTokenAST* ast) { } io::ScopedAttributeToken::Builder builder{fbb_}; - builder.add_attribute_namespace_loc(attributeNamespaceLoc.o); - builder.add_scope_loc(scopeLoc.o); - builder.add_identifier_loc(identifierLoc.o); + builder.add_attribute_namespace_loc(ast->attributeNamespaceLoc.index()); + builder.add_scope_loc(ast->scopeLoc.index()); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->attributeNamespace) { builder.add_attribute_namespace(attributeNamespace); } @@ -6083,8 +5123,6 @@ void ASTEncoder::visit(ScopedAttributeTokenAST* ast) { } void ASTEncoder::visit(SimpleAttributeTokenAST* ast) { - auto identifierLoc = encodeSourceLocation(ast->identifierLoc); - flatbuffers::Offset identifier; if (ast->identifier) { if (identifiers_.contains(ast->identifier)) { @@ -6096,7 +5134,7 @@ void ASTEncoder::visit(SimpleAttributeTokenAST* ast) { } io::SimpleAttributeToken::Builder builder{fbb_}; - builder.add_identifier_loc(identifierLoc.o); + builder.add_identifier_loc(ast->identifierLoc.index()); if (ast->identifier) { builder.add_identifier(identifier); } diff --git a/src/parser/cxx/preprocessor.cc b/src/parser/cxx/preprocessor.cc index 83b87f3f..8c43c9fc 100644 --- a/src/parser/cxx/preprocessor.cc +++ b/src/parser/cxx/preprocessor.cc @@ -3199,6 +3199,15 @@ void Preprocessor::printMacros(std::ostream &out) const { } } +auto Preprocessor::sources() const -> std::vector { + std::vector sources; + for (const auto &sourceFile : d->sourceFiles_) { + sources.push_back(Source{.fileName = sourceFile->fileName, + .lineOffsets = sourceFile->lines}); + } + return sources; +} + auto Preprocessor::tokenStartPosition(const Token &token) const -> SourcePosition { if (token.fileId() == 0) { diff --git a/src/parser/cxx/preprocessor.h b/src/parser/cxx/preprocessor.h index f49d0a77..49dc13e0 100644 --- a/src/parser/cxx/preprocessor.h +++ b/src/parser/cxx/preprocessor.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -102,6 +103,13 @@ class Preprocessor { void printMacros(std::ostream &out) const; + struct Source { + std::string_view fileName; + std::span lineOffsets; + }; + + [[nodiscard]] auto sources() const -> std::vector; + [[nodiscard]] auto tokenStartPosition(const Token &token) const -> SourcePosition; diff --git a/src/parser/cxx/private/ast_encoder.h b/src/parser/cxx/private/ast_encoder.h index e18a7290..0d2aa57c 100644 --- a/src/parser/cxx/private/ast_encoder.h +++ b/src/parser/cxx/private/ast_encoder.h @@ -40,21 +40,12 @@ class ASTEncoder : ASTVisitor { using Table = std::unordered_map>; - using SourceFiles = - std::unordered_map>; - - using SourceLines = std::map, - flatbuffers::Offset>; - TranslationUnit* unit_ = nullptr; Table identifiers_; Table charLiterals_; Table stringLiterals_; Table integerLiterals_; Table floatLiterals_; - SourceFiles sourceFiles_; - SourceLines sourceLines_; flatbuffers::FlatBufferBuilder fbb_; flatbuffers::Offset<> offset_; std::uint32_t type_ = 0; @@ -65,8 +56,6 @@ class ASTEncoder : ASTVisitor { auto operator()(TranslationUnit* unit) -> std::span; private: - auto encodeSourceLocation(const SourceLocation& loc) -> flatbuffers::Offset<>; - auto accept(AST* ast) -> flatbuffers::Offset<>; auto acceptUnit(UnitAST* ast) diff --git a/src/parser/cxx/token.h b/src/parser/cxx/token.h index c195bb14..4852741b 100644 --- a/src/parser/cxx/token.h +++ b/src/parser/cxx/token.h @@ -97,13 +97,20 @@ class Token { [[nodiscard]] auto isBuiltinTypeTrait() const -> bool; [[nodiscard]] auto builtinTypeTrait() const -> BuiltinTypeTraitKind; + [[nodiscard]] auto raw() const -> std::uint64_t { return raw_; } + private: - std::uint64_t kind_ : 8; - std::uint64_t startOfLine_ : 1; - std::uint64_t leadingSpace_ : 1; - std::uint64_t fileId_ : 12; - std::uint64_t length_ : 17; - std::uint64_t offset_ : 25; + union { + struct { + std::uint64_t kind_ : 8; + std::uint64_t startOfLine_ : 1; + std::uint64_t leadingSpace_ : 1; + std::uint64_t fileId_ : 12; + std::uint64_t length_ : 17; + std::uint64_t offset_ : 25; + }; + std::uint64_t raw_; + }; TokenValue value_; };