Skip to content

Commit f86d6ea

Browse files
committed
avoid dangling references to local objects
1 parent 7327a82 commit f86d6ea

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ static simplecpp::TokenList makeTokenList(const char code[], std::size_t size, s
9090
return simplecpp::TokenList(istr,filenames,filename,outputList);
9191
}
9292

93-
static simplecpp::TokenList makeTokenList(const char code[])
94-
{
95-
std::vector<std::string> files;
96-
return makeTokenList(code, files);
97-
}
98-
9993
static std::string readfile(const char code[], simplecpp::OutputList *outputList=nullptr)
10094
{
10195
std::vector<std::string> files;
@@ -205,7 +199,8 @@ static void builtin()
205199
static std::string testConstFold(const char code[])
206200
{
207201
try {
208-
simplecpp::TokenList expr = makeTokenList(code);
202+
std::vector<std::string> files;
203+
simplecpp::TokenList expr = makeTokenList(code, files);
209204
expr.constFold();
210205
return expr.stringify();
211206
} catch (std::exception &) {
@@ -1656,7 +1651,8 @@ static void multiline5() // column
16561651
{
16571652
const char code[] = "#define A\\\n"
16581653
"(";
1659-
const simplecpp::TokenList rawtokens = makeTokenList(code);
1654+
std::vector<std::string> files;
1655+
const simplecpp::TokenList rawtokens = makeTokenList(code, files);
16601656
ASSERT_EQUALS("# define A (", rawtokens.stringify());
16611657
ASSERT_EQUALS(11, rawtokens.cback()->location.col);
16621658
}
@@ -1666,7 +1662,8 @@ static void multiline6() // multiline string in macro
16661662
const char code[] = "#define string (\"\\\n"
16671663
"x\")\n"
16681664
"string\n";
1669-
const simplecpp::TokenList rawtokens = makeTokenList(code);
1665+
std::vector<std::string> files;
1666+
const simplecpp::TokenList rawtokens = makeTokenList(code, files);
16701667
ASSERT_EQUALS("# define string ( \"x\" )\n"
16711668
"\n"
16721669
"string", rawtokens.stringify());
@@ -1677,7 +1674,8 @@ static void multiline7() // multiline string in macro
16771674
const char code[] = "#define A(X) aaa { f(\"\\\n"
16781675
"a\"); }\n"
16791676
"A(1)";
1680-
const simplecpp::TokenList rawtokens = makeTokenList(code);
1677+
std::vector<std::string> files;
1678+
const simplecpp::TokenList rawtokens = makeTokenList(code, files);
16811679
ASSERT_EQUALS("# define A ( X ) aaa { f ( \"a\" ) ; }\n"
16821680
"\n"
16831681
"A ( 1 )", rawtokens.stringify());

0 commit comments

Comments
 (0)