ValueFlow: Stop on inline assembly

This commit is contained in:
PKEuS 2017-03-23 20:01:16 +01:00
parent 9225bff31d
commit 97fa9e9d1b
2 changed files with 12 additions and 1 deletions

View File

@ -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;
}

View File

@ -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)