Skip to content

[ASTPrinter] Prefer TypeReprs for printing generic requirements for SIL printing #4304

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
Aug 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,25 @@ void PrintAST::printWhereClause(ArrayRef<RequirementRepr> requirements) {
if (requirements.empty())
return;

// FIXME: Type objects do not preserve info to print requirements accurately.
// SIL printing cares about semantics so \c PrevPreferTypeRepr is false but
// we need to set it to true for printing requirements.
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't always have a TypeRepr, so the problem's still a problem.

Copy link
Contributor Author

@akyrtzi akyrtzi Aug 15, 2016

Choose a reason for hiding this comment

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

Yes, that's why I marked the comment as 'FIXME'.

struct PrefTypeReprForSILRAII {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why "Pref"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'Prefer'

PrintOptions &Opts;
bool PrevPreferTypeRepr;
PrefTypeReprForSILRAII(PrintOptions &opts) : Opts(opts) {
if (Opts.PrintForSIL) {
PrevPreferTypeRepr = Opts.PreferTypeRepr;
Opts.PreferTypeRepr = true;
}
}
~PrefTypeReprForSILRAII() {
if (Opts.PrintForSIL) {
Opts.PreferTypeRepr = PrevPreferTypeRepr;
}
}
} PrefTypeReprForSILRAII(Options);

std::vector<std::tuple<StringRef, StringRef, RequirementReprKind>> Elements;
llvm::SmallString<64> Output;
bool Handled = true;
Expand Down