[cfe-commits] r84420 - /cfe/trunk/tools/CIndex/CIndex.cpp
Daniel Dunbar
daniel at zuster.org
Sun Oct 18 23:52:21 PDT 2009
Hi Benjamin,
I think this should be exposed via something in LLVM's System library.
We already have GetMainExecutablePath, we just need to factor it into
a part which doesn't expect to have argv available.
- Daniel
On Sun, Oct 18, 2009 at 9:13 AM, Benjamin Kramer
<benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Sun Oct 18 11:13:48 2009
> New Revision: 84420
>
> URL: http://llvm.org/viewvc/llvm-project?rev=84420&view=rev
> Log:
> CIndex: add a (untested) WIN32 codepath to get ClangPath.
>
> Modified:
> cfe/trunk/tools/CIndex/CIndex.cpp
>
> Modified: cfe/trunk/tools/CIndex/CIndex.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=84420&r1=84419&r2=84420&view=diff
>
> ==============================================================================
> --- cfe/trunk/tools/CIndex/CIndex.cpp (original)
> +++ cfe/trunk/tools/CIndex/CIndex.cpp Sun Oct 18 11:13:48 2009
> @@ -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 @@
> 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 @@
> 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 @@
> clang_createTranslationUnit(CIdx, astTmpFile));
> ATU->unlinkTemporaryFile();
> return ATU;
> -#endif
> }
>
> void clang_disposeTranslationUnit(
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list