@@ -576,10 +576,12 @@ bool Parser::rDefinition(cpp_itemt &item)
576
576
return rNamespaceSpec (item.make_namespace_spec ());
577
577
else if (t==TOK_INLINE && lex.LookAhead (1 )==TOK_NAMESPACE)
578
578
return rNamespaceSpec (item.make_namespace_spec ());
579
- else if (t==TOK_USING &&
580
- is_identifier (lex.LookAhead (1 )) &&
581
- lex.LookAhead (2 )==' =' )
579
+ else if (
580
+ t == TOK_USING && is_identifier (lex.LookAhead (1 )) &&
581
+ lex.LookAhead (2 ) == ' =' )
582
+ {
582
583
return rTypedefUsing (item.make_declaration ());
584
+ }
583
585
else if (t==TOK_USING)
584
586
return rUsing (item.make_using ());
585
587
else if (t==TOK_STATIC_ASSERT)
@@ -759,27 +761,19 @@ bool Parser::isTypeSpecifier()
759
761
{
760
762
int t=lex.LookAhead (0 );
761
763
762
- if (is_identifier (t) || t==TOK_SCOPE
763
- || t==TOK_CONSTEXPR || t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT
764
- || t==TOK_CHAR || t==TOK_INT || t==TOK_SHORT || t==TOK_LONG
765
- || t==TOK_CHAR16_T || t==TOK_CHAR32_T
766
- || t==TOK_WCHAR_T || t==TOK_COMPLEX // new !!!
767
- || t==TOK_SIGNED || t==TOK_UNSIGNED || t==TOK_FLOAT || t==TOK_DOUBLE
768
- || t==TOK_INT8 || t==TOK_INT16 || t==TOK_INT32 || t==TOK_INT64
769
- || t==TOK_GCC_INT128
770
- || t==TOK_PTR32 || t==TOK_PTR64
771
- || t==TOK_GCC_FLOAT80 || t==TOK_GCC_FLOAT128
772
- || t==TOK_VOID || t==TOK_BOOL || t==TOK_CPROVER_BOOL
773
- || t==TOK_CLASS || t==TOK_STRUCT || t==TOK_UNION || t==TOK_ENUM
774
- || t==TOK_INTERFACE
775
- || t==TOK_TYPENAME
776
- || t==TOK_TYPEOF
777
- || t==TOK_DECLTYPE
778
- || t==TOK_UNDERLYING_TYPE
779
- )
780
- return true ;
781
-
782
- return false ;
764
+ return is_identifier (t) || t == TOK_SCOPE || t == TOK_CONSTEXPR ||
765
+ t == TOK_CONST || t == TOK_VOLATILE || t == TOK_RESTRICT ||
766
+ t == TOK_CHAR || t == TOK_INT || t == TOK_SHORT || t == TOK_LONG ||
767
+ t == TOK_CHAR16_T || t == TOK_CHAR32_T || t == TOK_WCHAR_T ||
768
+ t == TOK_COMPLEX // new !!!
769
+ || t == TOK_SIGNED || t == TOK_UNSIGNED || t == TOK_FLOAT ||
770
+ t == TOK_DOUBLE || t == TOK_INT8 || t == TOK_INT16 || t == TOK_INT32 ||
771
+ t == TOK_INT64 || t == TOK_GCC_INT128 || t == TOK_PTR32 ||
772
+ t == TOK_PTR64 || t == TOK_GCC_FLOAT80 || t == TOK_GCC_FLOAT128 ||
773
+ t == TOK_VOID || t == TOK_BOOL || t == TOK_CPROVER_BOOL ||
774
+ t == TOK_CLASS || t == TOK_STRUCT || t == TOK_UNION || t == TOK_ENUM ||
775
+ t == TOK_INTERFACE || t == TOK_TYPENAME || t == TOK_TYPEOF ||
776
+ t == TOK_DECLTYPE || t == TOK_UNDERLYING_TYPE;
783
777
}
784
778
785
779
/*
@@ -1250,8 +1244,7 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
1250
1244
1251
1245
cpp_tokent tk1, tk2;
1252
1246
1253
- if (lex.get_token (tk1)!=TOK_CLASS ||
1254
- !is_identifier (lex.get_token (tk2)))
1247
+ if (lex.get_token (tk1) != TOK_CLASS || !is_identifier (lex.get_token (tk2)))
1255
1248
return false ;
1256
1249
1257
1250
// Ptree cspec=new PtreeClassSpec(new LeafReserved(tk1),
@@ -1465,9 +1458,12 @@ bool Parser::rDeclaration(cpp_declarationt &declaration)
1465
1458
<< ' \n ' ;
1466
1459
#endif
1467
1460
1468
- if (cv_q.is_not_nil () &&
1469
- ((is_identifier (t) && lex.LookAhead (1 )==' =' ) || t==' *' ))
1461
+ if (
1462
+ cv_q.is_not_nil () &&
1463
+ ((is_identifier (t) && lex.LookAhead (1 ) == ' =' ) || t == ' *' ))
1464
+ {
1470
1465
return rConstDeclaration (declaration);
1466
+ }
1471
1467
else
1472
1468
return rOtherDeclaration (declaration, storage_spec, member_spec, cv_q);
1473
1469
}
@@ -3083,8 +3079,9 @@ bool Parser::rDeclarator(
3083
3079
d_inner.swap (declarator2.type ());
3084
3080
name.swap (declarator2.name ());
3085
3081
}
3086
- else if (kind!=kCastDeclarator &&
3087
- (kind==kDeclarator || is_identifier (t) || t==TOK_SCOPE))
3082
+ else if (
3083
+ kind != kCastDeclarator &&
3084
+ (kind == kDeclarator || is_identifier (t) || t == TOK_SCOPE))
3088
3085
{
3089
3086
#ifdef DEBUG
3090
3087
std::cout << std::string (__indent, ' ' ) << " Parser::rDeclarator2 6\n " ;
@@ -3832,29 +3829,29 @@ bool Parser::rPtrToMember(irept &ptr_to_mem)
3832
3829
}
3833
3830
break ;
3834
3831
3835
- case TOK_GCC_IDENTIFIER:
3836
- case TOK_MSC_IDENTIFIER:
3837
- lex.get_token (tk);
3838
- components.push_back (cpp_namet::namet (tk.data .get (ID_C_base_name)));
3839
- set_location (components.back (), tk);
3840
-
3841
- {
3842
- int t=lex.LookAhead (0 );
3843
- if (t!=TOK_SCOPE && t!=' <' )
3844
- return false ;
3845
- }
3846
- break ;
3832
+ case TOK_GCC_IDENTIFIER:
3833
+ case TOK_MSC_IDENTIFIER:
3834
+ lex.get_token (tk);
3835
+ components.push_back (cpp_namet::namet (tk.data .get (ID_C_base_name)));
3836
+ set_location (components.back (), tk);
3847
3837
3848
- case TOK_SCOPE:
3849
- lex.get_token (tk);
3850
- components.push_back (irept (" ::" ));
3851
- set_location (components.back (), tk);
3838
+ {
3839
+ int t = lex.LookAhead (0 );
3840
+ if (t != TOK_SCOPE && t != ' <' )
3841
+ return false ;
3842
+ }
3843
+ break ;
3852
3844
3853
- // done if next token is '*'
3854
- if (lex.LookAhead (0 ) == ' *' )
3855
- {
3845
+ case TOK_SCOPE:
3856
3846
lex.get_token (tk);
3857
- ptr_to_mem.swap (ptm);
3847
+ components.push_back (irept (" ::" ));
3848
+ set_location (components.back (), tk);
3849
+
3850
+ // done if next token is '*'
3851
+ if (lex.LookAhead (0 ) == ' *' )
3852
+ {
3853
+ lex.get_token (tk);
3854
+ ptr_to_mem.swap (ptm);
3858
3855
3859
3856
#ifdef DEBUG
3860
3857
std::cout << std::string (__indent, ' ' ) << " Parser::rPtrToMember 1\n " ;
@@ -4727,10 +4724,12 @@ bool Parser::rClassMember(cpp_itemt &member)
4727
4724
return rTypedef (member.make_declaration ());
4728
4725
else if (t==TOK_TEMPLATE)
4729
4726
return rTemplateDecl (member.make_declaration ());
4730
- else if (t==TOK_USING &&
4731
- is_identifier (lex.LookAhead (1 )) &&
4732
- lex.LookAhead (2 )==' =' )
4727
+ else if (
4728
+ t == TOK_USING && is_identifier (lex.LookAhead (1 )) &&
4729
+ lex.LookAhead (2 ) == ' =' )
4730
+ {
4733
4731
return rTypedefUsing (member.make_declaration ());
4732
+ }
4734
4733
else if (t==TOK_USING)
4735
4734
return rUsing (member.make_using ());
4736
4735
else if (t==TOK_STATIC_ASSERT)
@@ -5584,31 +5583,29 @@ bool Parser::rTypeNameOrFunctionType(typet &tname)
5584
5583
// TODO -- cruel hack for Clang's type_traits:
5585
5584
// struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...),
5586
5585
// true, false>
5587
- if (is_identifier (lex.LookAhead (0 )) &&
5588
- lex.LookAhead (1 )==TOK_SCOPE &&
5589
- lex.LookAhead (2 )==' *' &&
5590
- lex.LookAhead (3 )==' )' &&
5591
- lex.LookAhead (4 )==' (' )
5586
+ if (
5587
+ is_identifier (lex.LookAhead (0 )) && lex.LookAhead (1 ) == TOK_SCOPE &&
5588
+ lex.LookAhead (2 ) == ' *' && lex.LookAhead (3 ) == ' )' &&
5589
+ lex.LookAhead (4 ) == ' (' )
5592
5590
{
5593
5591
lex.get_token ();
5594
5592
lex.get_token ();
5595
5593
lex.get_token ();
5596
5594
lex.get_token ();
5597
5595
lex.get_token ();
5598
5596
}
5599
- else if (is_identifier (lex. LookAhead ( 0 )) &&
5600
- lex.LookAhead (1 )== ' )' &&
5601
- lex.LookAhead (2 )== ' (' )
5597
+ else if (
5598
+ is_identifier (lex. LookAhead ( 0 )) && lex.LookAhead (1 ) == ' )' &&
5599
+ lex.LookAhead (2 ) == ' (' )
5602
5600
{
5603
5601
lex.get_token (op);
5604
5602
type.set (ID_identifier, op.data .get (ID_C_base_name));
5605
5603
lex.get_token ();
5606
5604
lex.get_token ();
5607
5605
}
5608
- else if (lex.LookAhead (0 )==' *' &&
5609
- is_identifier (lex.LookAhead (1 )) &&
5610
- lex.LookAhead (2 )==' )' &&
5611
- lex.LookAhead (3 )==' (' )
5606
+ else if (
5607
+ lex.LookAhead (0 ) == ' *' && is_identifier (lex.LookAhead (1 )) &&
5608
+ lex.LookAhead (2 ) == ' )' && lex.LookAhead (3 ) == ' (' )
5612
5609
{
5613
5610
lex.get_token (op);
5614
5611
lex.get_token (op);
@@ -7076,7 +7073,7 @@ bool Parser::moreVarName()
7076
7073
if (lex.LookAhead (0 )==TOK_SCOPE)
7077
7074
{
7078
7075
int t=lex.LookAhead (1 );
7079
- if (is_identifier (t) || t== ' ~' || t== TOK_OPERATOR || t== TOK_TEMPLATE)
7076
+ if (is_identifier (t) || t == ' ~' || t == TOK_OPERATOR || t == TOK_TEMPLATE)
7080
7077
return true ;
7081
7078
}
7082
7079
@@ -7507,8 +7504,7 @@ optionalt<codet> Parser::rStatement()
7507
7504
7508
7505
case TOK_USING:
7509
7506
{
7510
- if (is_identifier (lex.LookAhead (1 )) &&
7511
- lex.LookAhead (2 )==' =' )
7507
+ if (is_identifier (lex.LookAhead (1 )) && lex.LookAhead (2 ) == ' =' )
7512
7508
{
7513
7509
cpp_declarationt declaration;
7514
7510
if (!rTypedefUsing (declaration))
@@ -8238,8 +8234,9 @@ optionalt<codet> Parser::rDeclarationStatement()
8238
8234
<< " Parser::rDeclarationStatement 3 " << t << ' \n ' ;
8239
8235
#endif
8240
8236
8241
- if (cv_q.is_not_nil () &&
8242
- ((is_identifier (t) && lex.LookAhead (1 )==' =' ) || t==' *' ))
8237
+ if (
8238
+ cv_q.is_not_nil () &&
8239
+ ((is_identifier (t) && lex.LookAhead (1 ) == ' =' ) || t == ' *' ))
8243
8240
{
8244
8241
#ifdef DEBUG
8245
8242
std::cout << std::string (__indent, ' ' )
0 commit comments