Skip to content

Commit

Permalink
Merge pull request #4006 from masatake/cxx--fix-export-prop-for-using
Browse files Browse the repository at this point in the history
C++: record "export" in the property field if the keyword is put at a "using" declaration
  • Loading branch information
masatake committed May 20, 2024
2 parents 8904e85 + 4674749 commit 5fae75d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Units/parser-cxx.r/export-using.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--sort=no
--fields=+K
--kinds-C++=+MtNp
--fields-C++=+{properties}
--extras=+r
--fields=+r
5 changes: 5 additions & 0 deletions Units/parser-cxx.r/export-using.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Delta input.cpp /^export module Delta;$/;" module roles:def properties:export
Param input.cpp /^export using Param = int;$/;" typedef typeref:typename:int file: roles:def properties:export
Param input.cpp /^export using ::Param;$/;" name file: roles:def properties:export
Param input.cpp /^export using ::Param; \/\/ We can declare an object more than twice.$/;" name file: roles:def properties:export
fn input.cpp /^export void fn();$/;" prototype typeref:typename:void file: roles:def properties:export
7 changes: 7 additions & 0 deletions Units/parser-cxx.r/export-using.d/input.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Derived from https://github.com/universal-ctags/ctags/issues/4003 submitted by @adrianconstantin-leroy.
export module Delta;

export using Param = int;
export using ::Param;
export using ::Param; // We can declare an object more than twice.
export void fn();
1 change: 1 addition & 0 deletions Units/parser-cxx.r/export-using.d/validator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cxx20+module
13 changes: 13 additions & 0 deletions parsers/cxx/cxx_parser_using.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ bool cxxParserParseUsingClause(void)
{
CXX_DEBUG_ENTER();

unsigned int uInitialKeywordState = g_cxx.uKeywordState;

// using-directives for namespaces and using-declarations
// for namespace members
// using-declarations for class members
Expand Down Expand Up @@ -170,7 +172,18 @@ bool cxxParserParseUsingClause(void)
{
tag->isFileScope = (cxxScopeGetType() == CXXScopeTypeNamespace) &&
(!isInputHeaderFile());

unsigned int uProperties = 0;
if(uInitialKeywordState & CXXParserKeywordStateSeenExport)
uProperties |= CXXTagPropertyExport;
vString * pszProperties = NULL;

if(uProperties)
pszProperties = cxxTagSetProperties(uProperties);

cxxTagCommit(NULL);

vStringDelete (pszProperties);
}
}
}
Expand Down

0 comments on commit 5fae75d

Please sign in to comment.