golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.51k stars 17.6k forks source link

x/tools/cmd/gorename: cannot find Swig identifiers #23261

Closed fabrice102 closed 3 weeks ago

fabrice102 commented 6 years ago

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.9.2 darwin/amd64

Does this issue reproduce with the latest release?

I am using the latest version

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/fbenhamo/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pp/87h481t95tl4rrv9kygw9z7r0000gn/T/go-build287490315=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

In the folder $GOPATH/src/test, I created the following files:

--- main.cxx
#include <iostream>

void SwigTest(int a) {
    std::cout << a << std::endl;
}

--- main.hpp
void SwigTest(int a);

--- main.swigcxx
%{
#include "main.hpp"
%}

%include "main.hpp"

--- test.go
package main

var val = 42

// Test just call the swig function SwigTest
func main() {
    SwigTest(val)
}

and I ran:

gorename -from test.go::val -to value

What did you expect to see?

I expected val to be renamed into value. (And this actually works if I comment the line SwigTest(val) of test.go).

What did you see instead?

/Users/fbenhamo/go/src/test/test.go:7:2: undeclared name: SwigTest
gorename: couldn't load packages due to errors: test

Note: the previous example compiles (go build) and run perfectly well. Only gorename cannot find the symbol SwigTest declared by swig.

fabrice102 commented 6 years ago

It might be related to #15793.

seankhliao commented 3 weeks ago

closing as obsoleted by #69360