Skip to content

Commit

Permalink
Cxx: introduce "alias:" field for storing ALIAS in __attribute__((ali…
Browse files Browse the repository at this point in the history
…as("ALIAS"))__

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Dec 17, 2023
1 parent fb3a966 commit d48d1d5
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Tmain/list-fields-with-prefix.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ r UCTAGSroles no NONE s-- no r- Roles
x UCTAGSxpath no NONE s-- no -- xpath for the tag
- UCTAGSproperties yes Asm s-- no -- properties (req, vararg for parameters)
- UCTAGSproperties no AutoIt s-- no -- properties (static, volatile, ...)
- UCTAGSalias no C s-- no -- the name of the alias target specified in __attribute__((alias(...)))
- UCTAGSmacrodef no C s-- no -- macro definition
- UCTAGSproperties no C s-- no -- properties (static, inline, mutable,...)
- UCTAGSsection no C s-- no -- the place where the object is placed
- UCTAGSalias no C++ s-- no -- the name of the alias target specified in __attribute__((alias(...)))
- UCTAGScaptures no C++ s-- no -- lambda capture list
- UCTAGSmacrodef no C++ s-- no -- macro definition
- UCTAGSname yes C++ s-- no -- aliased names
Expand All @@ -19,6 +21,7 @@ x UCTAGSxpath no NONE s-- no -- xpath for
- UCTAGSspecialization no C++ s-- no -- template specialization parameters
- UCTAGStemplate no C++ s-- no -- template parameters
- UCTAGSmacrodef no CPreProcessor s-- no -- macro definition
- UCTAGSalias no CUDA s-- no -- the name of the alias target specified in __attribute__((alias(...)))
- UCTAGSmacrodef no CUDA s-- no -- macro definition
- UCTAGSproperties no CUDA s-- no -- properties (static, inline, mutable,...)
- UCTAGSsection no CUDA s-- no -- the place where the object is placed
Expand Down
3 changes: 3 additions & 0 deletions Tmain/list-fields.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ x xpath no NONE s-- no -- xpath for the tag
z kind no NONE s-- no r- [tags output] prepend "kind:" to k/ (or K/) field output, [xref and json output] kind in long-name form
- properties yes Asm s-- no -- properties (req, vararg for parameters)
- properties no AutoIt s-- no -- properties (static, volatile, ...)
- alias no C s-- no -- the name of the alias target specified in __attribute__((alias(...)))
- macrodef no C s-- no -- macro definition
- properties no C s-- no -- properties (static, inline, mutable,...)
- section no C s-- no -- the place where the object is placed
- alias no C++ s-- no -- the name of the alias target specified in __attribute__((alias(...)))
- captures no C++ s-- no -- lambda capture list
- macrodef no C++ s-- no -- macro definition
- name yes C++ s-- no -- aliased names
Expand All @@ -37,6 +39,7 @@ z kind no NONE s-- no r- [tags output] prepend "kind:" to k/ (or K/) field outpu
- specialization no C++ s-- no -- template specialization parameters
- template no C++ s-- no -- template parameters
- macrodef no CPreProcessor s-- no -- macro definition
- alias no CUDA s-- no -- the name of the alias target specified in __attribute__((alias(...)))
- macrodef no CUDA s-- no -- macro definition
- properties no CUDA s-- no -- properties (static, inline, mutable,...)
- section no CUDA s-- no -- the place where the object is placed
Expand Down
2 changes: 2 additions & 0 deletions Units/parser-cxx.r/attribute-alias.cpp.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no
--fields-C=+{alias}
1 change: 1 addition & 0 deletions Units/parser-cxx.r/attribute-alias.cpp.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x input.c /^int x __attribute__((alias("y")));$/;" v typeref:typename:int alias:y
1 change: 1 addition & 0 deletions Units/parser-cxx.r/attribute-alias.cpp.d/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int x __attribute__((alias("y")));
2 changes: 2 additions & 0 deletions docs/man/ctags-lang-c++.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Change since "0.0"

* New field ``section``

* New field ``alias``

SEE ALSO
--------
:ref:`ctags(1) <ctags(1)>`,
Expand Down
2 changes: 2 additions & 0 deletions docs/man/ctags-lang-c.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Change since "0.0"

* New field ``section``

* New field ``alias``

SEE ALSO
--------
:ref:`ctags(1) <ctags(1)>`,
Expand Down
2 changes: 2 additions & 0 deletions docs/man/ctags-lang-cuda.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Change since "0.0"

* New field ``section``

* New field ``alias``

SEE ALSO
--------
:ref:`ctags(1) <ctags(1)>`,
Expand Down
6 changes: 6 additions & 0 deletions docs/news/HEAD.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ Changes about parser specific kinds, roles, fields, and extras

+ New filed `section`

+ New field `alias`

* C++

+ New filed `section`

+ New field `alias`

* CUDA

+ New field `section`

+ New field `alias`

* Fortran

+ New extra `linkName`.
Expand Down
2 changes: 2 additions & 0 deletions man/ctags-lang-c++.7.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Change since "0.0"

* New field ``section``

* New field ``alias``

SEE ALSO
--------
ctags(1),
Expand Down
2 changes: 2 additions & 0 deletions man/ctags-lang-c.7.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Change since "0.0"

* New field ``section``

* New field ``alias``

SEE ALSO
--------
ctags(1),
Expand Down
2 changes: 2 additions & 0 deletions man/ctags-lang-cuda.7.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Change since "0.0"

* New field ``section``

* New field ``alias``

SEE ALSO
--------
ctags(1),
Expand Down
31 changes: 29 additions & 2 deletions parsers/cxx/cxx_side_chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,35 @@ static void cxxScanAttrExtractSection(const CXXToken * pToken)
vStringPut(pArgToken->pszWord, '"');
}

