Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

WIP/SwiftExpressionParser: preserve default argument thunks #1744

Draft
wants to merge 1 commit into
base: stable
Choose a base branch
from

Conversation

compnerd
Copy link
Collaborator

No description provided.

@compnerd
Copy link
Collaborator Author

@dcci
Copy link
Member

dcci commented Aug 14, 2019

@jimingham you understand the expression parser better than me. Can you please review this patch? It fixes default arguments in the REPL.

@dcci dcci requested a review from jimingham August 14, 2019 21:08
Copy link
Member

@jimingham jimingham left a comment

Choose a reason for hiding this comment

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

I'm not up on how swift does default arguments. It looks from your change like Swift emits little assistant functions that set the parameters to the default values. If that's right, why doesn't swift::performSILGeneration emit them automatically? Why do you have to go back and force their emission by hand?

@@ -788,6 +788,44 @@ void SwiftASTManipulator::FindNonVariableDeclarations(
}
}

void SwiftASTManipulator::EnumerateDefaultValuedArguments(llvm::SmallVectorImpl<std::pair<swift::FuncDecl *, std::vector<int>>> &FDAI) {
class DefaultArgumentThunkFinder : public swift::ASTWalker {
swift::SourceFile *SF;
Copy link
Member

Choose a reason for hiding this comment

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

Can you use variable names more in keeping with lldb's conventions. Particularly here, you have FD DAI, AI, DAI... Playing the "guess the acronym" game makes the code much harder to read.

@jimingham
Copy link
Member

Also, if this fixes something there should be tests for what it fixes.

for (int AI : DAI) {
auto DAG = swift::SILDeclRef::getDefaultArgGenerator(FD, AI);
swift::SILFunction *F = sil_module->lookUpFunction(DAG);
F->dump();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how this has any effect (besides spewing garbage to stderr). What's actually going on here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I disagree with the spewing garbage bit at least - it was very useful to me when I was trying to determine if I was catching everything and the correct thing :-). Yes, this is absolutely debugging cruft that is not meant to be merged.

@compnerd
Copy link
Collaborator Author

@jimingham - it doesn't because they may not actually be needed - in the case that the value is provided, the call is not needed. I never finished this work, and there is more that needs to be done here, if you want to pick it up, that would be great. I've been busy with the breakage in libdispatch, Foundation, llbuild (across android, Windows) and trying to get s-p-m bootstrap builds CI'ed for Windows.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants