Browse Source

Changed vector<const char*> to vector<string> in TranslationUnit parameter.

merge-requests/37/head
eidheim 11 years ago
parent
commit
1dce44f4e4
  1. 20
      src/TranslationUnit.cc
  2. 4
      src/TranslationUnit.h

20
src/TranslationUnit.cc

@ -17,11 +17,15 @@ operator=(const clang::TranslationUnit &tu) {
clang::TranslationUnit:: clang::TranslationUnit::
TranslationUnit(Index *index, TranslationUnit(Index *index,
const std::string &filepath, const std::string &filepath,
const std::vector<const char*> &command_line_args) { const std::vector<std::string> &command_line_args) {
std::vector<const char*> args;
for(auto &a: command_line_args) {
args.push_back(a.c_str());
}
tu_ = clang_createTranslationUnitFromSourceFile(index->index_, tu_ = clang_createTranslationUnitFromSourceFile(index->index_,
filepath.c_str(), filepath.c_str(),
command_line_args.size(), args.size(),
command_line_args.data(), args.data(),
0, 0,
NULL); NULL);
} }
@ -40,7 +44,7 @@ TranslationUnit(Index *index,
clang::TranslationUnit:: clang::TranslationUnit::
TranslationUnit(clang::Index *index, TranslationUnit(clang::Index *index,
const std::string &filepath, const std::string &filepath,
const std::vector<const char*> &command_line_args, const std::vector<std::string> &command_line_args,
const std::map<std::string, std::string> &buffers) { const std::map<std::string, std::string> &buffers) {
std::vector<CXUnsavedFile> files; std::vector<CXUnsavedFile> files;
for (auto &buffer : buffers) { for (auto &buffer : buffers) {
@ -50,11 +54,15 @@ TranslationUnit(clang::Index *index,
file.Length = buffer.second.size(); file.Length = buffer.second.size();
files.push_back(file); files.push_back(file);
} }
std::vector<const char*> args;
for(auto &a: command_line_args) {
args.push_back(a.c_str());
}
tu_ = tu_ =
clang_parseTranslationUnit(index->index_, clang_parseTranslationUnit(index->index_,
filepath.c_str(), filepath.c_str(),
command_line_args.data(), args.data(),
command_line_args.size(), args.size(),
files.data(), files.data(),
files.size(), files.size(),
TranslationUnitOptions); TranslationUnitOptions);

4
src/TranslationUnit.h

@ -19,10 +19,10 @@ namespace clang {
public: public:
TranslationUnit(Index *index, TranslationUnit(Index *index,
const std::string &filepath, const std::string &filepath,
const std::vector<const char*> &command_line_args); const std::vector<std::string> &command_line_args);
TranslationUnit(Index *index, TranslationUnit(Index *index,
const std::string &filepath, const std::string &filepath,
const std::vector<const char*> &command_line_args, const std::vector<std::string> &command_line_args,
const std::map<std::string, std::string> &buffers); const std::map<std::string, std::string> &buffers);
TranslationUnit(Index *index, TranslationUnit(Index *index,
const std::string &filepath); const std::string &filepath);

Loading…
Cancel
Save