Clang import; Set links properly
This commit is contained in:
parent
1be41cb8fb
commit
1589ac5352
|
@ -322,6 +322,7 @@ Scope *clangastdump::AstNode::createScope(TokenList *tokenList, Scope::ScopeType
|
|||
}
|
||||
Token *bodyEnd = children.back()->addtoken(tokenList, "}");
|
||||
bodyStart->link(bodyEnd);
|
||||
bodyEnd->link(bodyStart);
|
||||
scope->bodyStart = bodyStart;
|
||||
scope->bodyEnd = bodyEnd;
|
||||
return scope;
|
||||
|
@ -337,6 +338,7 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList)
|
|||
bracket1->astOperand1(array);
|
||||
bracket1->astOperand2(index);
|
||||
bracket1->link(bracket2);
|
||||
bracket2->link(bracket1);
|
||||
return bracket1;
|
||||
}
|
||||
if (nodeType == BinaryOperator) {
|
||||
|
@ -402,6 +404,7 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList)
|
|||
Token *expr3 = children[3] ? children[3]->createTokens(tokenList) : nullptr;
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
par1->astOperand1(forToken);
|
||||
par1->astOperand2(sep1);
|
||||
sep1->astOperand1(expr1);
|
||||
|
@ -436,6 +439,7 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList)
|
|||
par1->astOperand2(cond->createTokens(tokenList));
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
createScope(tokenList, Scope::ScopeType::eIf, then);
|
||||
if (else_) {
|
||||
else_->addtoken(tokenList, "else");
|
||||
|
@ -475,6 +479,7 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList)
|
|||
Token *expr = children[0]->createTokens(tokenList);
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
return expr;
|
||||
}
|
||||
if (nodeType == RecordDecl) {
|
||||
|
@ -520,6 +525,7 @@ Token *clangastdump::AstNode::createTokens(TokenList *tokenList)
|
|||
par1->astOperand2(cond->createTokens(tokenList));
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
createScope(tokenList, Scope::ScopeType::eWhile, body);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -543,7 +549,9 @@ Token * clangastdump::AstNode::createTokensCall(TokenList *tokenList)
|
|||
parent->astOperand2(children[c]->createTokens(tokenList));
|
||||
}
|
||||
}
|
||||
par1->link(addtoken(tokenList, ")"));
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
return par1;
|
||||
}
|
||||
|
||||
|
@ -583,6 +591,7 @@ void clangastdump::AstNode::createTokensFunctionDecl(TokenList *tokenList)
|
|||
}
|
||||
Token *par2 = addtoken(tokenList, ")");
|
||||
par1->link(par2);
|
||||
par2->link(par1);
|
||||
// Function body
|
||||
if (!children.empty() && children.back()->nodeType == CompoundStmt) {
|
||||
Token *bodyStart = addtoken(tokenList, "{");
|
||||
|
@ -592,6 +601,7 @@ void clangastdump::AstNode::createTokensFunctionDecl(TokenList *tokenList)
|
|||
scope.bodyStart = bodyStart;
|
||||
scope.bodyEnd = bodyEnd;
|
||||
bodyStart->link(bodyEnd);
|
||||
bodyEnd->link(bodyStart);
|
||||
} else {
|
||||
addtoken(tokenList, ";");
|
||||
}
|
||||
|
|
|
@ -1996,7 +1996,7 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, SymbolDatabase *symbo
|
|||
if (Token::Match(tok, "<|>")) {
|
||||
if (num != 0)
|
||||
continue;
|
||||
if (!var->typeStartToken()->isUnsigned())
|
||||
if (var->valueType() && var->valueType()->sign != ValueType::Sign::UNSIGNED)
|
||||
continue;
|
||||
}
|
||||
ValueFlow::Value val(tok, num);
|
||||
|
|
|
@ -72,7 +72,7 @@ private:
|
|||
" |-<<<NULL>>>\n"
|
||||
" |-IntegerLiteral 0x2c31bf8 <col:21> 'int' 0\n"
|
||||
" `-BreakStmt 0x3687c18 <col:24>";
|
||||
ASSERT_EQUALS("void foo ( ) { while ( 0 ) { break ; } ; }", parse(clang));
|
||||
ASSERT_EQUALS("void foo ( ) { while ( 0 ) { break ; } }", parse(clang));
|
||||
}
|
||||
|
||||
void class1() {
|
||||
|
@ -158,7 +158,7 @@ private:
|
|||
" |-<<<NULL>>>\n"
|
||||
" |-IntegerLiteral 0x2c31bf8 <col:21> 'int' 0\n"
|
||||
" `-ContinueStmt 0x2c31c18 <col:24>";
|
||||
ASSERT_EQUALS("void foo ( ) { while ( 0 ) { continue ; } ; }", parse(clang));
|
||||
ASSERT_EQUALS("void foo ( ) { while ( 0 ) { continue ; } }", parse(clang));
|
||||
}
|
||||
|
||||
void cxxMemberCall() {
|
||||
|
@ -190,7 +190,7 @@ private:
|
|||
" | `-CompoundStmt 0x2f93d40 <col:43, col:44>\n"
|
||||
" `-ReturnStmt 0x2f93da8 <col:46, col:53>\n"
|
||||
" `-IntegerLiteral 0x2f93d88 <col:53> 'int' 0";
|
||||
ASSERT_EQUALS("int main ( ) { for ( int i@1 = 0 ; i@1 < 10 ; ++ i@1 ) { } ; return 0 ; }", parse(clang));
|
||||
ASSERT_EQUALS("int main ( ) { for ( int i@1 = 0 ; i@1 < 10 ; ++ i@1 ) { } return 0 ; }", parse(clang));
|
||||
}
|
||||
|
||||
void funcdecl1() {
|
||||
|
@ -280,7 +280,7 @@ private:
|
|||
" `-CompoundStmt 0x2637d28 <line:3:10, col:11>";
|
||||
ASSERT_EQUALS("int foo ( int x@1 ) {\n"
|
||||
"if ( x@1 > 10 ) { }\n"
|
||||
"else { } ; }", parse(clang));
|
||||
"else { } }", parse(clang));
|
||||
}
|
||||
|
||||
void memberExpr() {
|
||||
|
@ -392,7 +392,7 @@ private:
|
|||
" |-IntegerLiteral 0x3d45bf8 <col:12> 'int' 0\n"
|
||||
" `-NullStmt 0x3d45c18 <col:14>";
|
||||
ASSERT_EQUALS("void foo ( ) {\n"
|
||||
"while ( 0 ) { ; } ; }",
|
||||
"while ( 0 ) { ; } }",
|
||||
parse(clang));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue