[PATCH] D33788: Return a canonical path from getClangResourcePath()
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 1 10:30:07 PDT 2017
aaron.ballman created this revision.
on POSIX systems, CIndexer::getClangResourcesPath() uses dladdr() to get the path of the shared object. It seems that on some systems (in our case, OS X 10.6.8), dladdr() does not return a canonicalized path. We're getting a path like PATH/TO/CLANG/build/bin/../lib/clang/4.0.0. This resource directory path is then used to calculate a hash used by CompilerInvocation::getModuleHash(). This, in turn, is causing Index/pch-from-libclang.c to fail for us because the module cache paths have different names -- the first path is calculated with PATH/TO/CLANG/build/lib/clang/4.0.0 and the second path uses PATH/TO/CLANG/build/bin/../lib/clang/4.0.0.
Fix this bug by returning a canonicalized path.
https://reviews.llvm.org/D33788
Files:
tools/libclang/CIndexer.cpp
Index: tools/libclang/CIndexer.cpp
===================================================================
--- tools/libclang/CIndexer.cpp
+++ tools/libclang/CIndexer.cpp
@@ -73,6 +73,11 @@
llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
// Cache our result.
- ResourcesPath = LibClangPath.str();
+ SmallString<260> RealPath;
+ if (!llvm::sys::fs::real_path(LibClangPath, RealPath, /*expand_tilde=*/false))
+ ResourcesPath = RealPath.str();
+ else
+ ResourcesPath = LibClangPath.str();
+
return ResourcesPath;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33788.101047.patch
Type: text/x-patch
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170601/6eb47bf2/attachment.bin>
More information about the cfe-commits
mailing list