summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-04-07 20:50:35 +0000
committerFangrui Song <maskray@google.com>2018-04-07 20:50:35 +0000
commite46ac5fb9dcbfd805bf1181dc6babcae0a5c9210 (patch)
tree9214254a04e853613f4bf949b44a47337a0710f3 /clang/tools/libclang
parent6b6552367135e09806190187a5551e8bc9e621b0 (diff)
downloadbcm5719-llvm-e46ac5fb9dcbfd805bf1181dc6babcae0a5c9210.tar.gz
bcm5719-llvm-e46ac5fb9dcbfd805bf1181dc6babcae0a5c9210.zip
[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
Diffstat (limited to 'clang/tools/libclang')
-rw-r--r--clang/tools/libclang/CIndex.cpp8
-rw-r--r--clang/tools/libclang/libclang.exports1
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 74305718296..480e00eb962 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -4249,6 +4249,14 @@ int clang_File_isEqual(CXFile file1, CXFile file2) {
return FEnt1->getUniqueID() == FEnt2->getUniqueID();
}
+CXString clang_File_tryGetRealPathName(CXFile SFile) {
+ if (!SFile)
+ return cxstring::createNull();
+
+ FileEntry *FEnt = static_cast<FileEntry *>(SFile);
+ return cxstring::createRef(FEnt->tryGetRealPathName());
+}
+
//===----------------------------------------------------------------------===//
// CXCursor Operations.
//===----------------------------------------------------------------------===//
diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports
index 67e4b4334b7..222598dcd94 100644
--- a/clang/tools/libclang/libclang.exports
+++ b/clang/tools/libclang/libclang.exports
@@ -46,6 +46,7 @@ clang_Cursor_isVariadic
clang_Cursor_getModule
clang_Cursor_getStorageClass
clang_File_isEqual
+clang_File_tryGetRealPathName
clang_Module_getASTFile
clang_Module_getParent
clang_Module_getName
OpenPOWER on IntegriCloud