Improved handling of the __FILE__ macro

This commit is contained in:
Daniel Marjamäki 2013-08-14 06:36:03 +02:00
parent fd26bad6fa
commit f95b29db06
2 changed files with 2 additions and 1 deletions

View File

@ -2289,7 +2289,7 @@ void Tokenizer::simplifyFileAndLineMacro()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "__FILE__")
tok->str(list.file(tok));
tok->str("\"" + list.file(tok) + "\"");
else if (tok->str() == "__LINE__")
tok->str(MathLib::longToString(tok->linenr()));
}

View File

@ -921,6 +921,7 @@ private:
}
void simplifyFileAndLineMacro() { // tokenize 'return - __LINE__' correctly
ASSERT_EQUALS("\"test.cpp\"", tokenizeAndStringify("__FILE__"));
ASSERT_EQUALS("return -1 ;", tokenizeAndStringify("return - __LINE__;"));
}