static void cxxScanAttrExtractAlias(const CXXToken * pToken)
{
const CXXToken *pArgToken = cxxExtractFirstArgumentInAttrs(pToken);
if(pArgToken == NULL)
return;

Assert(vStringLength(pArgToken->pszWord));

// Remve doubule quote characters surrounding the constant string.
vStringChop(pArgToken->pszWord);
cxxTagSetField(CXXTagFieldAlias, vStringValue(pArgToken->pszWord)+1, true);

vStringPut(pArgToken->pszWord, '"');
}

static void cxxScanAttributes(const CXXTokenChain * pAttrChain)
{
if(pAttrChain == NULL)
return;

CXXToken * t = pAttrChain->pHead;
bool bSection = cxxTagFieldEnabled(CXXTagFieldSection)
&& (cxxParserCurrentLanguageIsC() || cxxParserCurrentLanguageIsCPP());
bool bSection = false;
bool bAlias = false;

if((cxxParserCurrentLanguageIsC() || cxxParserCurrentLanguageIsCPP()))
{
bSection = cxxTagFieldEnabled(CXXTagFieldSection);
bAlias = cxxTagFieldEnabled(CXXTagFieldAlias);
}

while(t)
{
Expand All @@ -104,6 +125,12 @@ static void cxxScanAttributes(const CXXTokenChain * pAttrChain)
if(s)
cxxScanAttrExtractSection(s);
}
if(bAlias)
{
CXXToken * s = cxxTokenChainNextIdentifier(t->pChain->pHead, "alias");
if(s)
cxxScanAttrExtractAlias(s);
}
}
if(t == pAttrChain->pTail)
break;
Expand Down
4 changes: 4 additions & 0 deletions parsers/cxx/cxx_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ static const char * g_aCXXAccessStrings [] = {
.name = "section", \
.description = "the place where the object is placed", \
.enabled = false \
}, { \
.name = "alias", \
.description = "the name of the alias target specified in __attribute__((alias(...)))", \
.enabled = false \
}

static fieldDefinition g_aCXXCFields [] = {
Expand Down
1 change: 1 addition & 0 deletions parsers/cxx/cxx_tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum CXXTagCommonField
CXXTagFieldProperties,
CXXTagFieldMacrodef,
CXXTagFieldSection,
CXXTagFieldAlias,

CXXTagCommonFieldCount
};
Expand Down

0 comments on commit d48d1d5

Please sign in to comment.