[libclang] Add clang_File_tryGetRealPathName
authorFangrui Song <maskray@google.com>
Sat, 7 Apr 2018 20:50:35 +0000 (20:50 +0000)
committerFangrui Song <maskray@google.com>
Sat, 7 Apr 2018 20:50:35 +0000 (20:50 +0000)
commite46ac5fb9dcbfd805bf1181dc6babcae0a5c9210
tree9214254a04e853613f4bf949b44a47337a0710f3
parent6b6552367135e09806190187a5551e8bc9e621b0
[libclang] Add clang_File_tryGetRealPathName

Summary:
clang_getFileName() may return a path relative to WorkingDir.
On Arch Linux, during clang_indexTranslationUnit(), clang_getFileName() on
CXIdxIncludedIncludedFileInfo::file may return
"/../lib64/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/string",
for `#include <string>`.

I presume WorkingDir is somehow changed to /usr/lib or /usr/include and
clang_getFileName() returns a path relative to WorkingDir.

clang_File_tryGetRealPathName() returns "/usr/include/c++/7.3.0/string"
which is more useful for the indexer in this case.

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D42893

llvm-svn: 329515
clang/include/clang-c/Index.h
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/libclang.exports
clang/unittests/libclang/LibclangTest.cpp