]> granicus.if.org Git - clang/commit
[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)
commit639427d5d327e33d797db8a39eedf466d1159e97
tree81e4a1d5a137dc45d8b5fc8c8d9f666409414704
parent06e7df12ca91bef4b1680a0a4d20bac50f1719e8
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329515 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang-c/Index.h
tools/libclang/CIndex.cpp
tools/libclang/libclang.exports
unittests/libclang/LibclangTest.cpp