Use clang_File_tryGetRealPathName

This commit is contained in:
Fangrui Song 2018-04-07 10:43:56 -07:00
parent b51347960c
commit 3fbfb99e1b
6 changed files with 18 additions and 12 deletions

View File

@ -5,7 +5,7 @@ a C/C++/Objective-C language server.
* code completion (with both signature help and snippets)
* finding [definition](src/messages/text_document_definition.cc)/[references](src/messages/text_document_references.cc)
* [call (caller/callee) hierarchy](src/messages/cquery_call_hierarchy.cc), [inheritance (base/derived) hierarchy](src/messages/cquery_inheritance_hierarchy.cc), [member hierarchy](src/messages/cquery_member_hierarchy.cc)
* [call (caller/callee) hierarchy](src/messages/ccls_call_hierarchy.cc), [inheritance (base/derived) hierarchy](src/messages/ccls_inheritance_hierarchy.cc), [member hierarchy](src/messages/ccls_member_hierarchy.cc)
* [symbol rename](src/messages/text_document_rename.cc)
* [document symbols](src/messages/text_document_document_symbol.cc) and approximate search of [workspace symbol](src/messages/workspace_symbol.cc)
* [hover information](src/messages/text_document_hover.cc)

View File

@ -7,15 +7,15 @@ case $(uname -s) in
Darwin)
libclang=(lib/clang+llvm-*/lib/libclang.dylib)
strip_option="-x"
name=cquery-$version-x86_64-apple-darwin ;;
name=ccls-$version-x86_64-apple-darwin ;;
FreeBSD)
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
strip_option="-s"
name=cquery-$version-x86_64-unknown-freebsd10 ;;
name=ccls-$version-x86_64-unknown-freebsd10 ;;
Linux)
libclang=(lib/clang+llvm-*/lib/libclang.so.?)
strip_option="-s"
name=cquery-$version-x86_64-unknown-linux-gnu ;;
name=ccls-$version-x86_64-unknown-linux-gnu ;;
*)
echo Unsupported >&2
exit 1 ;;
@ -26,7 +26,7 @@ mkdir "$pkg/$name"
rsync -rtLR bin "./${libclang[-1]}" ./lib/clang+llvm-*/lib/clang/*/include "$pkg/$name"
cd "$pkg"
strip "$strip_option" "$name/bin/cquery" "$name/${libclang[-1]}"
strip "$strip_option" "$name/bin/ccls" "$name/${libclang[-1]}"
case $(uname -s) in
Darwin)
# https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/tar.1.html

View File

@ -106,8 +106,13 @@ std::optional<lsDiagnostic> BuildAndDisposeDiagnostic(CXDiagnostic diagnostic,
}
std::string FileName(CXFile file) {
CXString cx_name = clang_getFileName(file);
std::string ret = NormalizePath(ToString(cx_name));
std::string ret;
// clang > 6
#if CINDEX_VERSION >= 48
ret = ToString(clang_File_tryGetRealPathName(file));
#endif
if (ret.empty())
ret = ToString(clang_getFileName(file));
// Resolve /usr/include/c++/7.3.0 symlink.
if (!StartsWith(ret, g_config->projectRoot))
ret = fs::canonical(ret);

View File

@ -77,7 +77,7 @@ bool ShouldDisplayMethodTiming(MethodType type) {
void PrintHelp() {
std::cout
<< R"help(ccls is a low-latency C/C++/Objective-C language server.
<< R"help(ccls is a C/C++/Objective-C language server.
Mode:
--test-unit Run unit tests.
@ -91,7 +91,7 @@ Mode:
Other command line options:
--init <initializationOptions>
Override client provided initialization options
https://github.com/cquery-project/cquery/wiki/Initialization-options
https://github.com/MaskRay/ccls/wiki/Initialization-options
--log-file <path> Logging file for diagnostics
--log-file-append <path> Like --log-file, but appending
--log-all-to-stderr Write all log messages to STDERR.

View File

@ -80,8 +80,8 @@ std::vector<std::string> kNormalizePathArgs = {"--sysroot="};
// Arguments whose path arguments should be injected into include dir lookup
// for #include completion.
std::vector<std::string> kQuoteIncludeArgs = {"-iquote"};
std::vector<std::string> kAngleIncludeArgs = {"-I", "/I", "-isystem"};
std::vector<std::string> kQuoteIncludeArgs = {"-iquote", "-I", "/I"};
std::vector<std::string> kAngleIncludeArgs = {"-isystem", "-I", "/I"};
bool ShouldAddToQuoteIncludes(const std::string& arg) {
return StartsWithAny(arg, kQuoteIncludeArgs);

View File

@ -9,6 +9,7 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <algorithm>
#include <fstream>
@ -248,7 +249,7 @@ std::string TextReplacer::Apply(const std::string& content) {
void WriteToFile(const std::string& filename, const std::string& content) {
FILE* f = fopen(filename.c_str(), "wb");
if (!f || fwrite(content.c_str(), content.size(), 1, f) != 1) {
LOG_S(ERROR) << "Cannot write to " << filename;
LOG_S(ERROR) << "Failed to write to " << filename << ' ' << strerror(errno);
return;
}
fclose(f);