Skip to content

Commit

Permalink
main,CPreProcessor: don't include extra tags to macro signature field
Browse files Browse the repository at this point in the history
Close universal-ctags#2275.

During gathering macro parameters for making the signature field of
macro, ctags can emit tags for subword extra. These subword extra tags
make the signature field broken.

Only non-extra tags should be gathered for making the signature field.
isTagExtra helper function is introduced to filter non-extra tags
from the cork queue.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Oct 30, 2019
1 parent 5357b20 commit 522de3f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--sort=no
--extras=*-{inputFile}{pseudo}
--fields=+{signature}{extras}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
m input.h /^#define m(/;" d signature:(_argument_)
m input.h /^#define m(/;" d signature:(_argument_) extras:subword
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define m(_argument_) 50
8 changes: 8 additions & 0 deletions main/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,14 @@ extern bool isTagExtraBitMarked (const tagEntryInfo *const tag, xtagType extra)
return !! ((slot [ index ]) & (1 << offset));
}

extern bool isTagExtra (const tagEntryInfo *const tag)
{
for (unsigned int i = 0; i < XTAG_COUNT; i++)
if (isTagExtraBitMarked (tag, i))
return true;
return false;
}

static void assignRoleFull(tagEntryInfo *const e, int roleIndex, bool assign)
{
if (roleIndex == ROLE_DEFINITION_INDEX)
Expand Down
3 changes: 3 additions & 0 deletions main/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ size_t countEntryInCorkQueue (void);
extern void markTagExtraBit (tagEntryInfo *const tag, xtagType extra);
extern bool isTagExtraBitMarked (const tagEntryInfo *const tag, xtagType extra);

/* If any extra bit is on, return true. */
extern bool isTagExtra (const tagEntryInfo *const tag);

/* Attaching parser speicificc fields
*
* If your parser doesn't use Cork API, use attachParserField().
Expand Down
7 changes: 5 additions & 2 deletions parsers/cpreprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,11 +802,14 @@ static void regenreateSignatureFromParameters (vString * buffer, int from, int t
for (int pindex = from; pindex < to; pindex++)
{
tagEntryInfo *e = getEntryInCorkQueue (pindex);
if (e)
if (e && !isTagExtra (e))
{
vStringCatS (buffer, e->name);
if (pindex != (to - 1))
vStringPut (buffer, ',');
}
}
if (vStringLast (buffer) == ',')
vStringChop (buffer);
vStringPut (buffer, ')');
}

Expand Down

0 comments on commit 522de3f

Please sign in to comment.