r183901 - libclang: Port CIndexer::getClangResourcesPath to PathV2. No functionality change.
Benjamin Kramer
benny.kra at googlemail.com
Thu Jun 13 06:56:37 PDT 2013
Author: d0k
Date: Thu Jun 13 08:56:37 2013
New Revision: 183901
URL: http://llvm.org/viewvc/llvm-project?rev=183901&view=rev
Log:
libclang: Port CIndexer::getClangResourcesPath to PathV2. No functionality change.
Modified:
cfe/trunk/tools/libclang/CIndexer.cpp
cfe/trunk/tools/libclang/CIndexer.h
Modified: cfe/trunk/tools/libclang/CIndexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexer.cpp?rev=183901&r1=183900&r2=183901&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexer.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexer.cpp Thu Jun 13 08:56:37 2013
@@ -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::getClangResourcesP
#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() {
Modified: cfe/trunk/tools/libclang/CIndexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexer.h?rev=183901&r1=183900&r2=183901&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexer.h (original)
+++ cfe/trunk/tools/libclang/CIndexer.h Thu Jun 13 08:56:37 2013
@@ -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();
};
/**
More information about the cfe-commits
mailing list