Skip to content

Go: Use objectpath for object labels in extractor #16742

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 deletions go/extractor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module github.com/github/codeql-go/extractor
go 1.22.0

require (
golang.org/x/mod v0.15.0
golang.org/x/tools v0.18.0
golang.org/x/mod v0.18.0
golang.org/x/tools v0.22.0
)

require golang.org/x/sync v0.7.0 // indirect
12 changes: 6 additions & 6 deletions go/extractor/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
1 change: 1 addition & 0 deletions go/extractor/trap/BUILD.bazel

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

9 changes: 9 additions & 0 deletions go/extractor/trap/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"go/types"

"github.com/github/codeql-go/extractor/util"
"golang.org/x/tools/go/types/objectpath"
)

// Label represents a label
Expand Down Expand Up @@ -157,7 +158,15 @@ func (l *Labeler) ScopedObjectID(object types.Object, getTypeLabel func() Label)
// referenced from other files via their method
methlbl, _ := l.MethodID(meth, getTypeLabel())
label, _ = l.ReceiverObjectID(object, methlbl)
} else if path, err := objectpath.For(object); err == nil {
// If we can, use the object path as the label. This is needed
// for type parameters. Note that `objectpath` returns an error
// for non-exported objects.
label = l.GlobalID(fmt.Sprintf("%v,{%s};object", object.Pkg().Path(), path))
} else {
// Otherwise, construct a label based on the scope and the object's name.
// If the scope is not package scope then it will be given a fresh label,
// which will be different when it is referenced from different packages.
scopeLbl := l.ScopeID(scope, object.Pkg())
label = l.GlobalID(fmt.Sprintf("{%v},%s;object", scopeLbl, object.Name()))
}
Expand Down
2 changes: 1 addition & 1 deletion go/extractor/vendor/golang.org/x/mod/modfile/read.go

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

113 changes: 108 additions & 5 deletions go/extractor/vendor/golang.org/x/mod/modfile/rule.go

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

52 changes: 51 additions & 1 deletion go/extractor/vendor/golang.org/x/mod/modfile/work.go

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

2 changes: 2 additions & 0 deletions go/extractor/vendor/golang.org/x/mod/module/module.go

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

27 changes: 27 additions & 0 deletions go/extractor/vendor/golang.org/x/sync/LICENSE

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

Loading
Loading