diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-01-21 08:27:08 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-21 13:38:45 +0000 |
| commit | f855e4845e221d8e036caa7edac9fe2926020ba4 (patch) | |
| tree | 317511a84574d9b94c4d8a006bd4ef92171ca052 /pkg/codesearch/codesearch.go | |
| parent | 6e304df8df70bfaecd0ff91478acda0e9177f030 (diff) | |
pkg/codesearch: fix resolving of static functions declared in headers
Update #6469
Diffstat (limited to 'pkg/codesearch/codesearch.go')
| -rw-r--r-- | pkg/codesearch/codesearch.go | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/pkg/codesearch/codesearch.go b/pkg/codesearch/codesearch.go index 396df4f82..051cad3c5 100644 --- a/pkg/codesearch/codesearch.go +++ b/pkg/codesearch/codesearch.go @@ -312,18 +312,25 @@ func (index *Index) FindReferences(contextFile, name, srcPrefix string, contextL } func (index *Index) findDefinition(contextFile, name string) *Definition { - var weakMatch *Definition + var weakMatch, veryWeakMatch *Definition for _, def := range index.db.Definitions { - if def.Name == name { - if def.Body.File == contextFile { - return def - } - if !def.IsStatic { - weakMatch = def - } + if def.Name != name { + continue } + if def.Body.File == contextFile { + return def + } + // Strictly speaking there may be several different static functions in different headers, + // but we ignore such possibility for now. + if !def.IsStatic || strings.HasSuffix(def.Body.File, ".h") { + weakMatch = def + } + veryWeakMatch = def + } + if weakMatch != nil { + return weakMatch } - return weakMatch + return veryWeakMatch } func (index *Index) formatSource(lines LineRange, includeLines bool) (string, error) { |
