Clang import; handle locations better, only expand function bodies in source file
This commit is contained in:
parent
e7e80a574d
commit
729fca8728
|
@ -201,7 +201,10 @@ namespace clangastdump {
|
||||||
void dumpAst(int num = 0, int indent = 0) const;
|
void dumpAst(int num = 0, int indent = 0) const;
|
||||||
void createTokens1(TokenList *tokenList) {
|
void createTokens1(TokenList *tokenList) {
|
||||||
//dumpAst();
|
//dumpAst();
|
||||||
|
if (!tokenList->back())
|
||||||
setLocations(tokenList, 0, 1, 1);
|
setLocations(tokenList, 0, 1, 1);
|
||||||
|
else
|
||||||
|
setLocations(tokenList, tokenList->back()->fileIndex(), tokenList->back()->linenr(), 1);
|
||||||
createTokens(tokenList);
|
createTokens(tokenList);
|
||||||
if (nodeType == VarDecl || nodeType == RecordDecl || nodeType == TypedefDecl)
|
if (nodeType == VarDecl || nodeType == RecordDecl || nodeType == TypedefDecl)
|
||||||
addtoken(tokenList, ";");
|
addtoken(tokenList, ";");
|
||||||
|
@ -774,7 +777,7 @@ void clangastdump::AstNode::createTokensFunctionDecl(TokenList *tokenList)
|
||||||
par1->link(par2);
|
par1->link(par2);
|
||||||
par2->link(par1);
|
par2->link(par1);
|
||||||
// Function body
|
// Function body
|
||||||
if (!children.empty() && children.back()->nodeType == CompoundStmt) {
|
if (mFile == 0 && !children.empty() && children.back()->nodeType == CompoundStmt) {
|
||||||
Token *bodyStart = addtoken(tokenList, "{");
|
Token *bodyStart = addtoken(tokenList, "{");
|
||||||
bodyStart->scope(&scope);
|
bodyStart->scope(&scope);
|
||||||
children.back()->createTokens(tokenList);
|
children.back()->createTokens(tokenList);
|
||||||
|
|
|
@ -281,6 +281,7 @@ unsigned int CppCheck::check(const std::string &path)
|
||||||
//std::cout << "Checking Clang ast dump:\n" << res.second << std::endl;
|
//std::cout << "Checking Clang ast dump:\n" << res.second << std::endl;
|
||||||
std::istringstream ast(res.second);
|
std::istringstream ast(res.second);
|
||||||
Tokenizer tokenizer(&mSettings, this);
|
Tokenizer tokenizer(&mSettings, this);
|
||||||
|
tokenizer.list.appendFileIfNew(path);
|
||||||
clangastdump::parseClangAstDump(&tokenizer, ast);
|
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)
|
if (mSettings.debugnormal)
|
||||||
|
|
Loading…
Reference in New Issue