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

execgen: preserve comments around callsite of inlined function #67291

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions pkg/sql/colexec/colexecjoin/hashjoiner.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/sql/colexec/execgen/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func inlineFunc(inlineFuncMap map[string]funcInfo, n dst.Node) dst.Node {
// }
inlinedStatements := &dst.BlockStmt{
List: []dst.Stmt{retValDeclStmt},
Decs: dst.BlockStmtDecorations{
NodeDecs: n.Decs.NodeDecs,
},
}
body := dst.Clone(decl.Body).(*dst.BlockStmt)

Expand Down Expand Up @@ -179,6 +182,9 @@ func inlineFunc(inlineFuncMap map[string]funcInfo, n dst.Node) dst.Node {
// the mangled returns after the inlined function.
funcBlock := &dst.BlockStmt{
List: []dst.Stmt{reassignments},
Decs: dst.BlockStmtDecorations{
NodeDecs: n.Decs.NodeDecs,
},
}
body := dst.Clone(decl.Body).(*dst.BlockStmt)

Expand Down
31 changes: 31 additions & 0 deletions pkg/sql/colexec/execgen/testdata/inline
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,34 @@ const _ = "inlined_b"
const _ = "inlined_c"
----
----

# Test that comments at call-site are preserved.
inline
package main

func a() {
// This comment should not be removed.
b()
// This one too.
}

// execgen:inline
func b() {
foo = bar
}
----
----
package main

func a() {
// This comment should not be removed.
{
foo = bar
}
// This one too.
}

// execgen:inline
const _ = "inlined_b"
----
----