Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Commit 2e23657

Browse files
committed
Fixed go to header on Arch Linux/Manjaro
1 parent dbcb700 commit 2e23657

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/source_clang.cc

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,16 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
10441044
}
10451045
}, &client_data);
10461046

1047-
if(!client_data.found_include.empty())
1048-
return Offset(0, 0, client_data.found_include);
1047+
if(!client_data.found_include.empty()) {
1048+
// Workaround for bug in ArchLinux's clang_getFileName()
1049+
// TODO: remove the workaround when this is fixed
1050+
auto include_path=filesystem::get_normal_path(client_data.found_include);
1051+
boost::system::error_code ec;
1052+
if(!boost::filesystem::exists(include_path, ec))
1053+
include_path="/usr/include"/include_path;
1054+
1055+
return Offset(0, 0, include_path);
1056+
}
10491057

10501058
// Find a matching include file if no include was found previously
10511059
clang_getInclusions(clang_tu->cx_tu, [](CXFile included_file, CXSourceLocation *inclusion_stack, unsigned include_len, CXClientData client_data_) {
@@ -1066,8 +1074,16 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
10661074
}
10671075
}, &client_data);
10681076

1069-
if(!client_data.found_include.empty())
1070-
return Offset(0, 0, client_data.found_include);
1077+
if(!client_data.found_include.empty()) {
1078+
// Workaround for bug in ArchLinux's clang_getFileName()
1079+
// TODO: remove the workaround when this is fixed
1080+
auto include_path=filesystem::get_normal_path(client_data.found_include);
1081+
boost::system::error_code ec;
1082+
if(!boost::filesystem::exists(include_path, ec))
1083+
include_path="/usr/include"/include_path;
1084+
1085+
return Offset(0, 0, include_path);
1086+
}
10711087
}
10721088
}
10731089
return Offset();

0 commit comments

Comments
 (0)