Clang import; Tweaks

This commit is contained in:
Daniel Marjamäki 2020-01-09 14:13:39 +01:00
parent 90e7a94ff4
commit 98e700e30d
2 changed files with 6 additions and 3 deletions

View File

@ -77,7 +77,7 @@ static std::vector<std::string> splitString(const std::string &line)
pos2 = line.find(">", pos1);
else if (line[pos1] == '\'') {
pos2 = line.find("\'", pos1+1);
if (line.compare(pos2, 3, "\':\'", 0, 3) == 0)
if (pos2 < (int)line.size() - 3 && line.compare(pos2, 3, "\':\'", 0, 3) == 0)
pos2 = line.find("\'", pos2 + 3);
} else
pos2 = line.find(" ", pos1) - 1;

View File

@ -245,7 +245,10 @@ unsigned int CppCheck::check(const std::string &path)
const std::string clang = Path::isCPP(path) ? "clang++" : "clang";
/* Experimental: import clang ast dump */
const std::string cmd1 = clang + " -v -fsyntax-only " + path + " 2>&1";
std::ofstream fout("temp.c");
fout << "int x;\n";
fout.close();
const std::string cmd1 = clang + " -v -fsyntax-only temp.c 2>&1";
const std::pair<bool, std::string> res1 = executeCommand(cmd1);
if (!res1.first) {
std::cerr << "Failed to execute '" + cmd1 + "'" << std::endl;
@ -276,7 +279,7 @@ unsigned int CppCheck::check(const std::string &path)
std::istringstream ast(res.second);
Tokenizer tokenizer(&mSettings, this);
clangastdump::parseClangAstDump(&tokenizer, ast);
ValueFlow::setValues(&tokenizer.list, const_cast<SymbolDatabase *>(tokenizer.getSymbolDatabase()), this, &mSettings);
//ValueFlow::setValues(&tokenizer.list, const_cast<SymbolDatabase *>(tokenizer.getSymbolDatabase()), this, &mSettings);
if (mSettings.debugnormal)
tokenizer.printDebugOutput(1);
ExprEngine::runChecks(this, &tokenizer, &mSettings);