Skip to content

Commit 1fa9825

Browse files
committed
CXX: extract reference tags
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent 99d7fc5 commit 1fa9825

File tree

16 files changed

+118
-11
lines changed

16 files changed

+118
-11
lines changed

Tmain/list-kinds-full.d/stdout-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
22
D macroparam no no 0 C parameters inside macro definitions
33
L label no no 0 C goto labels
4+
Y unknown no yes 1 C unknown identifier
45
d macro yes no 2 C macro definitions
56
e enumerator yes no 0 C enumerators (values inside an enumeration)
67
f function yes no 0 C function definitions
@@ -21,6 +22,7 @@ D macroparam no no 0 C parameters inside macro definitions
2122
L label no no 0 C goto labels
2223
N name no no 0 NONE names imported via using scope::symbol
2324
U using no no 0 NONE using namespace statements
25+
Y unknown no yes 1 C unknown identifier
2426
Z tparam no no 0 NONE template parameters
2527
c class yes no 0 NONE classes
2628
d macro yes no 2 C macro definitions

Tmain/list-roles.d/stdout-expected.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ Automake d/directory program on directory for PROGRA
1818
Automake d/directory script on directory for SCRIPTS primary
1919
Basic f/function decl on declared
2020
Bats S/script loaded on script loaed with "load" command
21+
C Y/unknown ref off referenced anyhow
2122
C d/macro condition off used in part of #if/#ifdef/#elif conditions
2223
C d/macro undef on undefined
2324
C h/header local on local header
2425
C h/header system on system header
26+
C++ Y/unknown ref off referenced anyhow
2527
C++ d/macro condition off used in part of #if/#ifdef/#elif conditions
2628
C++ d/macro undef on undefined
2729
C++ h/header local on local header
@@ -30,6 +32,7 @@ CPreProcessor d/macro condition off used in part of #if/
3032
CPreProcessor d/macro undef on undefined
3133
CPreProcessor h/header local on local header
3234
CPreProcessor h/header system on system header
35+
CUDA Y/unknown ref off referenced anyhow
3336
CUDA d/macro condition off used in part of #if/#ifdef/#elif conditions
3437
CUDA d/macro undef on undefined
3538
CUDA h/header local on local header
@@ -136,10 +139,12 @@ Automake d/directory program on directory for PROGRA
136139
Automake d/directory script on directory for SCRIPTS primary
137140
Basic f/function decl on declared
138141
Bats S/script loaded on script loaed with "load" command
142+
C Y/unknown ref off referenced anyhow
139143
C d/macro condition off used in part of #if/#ifdef/#elif conditions
140144
C d/macro undef on undefined
141145
C h/header local on local header
142146
C h/header system on system header
147+
C++ Y/unknown ref off referenced anyhow
143148
C++ d/macro condition off used in part of #if/#ifdef/#elif conditions
144149
C++ d/macro undef on undefined
145150
C++ h/header local on local header
@@ -148,6 +153,7 @@ CPreProcessor d/macro condition off used in part of #if/
148153
CPreProcessor d/macro undef on undefined
149154
CPreProcessor h/header local on local header
150155
CPreProcessor h/header system on system header
156+
CUDA Y/unknown ref off referenced anyhow
151157
CUDA d/macro condition off used in part of #if/#ifdef/#elif conditions
152158
CUDA d/macro undef on undefined
153159
CUDA h/header local on local header
@@ -239,6 +245,7 @@ Zsh s/script loaded on loaded
239245
# C.*
240246
#
241247
#KIND(L/N) NAME ENABLED DESCRIPTION
248+
Y/unknown ref off referenced anyhow
242249
d/macro condition off used in part of #if/#ifdef/#elif conditions
243250
d/macro undef on undefined
244251
h/header local on local header
@@ -276,6 +283,7 @@ s/script loaded on loaded
276283
# C.* with disabling all roles of all languages
277284
#
278285
#KIND(L/N) NAME ENABLED DESCRIPTION
286+
Y/unknown ref off referenced anyhow
279287
d/macro condition off used in part of #if/#ifdef/#elif conditions
280288
d/macro undef off undefined
281289
h/header local off local header
@@ -285,6 +293,7 @@ h/header system off system header
285293
# C.* with disabling all roles of all kinds of all languages
286294
#
287295
#KIND(L/N) NAME ENABLED DESCRIPTION
296+
Y/unknown ref off referenced anyhow
288297
d/macro condition off used in part of #if/#ifdef/#elif conditions
289298
d/macro undef off undefined
290299
h/header local off local header
@@ -295,6 +304,7 @@ h/header system off system header
295304
# after disabling system role of header kind of C language
296305
#
297306
#KIND(L/N) NAME ENABLED DESCRIPTION
307+
Y/unknown ref on referenced anyhow
298308
d/macro condition on used in part of #if/#ifdef/#elif conditions
299309
d/macro undef on undefined
300310
h/header local on local header
@@ -305,6 +315,7 @@ h/header system on system header
305315
# after disabling system role of header kind of C language
306316
#
307317
#KIND(L/N) NAME ENABLED DESCRIPTION
318+
Y/unknown ref on referenced anyhow
308319
d/macro condition on used in part of #if/#ifdef/#elif conditions
309320
d/macro undef on undefined
310321
h/header local on local header
@@ -314,6 +325,7 @@ h/header system on system header
314325
# C.* with disabling all roles in C language
315326
#
316327
#KIND(L/N) NAME ENABLED DESCRIPTION
328+
Y/unknown ref off referenced anyhow
317329
d/macro condition off used in part of #if/#ifdef/#elif conditions
318330
d/macro undef off undefined
319331
h/header local off local header
@@ -330,6 +342,7 @@ s/script loaded on loaded
330342
# C.* with disabling all roles of all kinds in C language
331343
#
332344
#KIND(L/N) NAME ENABLED DESCRIPTION
345+
Y/unknown ref off referenced anyhow
333346
d/macro condition off used in part of #if/#ifdef/#elif conditions
334347
d/macro undef off undefined
335348
h/header local off local header
@@ -347,6 +360,7 @@ s/script loaded on loaded
347360
# after disabling all roles in all languages
348361
#
349362
#KIND(L/N) NAME ENABLED DESCRIPTION
363+
Y/unknown ref on referenced anyhow
350364
d/macro condition on used in part of #if/#ifdef/#elif conditions
351365
d/macro undef on undefined
352366
h/header local on local header
@@ -365,6 +379,7 @@ s/script loaded off loaded
365379
# after disabling all roles in all languages
366380
#
367381
#KIND(L/N) NAME ENABLED DESCRIPTION
382+
Y/unknown ref on referenced anyhow
368383
d/macro condition on used in part of #if/#ifdef/#elif conditions
369384
d/macro undef on undefined
370385
h/header local on local header
@@ -382,6 +397,7 @@ s/script loaded off loaded
382397
# C.* with disabling all roles of {header} kind in C language
383398
#
384399
#KIND(L/N) NAME ENABLED DESCRIPTION
400+
Y/unknown ref off referenced anyhow
385401
d/macro condition off used in part of #if/#ifdef/#elif conditions
386402
d/macro undef on undefined
387403
h/header local off local header
@@ -398,6 +414,7 @@ s/script loaded on loaded
398414
# C.* with disabling all roles of h kind in C language
399415
#
400416
#KIND(L/N) NAME ENABLED DESCRIPTION
417+
Y/unknown ref off referenced anyhow
401418
d/macro condition off used in part of #if/#ifdef/#elif conditions
402419
d/macro undef on undefined
403420
h/header local off local header
@@ -415,6 +432,7 @@ s/script loaded on loaded
415432
# after disabling all roles in all languages
416433
#
417434
#KIND(L/N) NAME ENABLED DESCRIPTION
435+
Y/unknown ref off referenced anyhow
418436
d/macro condition off used in part of #if/#ifdef/#elif conditions
419437
d/macro undef off undefined
420438
h/header local on local header
@@ -433,6 +451,7 @@ s/script loaded off loaded
433451
# after disabling all roles in all languages
434452
#
435453
#KIND(L/N) NAME ENABLED DESCRIPTION
454+
Y/unknown ref off referenced anyhow
436455
d/macro condition off used in part of #if/#ifdef/#elif conditions
437456
d/macro undef off undefined
438457
h/header local on local header
@@ -450,6 +469,7 @@ s/script loaded off loaded
450469
# C.* with disabling system role of h kind
451470
#
452471
#KIND(L/N) NAME ENABLED DESCRIPTION
472+
Y/unknown ref off referenced anyhow
453473
d/macro condition off used in part of #if/#ifdef/#elif conditions
454474
d/macro undef on undefined
455475
h/header local on local header
@@ -459,6 +479,7 @@ h/header system off system header
459479
# C.* with disabling system role of {header} kind
460480
#
461481
#KIND(L/N) NAME ENABLED DESCRIPTION
482+
Y/unknown ref off referenced anyhow
462483
d/macro condition off used in part of #if/#ifdef/#elif conditions
463484
d/macro undef on undefined
464485
h/header local on local header
@@ -468,6 +489,7 @@ h/header system off system header
468489
# C.* with enabling system role of h kind after disabling the role
469490
#
470491
#KIND(L/N) NAME ENABLED DESCRIPTION
492+
Y/unknown ref off referenced anyhow
471493
d/macro condition off used in part of #if/#ifdef/#elif conditions
472494
d/macro undef on undefined
473495
h/header local on local header
@@ -477,6 +499,7 @@ h/header system on system header
477499
# C.* with enabling system role of {header} kind after disabling the role
478500
#
479501
#KIND(L/N) NAME ENABLED DESCRIPTION
502+
Y/unknown ref off referenced anyhow
480503
d/macro condition off used in part of #if/#ifdef/#elif conditions
481504
d/macro undef on undefined
482505
h/header local on local header
@@ -486,6 +509,7 @@ h/header system on system header
486509
# C.* with disabling system and local roles of h kind
487510
#
488511
#KIND(L/N) NAME ENABLED DESCRIPTION
512+
Y/unknown ref off referenced anyhow
489513
d/macro condition off used in part of #if/#ifdef/#elif conditions
490514
d/macro undef on undefined
491515
h/header local off local header
@@ -495,6 +519,7 @@ h/header system off system header
495519
# C.* with disabling system and local roles of {header} kind
496520
#
497521
#KIND(L/N) NAME ENABLED DESCRIPTION
522+
Y/unknown ref off referenced anyhow
498523
d/macro condition off used in part of #if/#ifdef/#elif conditions
499524
d/macro undef on undefined
500525
h/header local off local header
@@ -505,6 +530,7 @@ h/header system off system header
505530
# after disabling all roles in all languages
506531
#
507532
#KIND(L/N) NAME ENABLED DESCRIPTION
533+
Y/unknown ref off referenced anyhow
508534
d/macro condition off used in part of #if/#ifdef/#elif conditions
509535
d/macro undef off undefined
510536
h/header local on local header
@@ -515,6 +541,7 @@ h/header system on system header
515541
# after disabling all roles in all languages
516542
#
517543
#KIND(L/N) NAME ENABLED DESCRIPTION
544+
Y/unknown ref off referenced anyhow
518545
d/macro condition off used in part of #if/#ifdef/#elif conditions
519546
d/macro undef off undefined
520547
h/header local on local header
@@ -524,6 +551,7 @@ h/header system on system header
524551
# C.* with disabling local role of h kind and undef role of d kind
525552
#
526553
#KIND(L/N) NAME ENABLED DESCRIPTION
554+
Y/unknown ref off referenced anyhow
527555
d/macro condition off used in part of #if/#ifdef/#elif conditions
528556
d/macro undef off undefined
529557
h/header local off local header
@@ -533,6 +561,7 @@ h/header system on system header
533561
# C.* with enabling all roles of header kinds after disabling all roles of the kind
534562
#
535563
#KIND(L/N) NAME ENABLED DESCRIPTION
564+
Y/unknown ref off referenced anyhow
536565
d/macro condition off used in part of #if/#ifdef/#elif conditions
537566
d/macro undef on undefined
538567
h/header local on local header
@@ -542,6 +571,7 @@ h/header system on system header
542571
# C.* with enabling all roles of header kinds after disabling all roles of the kinds of C language
543572
#
544573
#KIND(L/N) NAME ENABLED DESCRIPTION
574+
Y/unknown ref off referenced anyhow
545575
d/macro condition off used in part of #if/#ifdef/#elif conditions
546576
d/macro undef off undefined
547577
h/header local on local header
@@ -551,6 +581,7 @@ h/header system on system header
551581
# C.* with enabling all roles of header kinds after disabling all roles of the kinds of C language (short notation)
552582
#
553583
#KIND(L/N) NAME ENABLED DESCRIPTION
584+
Y/unknown ref off referenced anyhow
554585
d/macro condition off used in part of #if/#ifdef/#elif conditions
555586
d/macro undef off undefined
556587
h/header local on local header

