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

Taking on every NYI we hit while parsing a large code base #71

Merged
merged 11 commits into from
Dec 21, 2023

Conversation

jurgenvinju
Copy link
Member

@jurgenvinju jurgenvinju commented Dec 18, 2023

This is to fix this stracktrace:

image

…ended the AST to typesymbol mapper with the mapping id of the declared alias template
@jurgenvinju
Copy link
Member Author

This needs some testing. @linuswagner could you give it as spin? and perhaps supply a small code example that exercises this new feature?

@@ -554,3 +554,59 @@ java rel[loc,loc] parseForMacros(loc file, str charset=DEFAULT_CHARSET, bool inf
@synopsis{All functions in this module that have a charset parameter use this as default.}
public str DEFAULT_CHARSET = "UTF-8";

public map[str, str] linusMacros = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, it's back :octocat:

Copy link
Member Author

Choose a reason for hiding this comment

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

strange.. I must have git commit -amed again.. it's in my muscle memory.

Copy link
Member Author

Choose a reason for hiding this comment

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

What's the status now? are we ready to merge?

@jurgenvinju jurgenvinju marked this pull request as ready for review December 20, 2023 15:33

| \functionSetType(loc decl, list[TypeSymbol] templateArguments)
| \functionSetTypePointer(loc decl, list[TypeSymbol] templateArguments)

| \unaryTypeTransformation(str operator, TypeSymbol operand)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a big fan of encoding the operator as a string parameter. Can we specialize this per operator? Looking at the code, there's (currently) only one value in the operator enum anyway

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like that either. I'll have a look. If it's a small finite set we can have one transformation constructor per operator. Otherwise, we introduce an TypeTransformationOperator sort.

@@ -376,7 +376,7 @@ private ISourceLocation resolveIEnumeration(IEnumeration binding, ISourceLocatio
throw new RuntimeException("NYI" + binding.getClass().getSimpleName() + ": " + binding + " @ " + origin);
}

private ISourceLocation resolveICPPBinding(ICPPBinding binding, ISourceLocation origin) throws URISyntaxException {
Copy link
Member

Choose a reason for hiding this comment

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

Was this change intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this is dead code.

@@ -840,6 +840,16 @@ public ISourceLocation resolveBinding(IASTNameOwner node, ISourceLocation origin
return failedBinding("unknown");
}

public ISourceLocation resolveBinding(ICPPBinding binding, ISourceLocation origin) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a particular reason that the preexisting interface method did not suffice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, due to multiple inheritance of interfaces, the code for reaching ICPPBinding was not always reachable, in particular when the object did not accidentally also implement IASTNameOwner.

@@ -1459,29 +1457,6 @@ private int visit(ICPPASTDesignatedInitializer initializer) {
return PROCESS_ABORT;
}

// InitializerClauses
Copy link
Member

Choose a reason for hiding this comment

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

Was this unreachable code?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. the compiler warned about that

@@ -1557,12 +1532,6 @@ private int visit(IASTArrayDeclarator declarator) {
return PROCESS_ABORT;
}

private int visit(IASTFieldDeclarator declarator) {
Copy link
Member

Choose a reason for hiding this comment

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

Was this unreachable code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed

Copy link
Member

@rodinaarssen rodinaarssen left a comment

Choose a reason for hiding this comment

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

Left some comments here and there. Looks good in general, but this PR has become much larger than just the alias templates, which makes it harder to review.

@jurgenvinju
Copy link
Member Author

Left some comments here and there. Looks good in general, but this PR has become much larger than just the alias templates, which makes it harder to review.

So true. We are under a lot of time pressure here so we decided to take a sprint and solve every remaining issue as it hits us. The code base we are trying to parse and map is incredibly large and decades old, so it seems we are bound for hitting every NYI on the way.

@jurgenvinju jurgenvinju changed the title added code for NYI alias templates in the type resolver, but also extended the AST to typesymbol mapper with the mapping id of the declared alias template Taking on every NYI we hit while parsing a large code base Dec 21, 2023
@jurgenvinju jurgenvinju marked this pull request as draft December 21, 2023 10:17
@jurgenvinju
Copy link
Member Author

Just added GNU's computed goto's. Will try and simplify the TypeTransformationOperator design now.

@jurgenvinju jurgenvinju marked this pull request as ready for review December 21, 2023 15:06
@jurgenvinju jurgenvinju merged commit 9e48227 into main Dec 21, 2023
1 check passed
@jurgenvinju jurgenvinju deleted the alias-templates branch December 21, 2023 15:06
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