Skip to content

[Compile Time Constant Extraction] Refactor to support recursion. #62461

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 2 commits into from
Dec 9, 2022

Conversation

quinntaylor
Copy link
Contributor

Extract extractCompileTimeValue() function to recursively handle CompileTimeValue hierarchies.
Inline extractLiteralOutput() to only be used from the one remaining call site.
Refactor ExprKind::Call handling to reduce branching for args with a DefaultArgumentExpr.

Extract `extractCompileTimeValue()` function to recursively handle `CompileTimeValue` hierarchies.
Inline `extractLiteralOutput()` to only be used from the one remaining call site.
Refactor `ExprKind::Call` handling to reduce branching for args with a `DefaultArgumentExpr`.
@quinntaylor
Copy link
Contributor Author

@swift-ci test

if (originalInit) {
auto literalOutput = extractLiteralOutput(originalInit);
static std::shared_ptr<CompileTimeValue> extractCompileTimeValue(Expr *expr) {
if (expr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Were you seeing nullptrs passed into this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is more of a precautionary construct, to avoid bad dereferences if nullptr were to get passed in, now or in the future.

@artemcm
Copy link
Contributor

artemcm commented Dec 8, 2022

@swift-ci test

@quinntaylor quinntaylor merged commit deae449 into swiftlang:main Dec 9, 2022
@quinntaylor quinntaylor deleted the const-extraction-recursion branch December 9, 2022 02: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.

3 participants