Tmain/nested-subparsers.d/stdout-expected.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ x external and forward variable declarations [off]
1717
z function parameters inside function or prototype definitions [off]
1818
L goto labels [off]
1919
D parameters inside macro definitions [off]
20+
Y unknown identifier [off]
2021
#
2122
# list kinds Event
2223
#
@@ -36,6 +37,7 @@ n name
3637
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
3738
D macroparam no no 0 C parameters inside macro definitions
3839
L label no no 0 C goto labels
40+
Y unknown no yes 1 C unknown identifier
3941
d macro yes no 2 C macro definitions
4042
e enumerator yes no 0 C enumerators (values inside an enumeration)
4143
f function yes no 0 C function definitions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__anon21d591360111 input.h /^{$/;" n
2-
foo input.h /^ int foo;$/;" v namespace:__anon21d591360111 typeref:typename:int
1+
__anon21d591360112 input.h /^{$/;" n
2+
foo input.h /^ int foo;$/;" v namespace:__anon21d591360112 typeref:typename:int

Units/parser-cxx.r/namespace.cpp.d/expected.tags

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
__anon396601200111 input.cpp /^namespace {$/;" n file: end:8
2-
anon_f input.cpp /^ void anon_f() { };$/;" f namespace:__anon396601200111 typeref:typename:void end:3
3-
__anon396601200211 input.cpp /^ namespace {$/;" n namespace:__anon396601200111 file: end:7
4-
anon_anon_f input.cpp /^ void anon_anon_f() { };$/;" f namespace:__anon396601200111::__anon396601200211 typeref:typename:void end:6
1+
__anon396601200112 input.cpp /^namespace {$/;" n file: end:8
2+
anon_f input.cpp /^ void anon_f() { };$/;" f namespace:__anon396601200112 typeref:typename:void end:3
3+
__anon396601200212 input.cpp /^ namespace {$/;" n namespace:__anon396601200112 file: end:7
4+
anon_anon_f input.cpp /^ void anon_anon_f() { };$/;" f namespace:__anon396601200112::__anon396601200212 typeref:typename:void end:6
55
a1 input.cpp /^namespace a1 {$/;" n file: end:24
66
a1_f input.cpp /^ void a1_f() { }$/;" f namespace:a1 typeref:typename:void end:11
77
a2 input.cpp /^ namespace a2 {$/;" n namespace:a1 file: end:19
88
a1_a2_f input.cpp /^ void a1_a2_f() { }$/;" f namespace:a1::a2 typeref:typename:void end:14
99
a3 input.cpp /^ namespace a3 {$/;" n namespace:a1::a2 file: end:18
1010
a1_a2_a3_f input.cpp /^ void a1_a2_a3_f() { };$/;" f namespace:a1::a2::a3 typeref:typename:void end:17
11-
__anon396601200311 input.cpp /^ namespace {$/;" n namespace:a1 file: end:23
12-
a1_anon_f input.cpp /^ void a1_anon_f() { };$/;" f namespace:a1::__anon396601200311 typeref:typename:void end:22
11+
__anon396601200312 input.cpp /^ namespace {$/;" n namespace:a1 file: end:23
12+
a1_anon_f input.cpp /^ void a1_anon_f() { };$/;" f namespace:a1::__anon396601200312 typeref:typename:void end:22
1313
b1 input.cpp /^namespace b1::b2 {$/;" n file: end:32
1414
b2 input.cpp /^namespace b1::b2 {$/;" n namespace:b1 file: end:32
1515
b1_b2_f input.cpp /^ void b1_b2_f() { };$/;" f namespace:b1::b2 typeref:typename:void end:27

misc/mini-geany.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ x: externvar
1717
z: parameter
1818
L: label
1919
D: macroparam
20+
Y: unknown
2021

2122
Parsing buffer:
2223
foo line: 1 kind: function lang: C

parsers/cxx/cxx_parser_function.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ int cxxParserEmitFunctionTags(
15431543
0
15441544
);
15451545

1546+
cxxTagUseTokensInRangeAsPartOfDefTags(CORK_NIL,pInfo->pIdentifierStart,pInfo->pIdentifierEnd);
15461547
cxxTokenChainDestroyRange(pInfo->pIdentifierChain,pInfo->pIdentifierStart,pInfo->pIdentifierEnd);
15471548

15481549
CXX_DEBUG_ASSERT(
@@ -1694,6 +1695,7 @@ int cxxParserEmitFunctionTags(
16941695
pInfo->pTemplateSpecializationEnd,
16951696
0
16961697
);
1698+
/* TODO */
16971699

16981700
// Tricky. We append it to the specialization chain which will
16991701
// be then used by cxxTagHandleTemplateFileds()

parsers/cxx/cxx_parser_namespace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ bool cxxParserParseNamespace(void)
141141
pLastIdentifier,
142142
CXXTokenChainExtractRangeNoTrailingSpaces
143143
);
144+
/* TODO */
144145

145146
cxxTagSetField(
146147
CXXTagCPPFieldAliasedName,

parsers/cxx/cxx_parser_tokenizer.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ void cxxParserUngetCurrentToken(void)
12141214
//
12151215
// In some special cases this function may parse more than one token,
12161216
// however only a single token will always be returned.
1217-
bool cxxParserParseNextToken(void)
1217+
static bool cxxParserParseNextTokenNoRefTag(void)
12181218
{
12191219
// The token chain should not be allowed to grow arbitrarily large.
12201220
// The token structures are quite big and it's easy to grow up to
@@ -1689,3 +1689,29 @@ bool cxxParserParseNextToken(void)
16891689

16901690
return true;
16911691
}
1692+
1693+
bool cxxParserParseNextToken(void)
1694+
{
1695+
bool r = cxxParserParseNextTokenNoRefTag();
1696+
if (r && cxxTokenTypeIs(g_cxx.pToken,CXXTokenTypeIdentifier)
1697+
&& cxxTagKindEnabled(CXXTagKindUNKNOWN))
1698+
{
1699+
// QtMoc subparser calls this function indirectly.
1700+
// However, "unknown" kind + "ref" role is part of the
1701+
// base parser like C++. They are not part of the subparser.
1702+
// So we have to swtich the context for making the reference tag
1703+
// temporarily here.
1704+
const bool in_subparser = (g_cxx.eLangType != getInputLanguage());
1705+
if (in_subparser)
1706+
pushLanguage(g_cxx.eLangType);
1707+
1708+
g_cxx.pToken->iCorkIndex = makeSimpleRefTag(g_cxx.pToken->pszWord,
1709+
CXXTagKindUNKNOWN,
1710+
CXXTagUnknownRoleREFERENCED);
1711+
g_cxx.pToken->bCorkIndexForReftag = true;
1712+
1713+
if (in_subparser)
1714+
popLanguage();
1715+
}
1716+
return r;
1717+
}

parsers/cxx/cxx_parser_variable.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ bool cxxParserExtractVariableDeclarations(CXXTokenChain * pChain,unsigned int uF
653653
);
654654

655655
CXXToken * pScopeId = cxxTokenChainExtractRange(pScopeStart,pPartEnd->pPrev,0);
656+
/* TODO */
656657
cxxScopePush(
657658
pScopeId,
658659
CXXScopeTypeClass,

parsers/cxx/cxx_qtmoc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static void qtMocMakeTagForProperty (CXXToken * pToken, const char *pszType)
8686
{
8787
tagEntryInfo tag;
8888

89+
cxxTagUseTokenAsPartOfDefTag(CORK_NIL, pToken);
8990
initTagEntry(&tag,
9091
vStringValue(pToken->pszWord),
9192
K_PROPERTY);

0 commit comments

Comments
 (0)