From e5db23fff382681181ee23f5aede3d5bc52c8c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 5 Apr 2018 15:40:59 +0200 Subject: [PATCH] project: import compile_commands.json generated by compiledb-generator --- lib/importproject.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 76317317e..49b569a78 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -199,6 +199,17 @@ void ImportProject::importCompileCommands(std::istream &istr) values[key.substr(1, key.size() - 2U)] = value.substr(1, value.size() - 2U); } + else if (Token::Match(tok, "%str : [ %str%") && tok->str() == "\"arguments\"") { + std::string cmd; + tok = tok->tokAt(2); + while (Token::Match(tok, ",|[ %str%")) { + const std::string &s = tok->next()->str(); + cmd += ' ' + s.substr(1, s.size() - 2); + tok = tok->tokAt(2); + } + values["command"] = cmd.substr(1); + } + else if (tok->str() == "}") { if (!values["file"].empty() && !values["command"].empty()) { struct FileSettings fs; @@ -216,6 +227,10 @@ void ImportProject::importCompileCommands(std::istream &istr) if (pos >= command.size()) break; const char F = command[pos++]; + if (std::strchr("DUI", F)) { + while (pos < command.size() && command[pos] == ' ') + ++pos; + } std::string fval; while (pos < command.size() && command[pos] != ' ' && command[pos] != '=') { if (command[pos] != '\\')