Tokenizer::simplifyPointerConst: Remove simplification. Its purpose was to avoid crash for garbage code (#6900). This fixes #7485.

This commit is contained in:
Daniel Marjamäki 2016-05-08 21:32:34 +02:00
parent e99a9b4742
commit 1caa79c45f
5 changed files with 4 additions and 25 deletions

View File

@ -3802,7 +3802,6 @@ bool Tokenizer::simplifyTokenList2()
// Create symbol database and then remove const keywords
createSymbolDatabase();
SymbolDatabase::setValueTypeInTokenList(list.front(), isCPP(), _settings->defaultSign, &_settings->library);
simplifyPointerConst();
ValueFlow::setValues(&list, _symbolDatabase, _errorLogger, _settings);
@ -3814,14 +3813,6 @@ bool Tokenizer::simplifyTokenList2()
return true;
}
//---------------------------------------------------------------------------
void Tokenizer::simplifyPointerConst()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::Match(tok, "* const %name%|*"))
tok->deleteNext();
}
}
//---------------------------------------------------------------------------
void Tokenizer::printDebugOutput(unsigned int simplification) const
{

View File

@ -281,12 +281,6 @@ public:
*/
void simplifyCompoundAssignment();
/**
* Simplify "* const" to "*"
*/
void simplifyPointerConst();
/**
* Simplify the location of "static" and "const" qualifiers in
* a variable declaration or definition.

View File

@ -153,8 +153,6 @@ private:
TEST_CASE(pointeralias3);
TEST_CASE(pointeralias4);
TEST_CASE(reduceConstness);
// simplify "while (0)"
TEST_CASE(while0);
// ticket #3140
@ -2780,10 +2778,6 @@ private:
ASSERT_EQUALS(expected, tok(code));
}
void reduceConstness() {
ASSERT_EQUALS("char * p ;", tok("char * const p;"));
}
void while0() {
ASSERT_EQUALS("; x = 1 ;", tok("; do { x = 1 ; } while (0);"));
ASSERT_EQUALS("; return 0 ;", tok("; do { return 0; } while (0);"));

View File

@ -1412,9 +1412,9 @@ private:
"_Iterator v3;";
// The expected result..
const char expected[] = "long * v1 ; "
"void * v2 [ 2 ] ; "
"int * * v3 ;";
const char expected[] = "long * const v1 ; "
"void * const v2 [ 2 ] ; "
"int * const * v3 ;";
ASSERT_EQUALS(expected, tok(code));
// Check for output..

View File

@ -2698,7 +2698,7 @@ private:
"}";
ASSERT_EQUALS("void f ( ) {\n"
"int i ; i = 1 ;\n"
"const int * constPtrToConst ; constPtrToConst = & i ;\n"
"const int * const constPtrToConst ; constPtrToConst = & i ;\n"
"std :: cout << i << std :: endl ;\n"
"std :: cout << & i << std :: endl ;\n"
"}", tokenizeAndStringify(code, true));