diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-06-13 13:56:37 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-06-13 13:56:37 +0000 |
| commit | e3868e46fbe5bd8ba374c2ce8df5faef04c9e4de (patch) | |
| tree | 616c937d95de343b7f51aaebdd84e39d1cb9aeb9 | |
| parent | 93c47b74bbefb75826b4475ceea78c5692bb1e91 (diff) | |
| download | bcm5719-llvm-e3868e46fbe5bd8ba374c2ce8df5faef04c9e4de.tar.gz bcm5719-llvm-e3868e46fbe5bd8ba374c2ce8df5faef04c9e4de.zip | |
libclang: Port CIndexer::getClangResourcesPath to PathV2. No functionality change.
llvm-svn: 183901
| -rw-r--r-- | clang/tools/libclang/CIndexer.cpp | 26 | ||||
| -rw-r--r-- | clang/tools/libclang/CIndexer.h | 4 |
2 files changed, 14 insertions, 16 deletions
diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index d89e0a41984..4cbf0c19510 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -43,11 +43,13 @@ using namespace clang; -std::string CIndexer::getClangResourcesPath() { +const std::string &CIndexer::getClangResourcesPath() { // Did we already compute the path? if (!ResourcesPath.empty()) - return ResourcesPath.str(); - + return ResourcesPath; + + SmallString<128> LibClangPath; + // Find the location where this library lives (libclang.dylib). #ifdef LLVM_ON_WIN32 MEMORY_BASIC_INFORMATION mbi; @@ -66,26 +68,22 @@ std::string CIndexer::getClangResourcesPath() { #endif #endif - llvm::sys::Path LibClangPath(path); - LibClangPath.eraseComponent(); + LibClangPath += llvm::sys::path::parent_path(path); #else // This silly cast below avoids a C++ warning. Dl_info info; if (dladdr((void *)(uintptr_t)clang_createTranslationUnit, &info) == 0) llvm_unreachable("Call to dladdr() failed"); - - llvm::sys::Path LibClangPath(info.dli_fname); - + // We now have the CIndex directory, locate clang relative to it. - LibClangPath.eraseComponent(); + LibClangPath += llvm::sys::path::parent_path(info.dli_fname); #endif - - LibClangPath.appendComponent("clang"); - LibClangPath.appendComponent(CLANG_VERSION_STRING); + + llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING); // Cache our result. - ResourcesPath = LibClangPath; - return LibClangPath.str(); + ResourcesPath = LibClangPath.str(); + return ResourcesPath; } static llvm::sys::Path GetTemporaryPath() { diff --git a/clang/tools/libclang/CIndexer.h b/clang/tools/libclang/CIndexer.h index 6f000da29db..1b4d5c56322 100644 --- a/clang/tools/libclang/CIndexer.h +++ b/clang/tools/libclang/CIndexer.h @@ -38,7 +38,7 @@ class CIndexer { bool DisplayDiagnostics; unsigned Options; // CXGlobalOptFlags. - llvm::sys::Path ResourcesPath; + std::string ResourcesPath; public: CIndexer() : OnlyLocalDecls(false), DisplayDiagnostics(false), @@ -63,7 +63,7 @@ public: } /// \brief Get the path of the clang resource files. - std::string getClangResourcesPath(); + const std::string &getClangResourcesPath(); }; /** |

