class CIndexer : public Indexer {
public:
- explicit CIndexer(Program *prog) : Indexer(*prog), OnlyLocalDecls(false) {}
+ explicit CIndexer(Program *prog, std::string &path)
+ : Indexer(*prog), OnlyLocalDecls(false), ClangPath(path) {}
virtual ~CIndexer() { delete &getProgram(); }
/// declarations.
bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
void setOnlyLocalDecls(bool Local = true) { OnlyLocalDecls = Local; }
-
+
+ const std::string& getClangPath() { return ClangPath; }
private:
bool OnlyLocalDecls;
+ std::string ClangPath;
};
}
extern "C" {
-static const char *clangPath;
-
CXIndex clang_createIndex()
{
// FIXME: This is a hack to unbreak the MSVC build.
// We now have the CIndex directory, locate clang relative to it.
std::string ClangPath = CIndexDir + "/../bin/clang";
- clangPath = ClangPath.c_str();
-
- return new CIndexer(new Program());
+ return new CIndexer(new Program(), ClangPath);
}
void clang_disposeIndex(CXIndex CIdx)
#else
// Build up the arguments for involing clang.
std::vector<const char *> argv;
- argv.push_back(clangPath);
+ argv.push_back(static_cast<CIndexer *>(CIdx)->getClangPath().c_str());
argv.push_back("-emit-ast");
argv.push_back(source_filename);
argv.push_back("-o");