@@ -268,10 +268,8 @@ auto Parser::expect(TokenKind tk, SourceLocation& location) -> bool {
268268
269269void Parser::operator ()(UnitAST*& ast) { parse (ast); }
270270
271- auto Parser::config () const -> const ParserConfiguration& { return config_; }
272-
273- void Parser::setConfig (ParserConfiguration config) {
274- config_ = std::move (config);
271+ auto Parser::config () const -> const ParserConfiguration& {
272+ return unit->config ();
275273}
276274
277275void Parser::parse (UnitAST*& ast) { parse_translation_unit (ast); }
@@ -676,7 +674,7 @@ auto Parser::parse_completion(SourceLocation& loc) -> bool {
676674 if (didAcceptCompletionToken_) return false ;
677675
678676 // if there is no completer, return false
679- if (!config_ .complete ) return false ;
677+ if (!config () .complete ) return false ;
680678
681679 if (!match (TokenKind::T_CODE_COMPLETION, loc)) return false ;
682680
@@ -709,7 +707,7 @@ auto Parser::parse_primary_expression(ExpressionAST*& yyast,
709707}
710708
711709auto Parser::parse_splicer (SplicerAST*& yyast) -> bool {
712- if (!config_ .reflect ) return false ;
710+ if (!config () .reflect ) return false ;
713711
714712 if (!lookat (TokenKind::T_LBRACKET, TokenKind::T_COLON)) return false ;
715713
@@ -729,7 +727,7 @@ auto Parser::parse_splicer(SplicerAST*& yyast) -> bool {
729727
730728auto Parser::parse_splicer_expression (ExpressionAST*& yyast,
731729 const ExprContext& ctx) -> bool {
732- if (!config_ .reflect ) return false ;
730+ if (!config () .reflect ) return false ;
733731
734732 SplicerAST* splicer = nullptr ;
735733 if (!parse_splicer (splicer)) return false ;
@@ -741,7 +739,7 @@ auto Parser::parse_splicer_expression(ExpressionAST*& yyast,
741739
742740auto Parser::parse_reflect_expression (ExpressionAST*& yyast,
743741 const ExprContext& ctx) -> bool {
744- if (!config_ .reflect ) return false ;
742+ if (!config () .reflect ) return false ;
745743
746744 SourceLocation caretLoc;
747745
@@ -1054,7 +1052,7 @@ auto Parser::parse_template_nested_name_specifier(
10541052 }
10551053 }
10561054
1057- if (!ast->symbol && config_ .checkTypes ) {
1055+ if (!ast->symbol && config () .checkTypes ) {
10581056 ast->symbol = binder_.instantiate (templateId);
10591057 }
10601058
@@ -1859,7 +1857,7 @@ auto Parser::parse_member_expression(ExpressionAST*& yyast) -> bool {
18591857 auto objectType = ast->baseExpression ->type ;
18601858
18611859 // trigger the completion
1862- config_ .complete (MemberCompletionContext{
1860+ config () .complete (MemberCompletionContext{
18631861 .objectType = objectType,
18641862 .accessOp = ast->accessOp ,
18651863 });
@@ -4082,7 +4080,7 @@ auto Parser::parse_simple_declaration(
40824080
40834081 if (auto scope = decl.getScope ()) {
40844082 setScope (scope);
4085- } else if (q && config_ .checkTypes ) {
4083+ } else if (q && config () .checkTypes ) {
40864084 parse_error (q->firstSourceLocation (),
40874085 std::format (" unresolved class or namespace" ));
40884086 }
@@ -4091,7 +4089,7 @@ auto Parser::parse_simple_declaration(
40914089 auto functionSymbol = getFunction (scope (), functionName, functionType);
40924090
40934091 if (!functionSymbol) {
4094- if (q && config_ .checkTypes ) {
4092+ if (q && config () .checkTypes ) {
40954093 parse_error (q->firstSourceLocation (),
40964094 std::format (" class or namespace has no member named '{}'" ,
40974095 to_string (functionName)));
@@ -4196,7 +4194,7 @@ auto Parser::parse_notypespec_function_definition(
41964194 if (auto scope = decl.getScope ()) {
41974195 setScope (scope);
41984196 } else if (auto q = decl.getNestedNameSpecifier ()) {
4199- if (config_ .checkTypes ) {
4197+ if (config () .checkTypes ) {
42004198 parse_error (q->firstSourceLocation (),
42014199 std::format (" unresolved class or namespace" ));
42024200 }
@@ -4325,7 +4323,7 @@ auto Parser::parse_static_assert_declaration(DeclarationAST*& yyast) -> bool {
43254323 value = visit (to_bool, *constValue);
43264324 }
43274325
4328- if (!value && config_ .checkTypes ) {
4326+ if (!value && config () .checkTypes ) {
43294327 SourceLocation loc = ast->firstSourceLocation ();
43304328
43314329 if (!ast->expression || !constValue.has_value ()) {
@@ -4847,12 +4845,12 @@ auto Parser::parse_named_type_specifier(SpecifierAST*& yyast, DeclSpecs& specs)
48474845 if (conceptSymbol && !lookat (TokenKind::T_AUTO)) return false ;
48484846 }
48494847
4850- const auto canInstantiate = config_ .checkTypes ;
4848+ const auto canInstantiate = config () .checkTypes ;
48514849
48524850 auto symbol =
48534851 binder_.resolve (nestedNameSpecifier, unqualifiedId, canInstantiate);
48544852
4855- if (config_ .checkTypes && !symbol && ast_cast<NameIdAST>(unqualifiedId)) {
4853+ if (config () .checkTypes && !symbol && ast_cast<NameIdAST>(unqualifiedId)) {
48564854 return false ;
48574855 }
48584856
@@ -4987,14 +4985,14 @@ auto Parser::parse_primitive_type_specifier(SpecifierAST*& yyast,
49874985}
49884986
49894987auto Parser::maybe_template_name (const Identifier* id) -> bool {
4990- if (!config_ .fuzzyTemplateResolution ) return true ;
4988+ if (!config () .fuzzyTemplateResolution ) return true ;
49914989 if (template_names_.contains (id)) return true ;
49924990 if (concept_names_.contains (id)) return true ;
49934991 return false ;
49944992}
49954993
49964994void Parser::mark_maybe_template_name (const Identifier* id) {
4997- if (!config_ .fuzzyTemplateResolution ) return ;
4995+ if (!config () .fuzzyTemplateResolution ) return ;
49984996 if (!id) return ;
49994997 template_names_.insert (id);
50004998}
@@ -5314,7 +5312,7 @@ auto Parser::parse_declarator(DeclaratorAST*& yyast, Decl& decl,
53145312
53155313 if (auto scope = decl.getScope ()) {
53165314 setScope (scope);
5317- } else if (q && config_ .checkTypes ) {
5315+ } else if (q && config () .checkTypes ) {
53185316 parse_error (q->firstSourceLocation (),
53195317 std::format (" unresolved class or namespace" ));
53205318 }
@@ -9041,7 +9039,7 @@ auto Parser::parse_concept_definition(DeclarationAST*& yyast) -> bool {
90419039
90429040auto Parser::parse_splicer_specifier (SpecifierAST*& yyast, DeclSpecs& specs)
90439041 -> bool {
9044- if (!config_ .reflect ) return false ;
9042+ if (!config () .reflect ) return false ;
90459043 if (specs.typeSpecifier ) return false ;
90469044 LookaheadParser lookahead{this };
90479045 SourceLocation typenameLoc;
@@ -9391,7 +9389,7 @@ void Parser::check(ExpressionAST* ast) {
93919389 if (binder_.inTemplate ()) return ;
93929390 TypeChecker check{unit};
93939391 check.setScope (scope ());
9394- check.setReportErrors (config_ .checkTypes );
9392+ check.setReportErrors (config () .checkTypes );
93959393 check (ast);
93969394}
93979395
0 commit comments