Hide Pro*C SQL simplification. Use pro_c_sql.cfg library file if this is wanted.
This commit is contained in:
parent
9b2936a66f
commit
4f6f1e20dd
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0"?>
|
||||
<def format="2">
|
||||
<define name="EXEC" value="__CPPCHECK_PRO_C_EXEC__"/>
|
||||
</def>
|
|
@ -1980,12 +1980,12 @@ void Tokenizer::simplifyRoundCurlyParentheses()
|
|||
void Tokenizer::simplifySQL()
|
||||
{
|
||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||
if (Token::simpleMatch(tok, "EXEC SQL")) {
|
||||
if (Token::simpleMatch(tok, "__CPPCHECK_PRO_C_EXEC__ SQL")) {
|
||||
const Token *end = findSQLBlockEnd(tok);
|
||||
if (end == nullptr)
|
||||
syntaxError(nullptr);
|
||||
|
||||
std::string instruction = tok->stringifyList(end);
|
||||
const std::string instruction = tok->stringifyList(end);
|
||||
// delete all tokens until the embedded SQL block end
|
||||
Token::eraseTokens(tok, end);
|
||||
|
||||
|
@ -9893,8 +9893,8 @@ const Token *Tokenizer::findSQLBlockEnd(const Token *tokSQLStart) const
|
|||
for (const Token *tok = tokSQLStart->tokAt(2); tok != nullptr; tok = tok->next()) {
|
||||
if (tokLastEnd == nullptr && tok->str() == ";")
|
||||
tokLastEnd = tok;
|
||||
else if (tok->str() == "EXEC") {
|
||||
if (Token::simpleMatch(tok->tokAt(-2), "END - EXEC ;"))
|
||||
else if (tok->str() == "__CPPCHECK_PRO_C_EXEC__") {
|
||||
if (Token::simpleMatch(tok->tokAt(-2), "END - __CPPCHECK_PRO_C_EXEC__ ;"))
|
||||
return tok->next();
|
||||
return tokLastEnd;
|
||||
}
|
||||
|
|
|
@ -5782,19 +5782,19 @@ private:
|
|||
void simplifySQL() {
|
||||
// Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages
|
||||
// ticket: #1959
|
||||
ASSERT_EQUALS("asm ( \"\"EXEC SQL SELECT A FROM B\"\" ) ;", tokenizeAndStringify("EXEC SQL SELECT A FROM B;",false));
|
||||
ASSERT_THROW(tokenizeAndStringify("EXEC SQL",false), InternalError);
|
||||
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL SELECT A FROM B\"\" ) ;", tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL SELECT A FROM B;",false));
|
||||
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL",false), InternalError);
|
||||
|
||||
ASSERT_EQUALS("asm ( \"\"EXEC SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - EXEC\"\" ) ; asm ( \"\"EXEC SQL COMMIT\"\" ) ;",
|
||||
tokenizeAndStringify("EXEC SQL EXECUTE BEGIN Proc1(A); END; END-EXEC; EXEC SQL COMMIT;",false));
|
||||
ASSERT_EQUALS("asm ( \"\"EXEC SQL UPDATE A SET B = C\"\" ) ; asm ( \"\"EXEC SQL COMMIT\"\" ) ;",
|
||||
tokenizeAndStringify("EXEC SQL UPDATE A SET B = C; EXEC SQL COMMIT;",false));
|
||||
ASSERT_EQUALS("asm ( \"\"EXEC SQL COMMIT\"\" ) ; asm ( \"\"EXEC SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - EXEC\"\" ) ;",
|
||||
tokenizeAndStringify("EXEC SQL COMMIT; EXEC SQL EXECUTE BEGIN Proc1(A); END; END-EXEC;",false));
|
||||
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - __CPPCHECK_PRO_C_EXEC__\"\" ) ; asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL COMMIT\"\" ) ;",
|
||||
tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1(A); END; END-__CPPCHECK_PRO_C_EXEC__; __CPPCHECK_PRO_C_EXEC__ SQL COMMIT;",false));
|
||||
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL UPDATE A SET B = C\"\" ) ; asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL COMMIT\"\" ) ;",
|
||||
tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL UPDATE A SET B = C; __CPPCHECK_PRO_C_EXEC__ SQL COMMIT;",false));
|
||||
ASSERT_EQUALS("asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL COMMIT\"\" ) ; asm ( \"\"__CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1 ( A ) ; END ; END - __CPPCHECK_PRO_C_EXEC__\"\" ) ;",
|
||||
tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL COMMIT; __CPPCHECK_PRO_C_EXEC__ SQL EXECUTE BEGIN Proc1(A); END; END-__CPPCHECK_PRO_C_EXEC__;",false));
|
||||
|
||||
ASSERT_THROW(tokenizeAndStringify("int f(){ EXEC SQL } int a;",false), InternalError);
|
||||
ASSERT_THROW(tokenizeAndStringify("EXEC SQL int f(){",false), InternalError);
|
||||
ASSERT_THROW(tokenizeAndStringify("EXEC SQL END-EXEC int a;",false), InternalError);
|
||||
ASSERT_THROW(tokenizeAndStringify("int f(){ __CPPCHECK_PRO_C_EXEC__ SQL } int a;",false), InternalError);
|
||||
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL int f(){",false), InternalError);
|
||||
ASSERT_THROW(tokenizeAndStringify("__CPPCHECK_PRO_C_EXEC__ SQL END-__CPPCHECK_PRO_C_EXEC__ int a;",false), InternalError);
|
||||
}
|
||||
|
||||
void simplifyCAlternativeTokens() {
|
||||
|
|
Loading…
Reference in New Issue