Skip to content

Conversation

@firewave
Copy link
Collaborator

No description provided.

@firewave
Copy link
Collaborator Author

firewave commented Oct 26, 2024

@pfultz2 Please have a look. I obviously have no idea what I am doing.

The printing of the tokens we pass to isAliasOf() in isExpressionChangedAt() shows something like this:

{ 0 877 0
{ 0 877 1
std 0 877 0
std 0 877 1
:: 882 877 0
:: 882 877 1
strncmp 0 877 0
strncmp 0 877 1

The namespace prefix does not seem like any expression that might have any impact.

lib/astutils.cpp Outdated
if (tok->isLiteral() || tok->isKeyword() || tok->isStandardType() || tok->isEnumerator())
return false;
if (Token::Match(tok, ",|;|:|]|)|}"))
if (Token::Match(tok, ",|;|:|]|)|}|::"))
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't bail on ::, this will miss variable changes. Instead you should check astOperand2()(or perhaps both) when its a :::

if (Token::Match(tok, "::"))
    return isMutableExpression(tok->astOperand2());

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Given the example above in case of std :: strncmp that will pass any of that to this function and my understanding would be that it makes no sense for std :: in that case. Same for a type like std :: string which I also see.

The case you refer to would be a scoped variable. I wonder if all parts would also be passed as an expression that should be changed.

I have the feeling that namespaces are not handled properly here. I guess it requires some tests to be written.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You shouldn't bail on ::, this will miss variable changes.

It is called on all tokens (at least in terms of find aliases) so I think it would only make sense for the actual variable one to proceed on but not the scoping stuff or type. And neither for any function calls.

@pfultz2
Copy link
Contributor

pfultz2 commented Oct 26, 2024

Please have a look. I obviously have no idea what I am doing.

I dont really have a context of what you are trying to do here, but it is definitely problematic.

@firewave
Copy link
Collaborator Author

I dont really have a context of what you are trying to do here, but it is definitely problematic.

I want to reduce the amount of calls to isAliasOf() since most of the time during analysis is spent there.

@sonarqubecloud
Copy link

@firewave
Copy link
Collaborator Author

Closing in favor of #8145. This was mostly about starting a discussion.

@firewave firewave closed this Jan 21, 2026
@firewave firewave deleted the expr-chg branch January 21, 2026 19:47
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.

2 participants