From adf16fae8be117150d735df03ea0da48c7a24119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 25 Jul 2016 07:58:03 +0200 Subject: [PATCH] Remove handling of ##, __FILE__, __LINE__ from tokenizer --- lib/tokenize.cpp | 26 -------------------------- lib/tokenize.h | 4 ---- test/testsimplifytypedef.cpp | 9 --------- test/testtokenize.cpp | 20 -------------------- 4 files changed, 59 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 07dbdc8b5..5602f5bd8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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() .. diff --git a/lib/tokenize.h b/lib/tokenize.h index 2ade5789c..3a44ba781 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -470,10 +470,6 @@ public: void combineStrings(); - void concatenateDoubleSharp(); - - void simplifyFileAndLineMacro(); - void simplifyNull(); void concatenateNegativeNumberAndAnyPositive(); diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index c71543646..b7c772899 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -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 { };"; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 9c97e063e..b556de8a8 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 ) ] ;";