Browse Source

Added workaround for libclang crash when looking for definitions of completion items

pipelines/235045657
eidheim 5 years ago
parent
commit
e21dd3681d
  1. 12
      src/source_clang.cpp

12
src/source_clang.cpp

@ -1335,7 +1335,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
auto implementation_locations = [this](const Identifier &identifier) {
std::vector<Offset> offsets;
if(identifier) {
wait_parsing();
if(parsed) {
wait_parsing(); // Wait for other views to finish parsing
// First, look for a definition cursor that is equal
auto identifier_usr = identifier.cursor.get_usr();
@ -1347,10 +1348,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
if((cursor_kind == clangmm::Cursor::Kind::FunctionDecl || cursor_kind == clangmm::Cursor::Kind::CXXMethod ||
cursor_kind == clangmm::Cursor::Kind::Constructor || cursor_kind == clangmm::Cursor::Kind::Destructor ||
cursor_kind == clangmm::Cursor::Kind::FunctionTemplate || cursor_kind == clangmm::Cursor::Kind::ConversionFunction) &&
token.is_identifier()) {
auto token_spelling = token.get_spelling();
if(identifier.kind == cursor.get_kind() && identifier.spelling == token_spelling && identifier_usr == cursor.get_usr()) {
if(clang_isCursorDefinition(cursor.cx_cursor)) {
identifier.kind == cursor_kind && token.is_identifier() && clang_isCursorDefinition(cursor.cx_cursor) &&
identifier.spelling == token.get_spelling() && identifier_usr == cursor.get_usr()) {
Offset offset;
auto location = cursor.get_source_location();
auto clang_offset = location.get_offset();
@ -1362,10 +1361,9 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
}
}
}
}
}
if(!offsets.empty())
return offsets;
}
// If no implementation was found, try using clang_getCursorDefinition
auto definition = identifier.cursor.get_definition();

Loading…
Cancel
Save