Clang import; handle locations better, only expand function bodies in source file

This commit is contained in:
Daniel Marjamäki 2020-01-10 14:59:34 +01:00
parent e7e80a574d
commit 729fca8728
2 changed files with 6 additions and 2 deletions

View File

@ -201,7 +201,10 @@ namespace clangastdump {
void dumpAst(int num = 0, int indent = 0) const;
void createTokens1(TokenList *tokenList) {
//dumpAst();
if (!tokenList->back())
setLocations(tokenList, 0, 1, 1);
else
setLocations(tokenList, tokenList->back()->fileIndex(), tokenList->back()->linenr(), 1);
createTokens(tokenList);
if (nodeType == VarDecl || nodeType == RecordDecl || nodeType == TypedefDecl)
addtoken(tokenList, ";");
@ -774,7 +777,7 @@ void clangastdump::AstNode::createTokensFunctionDecl(TokenList *tokenList)
par1->link(par2);
par2->link(par1);
// Function body
if (!children.empty() && children.back()->nodeType == CompoundStmt) {
if (mFile == 0 && !children.empty() && children.back()->nodeType == CompoundStmt) {
Token *bodyStart = addtoken(tokenList, "{");
bodyStart->scope(&scope);
children.back()->createTokens(tokenList);

View File

@ -281,6 +281,7 @@ unsigned int CppCheck::check(const std::string &path)
//std::cout << "Checking Clang ast dump:\n" << res.second << std::endl;
std::istringstream ast(res.second);
Tokenizer tokenizer(&mSettings, this);
tokenizer.list.appendFileIfNew(path);
clangastdump::parseClangAstDump(&tokenizer, ast);
//ValueFlow::setValues(&tokenizer.list, const_cast<SymbolDatabase *>(tokenizer.getSymbolDatabase()), this, &mSettings);
if (mSettings.debugnormal)