I am running into a problem with clang's code-completion feature.
A simple class illustrates the problem:
~/Source/clang-test/test.h:
Asking clang for completion suggestions at "m_" in the to_string method;
generates the error:
But if I move the method definition out of the class definition:
Asking for code-completion suggestions at "m_" of the to_string method:
generates the expected results:
Oddly enough even when the method definition is within the class definition, if I as clang for suggestions after "this->", clang returns the expected suggestions:
If anyone has any experience clang's code-completion, is the command line I am using to call clang wrong?
A simple class illustrates the problem:
~/Source/clang-test/test.h:
Code:
#include <string>
#include <utility>
class Full_Name {
std::string m_firstName;
std::string m_lastName;
std::string m_fullName;
public:
Full_Name(std::string firstName, std::string lastName) :
m_firstName(std::move(firstName)),
m_lastName(std::move(lastName)) {
m_fullName = m_firstName + " " + m_lastName;
}
std::string to_string() const { return m_ }
};
Asking clang for completion suggestions at "m_" in the to_string method;
Code:
clifford@Google-VM:~/Source$ clang -std=c++11 -fsyntax-only -x c++ -Xclang -code-completion-at=clang-test/test.h:15:43 clang-test/test.h
generates the error:
Code:
};
^
clang-test/test.h:3:17: note: to match this '{'
class Full_Name {
^
clang-test/test.h:14:42: error: use of undeclared identifier 'm'
std::string to_string() const { return m<U+0000>_ }
^
clang-test/test.h:14:43: error: expected '}'
std::string to_string() const { return m<U+0000>_ }
^
clang-test/test.h:14:33: note: to match this '{'
std::string to_string() const { return m<U+0000>_ }
^
clang-test/test.h:14:43: error: expected ';' after class
std::string to_string() const { return m<U+0000>_ }
^
;
4 errors generated.
But if I move the method definition out of the class definition:
Code:
#include <string>
#include <utility>
class Full_Name {
std::string m_firstName;
std::string m_lastName;
std::string m_fullName;
public:
Full_Name(std::string firstName, std::string lastName) :
m_firstName(std::move(firstName)),
m_lastName(std::move(lastName)) {
m_fullName = m_firstName + " " + m_lastName;
}
std::string to_string() const;
};
std::string Full_Name::to_string() const {
return m_
}
Asking for code-completion suggestions at "m_" of the to_string method:
Code:
clifford@Google-VM:~/Source$ clang -std=c++11 -fsyntax-only -x c++ -Xclang -code-completion-at=clang-test/test.h:22:10 clang-test/test.h
generates the expected results:
Code:
COMPLETION: m_firstName : [#std::string#]m_firstName
COMPLETION: m_fullName : [#std::string#]m_fullName
COMPLETION: m_lastName : [#std::string#]m_lastName
Oddly enough even when the method definition is within the class definition, if I as clang for suggestions after "this->", clang returns the expected suggestions:
Code:
COMPLETION: Full_Name : Full_Name::
COMPLETION: m_firstName : [#std::string#]m_firstName
COMPLETION: m_fullName : [#std::string#]m_fullName
COMPLETION: m_lastName : [#std::string#]m_lastName
COMPLETION: to_string : [#std::string#]to_string()[# const#]
If anyone has any experience clang's code-completion, is the command line I am using to call clang wrong?