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

fixed #12715 - made Visual Studio conditions work again #6389

Merged
merged 1 commit into from
May 14, 2024

Conversation

firewave
Copy link
Collaborator

@firewave firewave commented May 7, 2024

No description provided.

TokenList tokenlist(&settings);
std::istringstream istr(s);
tokenlist.createTokens(istr, Standards::Language::C);
tokenlist.createAst(); // TODO: do not crash
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@chrchr-github Any idea why this might crash? It works when done in the context of Tokenizer::simplifyTokens1(). IMO the AST generation in TokenList should not depend on the simplifications.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like the parentheses are not linked (Tokenizer::createLinks()).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The logic seems to exists in several others places:
TokenList::insertTokens()
createTokenFromExpression()
clangimport::AstNode::addTypeTokens()

I assume this is done to work around the issue I am currently encountering as the code in question is only using a TokenList.

@firewave
Copy link
Collaborator Author

firewave commented May 7, 2024

This still needs Visual Studio import tests but I might not get to those. And as this is a high severity regression I want to get in a fix ASAP (as well as a backport and a 2.14.x patch release).

@chrchr-github
Copy link
Collaborator

Is the test snippet from a project file? Why do we need to create an AST from that?

@firewave
Copy link
Collaborator Author

firewave commented May 7, 2024

Is the test snippet from a project file?

Yes. That is a bog standard condition used in every Visual Studio project file.

Why do we need to create an AST from that?

I need to create the AST so Token::astOperandX() is set.

@chrchr-github
Copy link
Collaborator

But a .vcxproj is XML, do we treat that as code somehow? Seems sketchy...

@firewave
Copy link
Collaborator Author

firewave commented May 7, 2024

But a .vcxproj is XML, do we treat that as code somehow?

This is a string extracted from it (macros obviously being replaced):

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"/>

I think this is actually C# code.

Seems sketchy...

Hence the TODOs to improve the testing and maybe handling it differently.

@firewave firewave changed the title fixed #12715 - made Visual Studio conditions work again [skip ci] fixed #12715 - made Visual Studio conditions work again May 8, 2024
@danmar
Copy link
Owner

danmar commented May 13, 2024

👍

@firewave
Copy link
Collaborator Author

This needs to be cleaned up but it is all I can do right now and this needs to be fixed ASAP since it breaks scanning Visual Studio projects.

@firewave
Copy link
Collaborator Author

There is a WIP selftest/dogfooding job which would have caught this with #5477.

@chrchr-github chrchr-github merged commit 994c015 into danmar:main May 14, 2024
63 checks passed
@firewave firewave deleted the vcxproj-test branch May 14, 2024 21:54
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