Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemVerilog: handle an identifier include '$' #2680

Merged
merged 10 commits into from
Oct 29, 2020

Conversation

hirooih
Copy link
Contributor

@hirooih hirooih commented Oct 27, 2020

isIdentifierCharacter() did not handle '$` properly.
I needed to simplify token handling for the better fix of it.
Delay handling is also improved.

@coveralls
Copy link

coveralls commented Oct 27, 2020

Coverage Status

Coverage decreased (-0.001%) to 87.026% when pulling 4219047 on hirooih:sv-token-handling into 8b4a13c on universal-ctags:master.

@codecov
Copy link

codecov bot commented Oct 27, 2020

Codecov Report

Merging #2680 into master will decrease coverage by 0.00%.
The diff coverage is 96.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2680      +/-   ##
==========================================
- Coverage   86.93%   86.93%   -0.01%     
==========================================
  Files         183      183              
  Lines       39080    39091      +11     
==========================================
+ Hits        33974    33983       +9     
- Misses       5106     5108       +2     
Impacted Files Coverage Δ
parsers/verilog.c 99.01% <96.47%> (-0.32%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b7b8a2...4219047. Read the comment docs.

@hirooih
Copy link
Contributor Author

hirooih commented Oct 27, 2020

All of uncovered lines increased are sanity checks for broken inputs.

dup->inheritance = vStringNew ();
vStringCopy (dup->name, token->name);
vStringCopy (dup->blockName, token->blockName);
vStringCopy (dup->inheritance, token->inheritance);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You does "delete", "new", and "copy" three vStrings.

However, when you call newToken () at the beginning of the funciton, the dup returned from newToken() is already cleared.
So the "delete" and "new" steps are just redundant. What you need is only the the "copy" step.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review.

First I did make same mistake as you wrote. But it does not work.
dup->name, dup->blockName, and dup->inheritance are overwritten by token->name, token->blockName, and token->inheritance via *dup = *token;.
vStrings allocated by dupToken() are never be freed.

Another solution is copying each element without using *dup = *token;. But I did not choose it because it might cause missing elements. I am assuming the number of vString elements are much less than the number of other elements.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about the following code?

static tokenInfo *dupToken (tokenInfo *token)
{
	tokenInfo *dup = newToken ();

	{
	  tokenInfo tmp = *dup;

	  *dup = *token;

	  dup->name = tmp.name;
	  dup->blockName = tmp.blockName;
	  dup->inheritance = tmp.inheritance;
	}

	vStringCopy (dup->name, token->name);
	vStringCopy (dup->blockName, token->blockName);
	vStringCopy (dup->inheritance, token->inheritance);
	return dup;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Better than mine.
I've committed the following code.

static tokenInfo *dupToken (tokenInfo *token)
{
	tokenInfo *dup = newToken ();
	tokenInfo tmp = *dup;	// save vStrings, name, blockName, and inheritance
	*dup = *token;
	// revert vStrings allocated for dup
	dup->name = tmp.name;
	dup->blockName = tmp.blockName;
	dup->inheritance = tmp.inheritance;
	// copy contents of vStrings
	vStringCopy (dup->name, token->name);
	vStringCopy (dup->blockName, token->blockName);
	vStringCopy (dup->inheritance, token->inheritance);
	return dup;
}

@hirooih hirooih merged commit 6222334 into universal-ctags:master Oct 29, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants