Skip to content

ABIChecker: teach ABI descriptor JSON to also keep track of constant values known at compile-time #41367

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

Merged
merged 1 commit into from
Feb 15, 2022

Conversation

nkcsgexi
Copy link
Contributor

Emitted at the emit-module step, ABI descriptor is of an entensible JSON format. This patch sets
up a segment in the file to also keep track of all compile-time constant values for other tools
to consume. As the initial step, we only keep track of string literals in the source files.

…values known at compile-time

Emitted at the emit-module step, ABI descriptor is of an entensible JSON format. This patch sets
up a segment in the file to also keep track of all compile-time constant values for other tools
to consume. As the initial step, we only keep track of string literals in the source files.
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi requested a review from artemcm February 14, 2022 17:28
struct ConstExprInfo {
StringRef filePath;
ConstKind kind;
unsigned offset = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I understand, offset here is measured in number of characters from the start of the buffer, and length is the difference between token locs of the Expr where we found this value.

I'm not sure these are useful values to have here, what's the thinking behind including them?

Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

This is a great start for having the infrastructure to extract constant values.

I think the next most-important missing piece is how to also include information about the context of what these values are.

For example, clients may really want to know values of constant properties of their types.
For something like:

struct Foo {
    let bar: String = "abc"
}

We should be able to extract the value of abc but also the fact that it is used to initialize Foo.bar.

@nkcsgexi nkcsgexi merged commit d7d3fe3 into swiftlang:main Feb 15, 2022
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