Remove handling of ##, __FILE__, __LINE__ from tokenizer

This commit is contained in:
Daniel Marjamäki 2016-07-25 07:58:03 +02:00
parent 0767284ca1
commit adf16fae8b
4 changed files with 0 additions and 59 deletions

View File

@ -1885,26 +1885,6 @@ void Tokenizer::combineStrings()
}
}
void Tokenizer::concatenateDoubleSharp()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
while (Token::Match(tok, "%num%|%name% ## %num%|%name%")) {
tok->str(tok->str() + tok->strAt(2));
tok->deleteNext(2);
}
}
}
void Tokenizer::simplifyFileAndLineMacro()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "__FILE__")
tok->str("\"" + list.file(tok) + "\"");
else if (tok->str() == "__LINE__")
tok->str(MathLib::toString(tok->linenr()));
}
}
void Tokenizer::simplifyNull()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
@ -3339,12 +3319,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// replace inline SQL with "asm()" (Oracle PRO*C). Ticket: #1959
simplifySQL();
// replace __LINE__ macro with line number
simplifyFileAndLineMacro();
// Concatenate double sharp: 'a ## b' -> 'ab'
concatenateDoubleSharp();
createLinks();
// if (x) MACRO() ..

View File

@ -470,10 +470,6 @@ public:
void combineStrings();
void concatenateDoubleSharp();
void simplifyFileAndLineMacro();
void simplifyNull();
void concatenateNegativeNumberAndAnyPositive();

View File

@ -131,7 +131,6 @@ private:
TEST_CASE(simplifyTypedef95); // ticket #2844
TEST_CASE(simplifyTypedef96); // ticket #2886
TEST_CASE(simplifyTypedef97); // ticket #2983 (segmentation fault)
TEST_CASE(simplifyTypedef98); // ticket #2963
TEST_CASE(simplifyTypedef99); // ticket #2999
TEST_CASE(simplifyTypedef100); // ticket #3000
TEST_CASE(simplifyTypedef101); // ticket #3003 (segmentation fault)
@ -2082,14 +2081,6 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef98() { // ticket #2963
const char code[] = "typedef int type ## __LINE__;\n"
"typedef int type ## __LINE__;\n"
"type1 x;\n"
"type2 y;";
ASSERT_EQUALS("int x ; int y ;", tok(code));
}
void simplifyTypedef99() { // ticket #2999
const char code[] = "typedef struct Fred Fred;\n"
"struct Fred { };";

View File

@ -67,7 +67,6 @@ private:
TEST_CASE(tokenize33); // #5780 Various crashes on valid template code
TEST_CASE(syntax_case_default);
TEST_CASE(simplifyFileAndLineMacro); // tokenize "return - __LINE__;"
TEST_CASE(foreach); // #3690
@ -200,14 +199,10 @@ private:
TEST_CASE(file2);
TEST_CASE(file3);
TEST_CASE(doublesharp);
TEST_CASE(isZeroNumber);
TEST_CASE(isOneNumber);
TEST_CASE(isTwoNumber);
TEST_CASE(macrodoublesharp);
TEST_CASE(simplifyFunctionParameters);
TEST_CASE(simplifyFunctionParameters1); // #3721
TEST_CASE(simplifyFunctionParameters2); // #4430
@ -834,11 +829,6 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
ASSERT_EQUALS("\"test.cpp\"", tokenizeAndStringify("__FILE__"));
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
}
void foreach () {
// #3690,#5154
const char code[] ="void f() { for each ( char c in MyString ) { Console::Write(c); } }";
@ -2971,16 +2961,6 @@ private:
ASSERT_EQUALS(Path::toNativeSeparators("[c:\\a.h:1]"), tokenizer.list.fileLine(tokenizer.tokens()));
}
void doublesharp() {
const char code[] = "a##_##b TEST(var,val) var##_##val = val\n";
ASSERT_EQUALS("a_b TEST ( var , val ) var_val = val", tokenizeAndStringify(code));
}
void macrodoublesharp() {
const char code[] = "DBG(fmt,args...) printf(fmt, ## args)\n";
ASSERT_EQUALS("DBG ( fmt , args . . . ) printf ( fmt , ## args )", tokenizeAndStringify(code));
}
void simplifyFunctionParameters() {
{
const char code[] = "char a [ ABC ( DEF ) ] ;";