diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-18 16:13:48 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-18 16:13:48 +0000 |
commit | 20d758132f6e96b7b563c0af79aef6b3056ae22f (patch) | |
tree | fdd1df4e9df748ecc243c22a2c6fc3e292a996cb | |
parent | 5e4bc590b0ea010e38372d0b4a0aab578a746fe6 (diff) |
CIndex: add a (untested) WIN32 codepath to get ClangPath.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84420 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/CIndex/CIndex.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index ad78fbd311..8fa5aa3418 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -22,11 +22,15 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "clang/Frontend/ASTUnit.h" +#include "llvm/Config/config.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/System/Path.h" #include "llvm/System/Program.h" #include <cstdio> -#ifndef _MSC_VER +#ifdef LLVM_ON_WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else #include <dlfcn.h> #endif #include <vector> @@ -292,11 +296,16 @@ const llvm::sys::Path& CIndexer::getClangPath() { if (!ClangPath.empty()) return ClangPath; - // FIXME: This is a hack to unbreak the MSVC build. -#ifdef _MSC_VER - llvm::sys::Path CIndexPath(""); -#else // Find the location where this library lives (libCIndex.dylib). +#ifdef LLVM_ON_WIN32 + MEMORY_BASIC_INFORMATION mbi; + char path[MAX_PATH]; + VirtualQuery(void *)(uintptr_t)clang_createTranslationUnit, &mbi, + sizeof(mbi)); + GetModuleFileNameA((HINSTANCE)mbi.AllocationBase, path, MAX_PATH); + + llvm::sys::Path CIndexPath(path); +#else // This silly cast below avoids a C++ warning. Dl_info info; if (dladdr((void *)(uintptr_t)clang_createTranslationUnit, &info) == 0) @@ -351,10 +360,6 @@ CXTranslationUnit clang_createTranslationUnitFromSourceFile( const char *source_filename, int num_command_line_args, const char **command_line_args) { - // FIXME: This is a hack to unbreak the build. -#ifdef _MSC_VER - return 0; -#else // Build up the arguments for involing clang. llvm::sys::Path ClangPath = static_cast<CIndexer *>(CIdx)->getClangPath(); std::vector<const char *> argv; @@ -377,7 +382,6 @@ CXTranslationUnit clang_createTranslationUnitFromSourceFile( clang_createTranslationUnit(CIdx, astTmpFile)); ATU->unlinkTemporaryFile(); return ATU; -#endif } void clang_disposeTranslationUnit( |