Browse Source

Minor cleanups

merge-requests/37/head
eidheim 8 years ago
parent
commit
955c113c73
  1. 11
      src/CompileCommand.cc
  2. 17
      src/CompileCommands.cc

11
src/CompileCommand.cc

@ -3,10 +3,9 @@
#include "Utility.h" #include "Utility.h"
std::vector<std::string> clangmm::CompileCommand::get_arguments() { std::vector<std::string> clangmm::CompileCommand::get_arguments() {
unsigned N = clang_CompileCommand_getNumArgs(cx_command); unsigned size = clang_CompileCommand_getNumArgs(cx_command);
std::vector<std::string> res(N); std::vector<std::string> arguments;
for (unsigned i = 0; i < N; i++) { for (unsigned i = 0; i < size; i++)
res[i] = to_string(clang_CompileCommand_getArg(cx_command, i)); arguments.emplace_back(to_string(clang_CompileCommand_getArg(cx_command, i)));
} return arguments;
return res;
} }

17
src/CompileCommands.cc

@ -1,9 +1,9 @@
#include "CompileCommands.h" #include "CompileCommands.h"
clangmm::CompileCommands::CompileCommands(const std::string &filename, CompilationDatabase &db) { clangmm::CompileCommands::CompileCommands(const std::string &filename, CompilationDatabase &db) {
cx_commands = if(!filename.empty())
clang_CompilationDatabase_getCompileCommands(db.cx_db, filename.c_str()); cx_commands = clang_CompilationDatabase_getCompileCommands(db.cx_db, filename.c_str());
if(clang_CompileCommands_getSize(cx_commands)==0) if(filename.empty() || clang_CompileCommands_getSize(cx_commands)==0)
cx_commands = clang_CompilationDatabase_getAllCompileCommands(db.cx_db); cx_commands = clang_CompilationDatabase_getAllCompileCommands(db.cx_db);
} }
@ -12,10 +12,9 @@ clangmm::CompileCommands::~CompileCommands() {
} }
std::vector<clangmm::CompileCommand> clangmm::CompileCommands::get_commands() { std::vector<clangmm::CompileCommand> clangmm::CompileCommands::get_commands() {
unsigned N = clang_CompileCommands_getSize(cx_commands); unsigned size = clang_CompileCommands_getSize(cx_commands);
std::vector<CompileCommand> res; std::vector<CompileCommand> commands;
for (unsigned i = 0; i < N; i++) { for (unsigned i = 0; i < size; i++)
res.emplace_back(clang_CompileCommands_getCommand(cx_commands, i)); commands.emplace_back(clang_CompileCommands_getCommand(cx_commands, i));
} return commands;
return res;
} }

Loading…
Cancel
Save