Browse Source

Further workarounds for ArchLinux's clang_getFileName that sometime returns wrong paths

merge-requests/365/head
eidheim 9 years ago
parent
commit
757eddb147
  1. 51
      src/source_clang.cc

51
src/source_clang.cc

@ -945,16 +945,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
}
}, &client_data);
if(!client_data.found_include.empty()) {
// Workaround for bug in ArchLinux's clang_getFileName()
// TODO: remove the workaround when this is fixed
auto include_path=filesystem::get_normal_path(client_data.found_include);
boost::system::error_code ec;
if(!boost::filesystem::exists(include_path, ec))
include_path="/usr/include"/include_path;
return Offset(0, 0, include_path);
}
if(!client_data.found_include.empty())
return Offset(0, 0, client_data.found_include);
// Find a matching include file if no include was found previously
clang_getInclusions(clang_tu->cx_tu, [](CXFile included_file, CXSourceLocation *inclusion_stack, unsigned include_len, CXClientData client_data_) {
@ -975,16 +967,8 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
}
}, &client_data);
if(!client_data.found_include.empty()) {
// Workaround for bug in ArchLinux's clang_getFileName()
// TODO: remove the workaround when this is fixed
auto include_path=filesystem::get_normal_path(client_data.found_include);
boost::system::error_code ec;
if(!boost::filesystem::exists(include_path, ec))
include_path="/usr/include"/include_path;
return Offset(0, 0, include_path);
}
if(!client_data.found_include.empty())
return Offset(0, 0, client_data.found_include);
}
}
return Offset();
@ -998,6 +982,14 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
auto offset=declaration_location();
if(!offset)
Info::get().print("No declaration found");
// Workaround for bug in ArchLinux's clang_getFileName()
// TODO: remove the workaround when this is fixed
auto include_path=filesystem::get_normal_path(offset.file_path);
boost::system::error_code ec;
if(!boost::filesystem::exists(include_path, ec))
offset.file_path="/usr/include"/include_path;
return offset;
};
@ -1095,6 +1087,16 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
auto offsets=implementation_locations(views);
if(offsets.empty())
Info::get().print("No implementation found");
// Workaround for bug in ArchLinux's clang_getFileName()
// TODO: remove the workaround when this is fixed
for(auto &offset: offsets) {
auto include_path=filesystem::get_normal_path(offset.file_path);
boost::system::error_code ec;
if(!boost::filesystem::exists(include_path, ec))
offset.file_path="/usr/include"/include_path;
}
return offsets;
};
@ -1140,6 +1142,15 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file
if(offsets.empty())
Info::get().print("No declaration or implementation found");
// Workaround for bug in ArchLinux's clang_getFileName()
// TODO: remove the workaround when this is fixed
for(auto &offset: offsets) {
auto include_path=filesystem::get_normal_path(offset.file_path);
boost::system::error_code ec;
if(!boost::filesystem::exists(include_path, ec))
offset.file_path="/usr/include"/include_path;
}
return offsets;
};

Loading…
Cancel
Save