ValueFlow: Stop on inline assembly
This commit is contained in:
parent
9225bff31d
commit
97fa9e9d1b
|
@ -1327,7 +1327,7 @@ static bool valueFlowForward(Token * const startToken,
|
|||
continue;
|
||||
}
|
||||
|
||||
else if (var->isGlobal() && Token::Match(tok2, "%name% (") && Token::Match(tok2->linkAt(1), ") !!{")) {
|
||||
else if ((var->isGlobal() || tok2->str() == "asm") && Token::Match(tok2, "%name% (") && Token::Match(tok2->linkAt(1), ") !!{")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,8 @@ private:
|
|||
TEST_CASE(valueFlowSizeofForwardDeclaredEnum);
|
||||
|
||||
TEST_CASE(valueFlowGlobalVar);
|
||||
|
||||
TEST_CASE(valueFlowInlineAssembly);
|
||||
}
|
||||
|
||||
bool testValueOfX(const char code[], unsigned int linenr, int value) {
|
||||
|
@ -2355,6 +2357,15 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 5U, 42));
|
||||
}
|
||||
|
||||
void valueFlowInlineAssembly() {
|
||||
const char* code = "void f() {\n"
|
||||
" int x = 42;\n"
|
||||
" asm(\"\");\n"
|
||||
" a = x;\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 5U, 42));
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestValueFlow)
|
||||
|
|
Loading…
Reference in New Issue