diff --git a/test/helpers.cpp b/test/helpers.cpp index 633becd1e9b8..575ee06d2f8e 100644 --- a/test/helpers.cpp +++ b/test/helpers.cpp @@ -117,25 +117,24 @@ ScopedFile::~ScopedFile() { // TODO: we should be using the actual Preprocessor implementation std::string PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const std::string &filedata, const std::string &cfg, const std::string &filename, SuppressionList *inlineSuppression) { - std::map cfgcode = getcode(settings, errorlogger, filedata.c_str(), std::set{cfg}, filename, inlineSuppression); + std::map cfgcode = getcode(settings, errorlogger, filedata.c_str(), filedata.size(), std::set{cfg}, filename, inlineSuppression); const auto it = cfgcode.find(cfg); if (it == cfgcode.end()) return ""; return it->second; } -std::map PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], const std::string &filename, SuppressionList *inlineSuppression) +std::map PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::size_t size, const std::string &filename, SuppressionList *inlineSuppression) { - return getcode(settings, errorlogger, code, {}, filename, inlineSuppression); + return getcode(settings, errorlogger, code, size, {}, filename, inlineSuppression); } -std::map PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::set cfgs, const std::string &filename, SuppressionList *inlineSuppression) +std::map PreprocessorHelper::getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::size_t size, std::set cfgs, const std::string &filename, SuppressionList *inlineSuppression) { simplecpp::OutputList outputList; std::vector files; - std::istringstream istr(code); - simplecpp::TokenList tokens(istr, files, Path::simplifyPath(filename), &outputList); + simplecpp::TokenList tokens(code, size, files, Path::simplifyPath(filename), &outputList); Preprocessor preprocessor(settings, errorlogger); if (inlineSuppression) preprocessor.inlineSuppressions(tokens, *inlineSuppression); @@ -163,17 +162,16 @@ std::map PreprocessorHelper::getcode(const Settings& s return cfgcode; } -void PreprocessorHelper::preprocess(const char code[], std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger) +void PreprocessorHelper::preprocess(const char code[], std::size_t size, std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger) { - preprocess(code, files, tokenizer, errorlogger, simplecpp::DUI()); + preprocess(code, size, files, tokenizer, errorlogger, simplecpp::DUI()); } -void PreprocessorHelper::preprocess(const char code[], std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger, const simplecpp::DUI& dui) +void PreprocessorHelper::preprocess(const char code[], std::size_t size, std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger, const simplecpp::DUI& dui) { // TODO: make sure the given Tokenizer has not been used yet - std::istringstream istr(code); - const simplecpp::TokenList tokens1(istr, files, files[0]); + const simplecpp::TokenList tokens1(code, size, files, files[0]); // Preprocess.. simplecpp::TokenList tokens2(files); @@ -189,11 +187,10 @@ void PreprocessorHelper::preprocess(const char code[], std::vector tokenizer.setDirectives(std::move(directives)); } -std::vector PreprocessorHelper::getRemarkComments(const char code[], ErrorLogger& errorLogger) +std::vector PreprocessorHelper::getRemarkComments(const char code[], std::size_t size, ErrorLogger& errorLogger) { std::vector files{"test.cpp"}; - std::istringstream istr(code); - const simplecpp::TokenList tokens1(istr, files, files[0]); + const simplecpp::TokenList tokens1(code, size, files, files[0]); const Settings settings; diff --git a/test/helpers.h b/test/helpers.h index 3562e403638b..ce88d882b4fe 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -167,16 +167,38 @@ class PreprocessorHelper * @param inlineSuppression the inline suppressions */ static std::string getcode(const Settings& settings, ErrorLogger& errorlogger, const std::string &filedata, const std::string &cfg, const std::string &filename, SuppressionList *inlineSuppression = nullptr); - static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr); + template + static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char (&code)[size], const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr) + { + return getcode(settings, errorlogger, code, size-1, filename, inlineSuppression); + } - static void preprocess(const char code[], std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger); - static void preprocess(const char code[], std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger, const simplecpp::DUI& dui); + template + static void preprocess(const char (&code)[size], std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger) + { + preprocess(code, size-1, files, tokenizer, errorlogger); + } + template + static void preprocess(const char (&code)[size], std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger, const simplecpp::DUI& dui) + { + preprocess(code, size-1, files, tokenizer, errorlogger, dui); + } /** get remark comments */ - static std::vector getRemarkComments(const char code[], ErrorLogger& errorLogger); + template + static std::vector getRemarkComments(const char (&code)[size], ErrorLogger& errorLogger) + { + return getRemarkComments(code, size-1, errorLogger); + } private: - static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::set cfgs, const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr); + static void preprocess(const char code[], std::size_t size, std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger); + static void preprocess(const char code[], std::size_t size, std::vector &files, Tokenizer& tokenizer, ErrorLogger& errorlogger, const simplecpp::DUI& dui); + + static std::vector getRemarkComments(const char code[], std::size_t size, ErrorLogger& errorLogger); + + static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::size_t size, const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr); + static std::map getcode(const Settings& settings, ErrorLogger& errorlogger, const char code[], std::size_t size, std::set cfgs, const std::string &filename = "file.c", SuppressionList *inlineSuppression = nullptr); }; namespace cppcheck { diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index baa406b13f14..75f05c7c3de2 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -74,7 +74,8 @@ class TestBufferOverrun : public TestFixture { } #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) - void checkP_(const char* file, int line, const char code[], const char* filename = "test.cpp") + template + void checkP_(const char* file, int line, const char (&code)[size], const char* filename = "test.cpp") { const Settings settings = settingsBuilder(settings0).severity(Severity::performance).certainty(Certainty::inconclusive).build(); diff --git a/test/testclass.cpp b/test/testclass.cpp index 615d9854b1f2..f33c142f8c80 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -8568,7 +8568,8 @@ class TestClass : public TestFixture { } #define checkUselessOverride(...) checkUselessOverride_(__FILE__, __LINE__, __VA_ARGS__) - void checkUselessOverride_(const char* file, int line, const char code[]) { + template + void checkUselessOverride_(const char* file, int line, const char (&code)[size]) { const Settings settings = settingsBuilder().severity(Severity::style).build(); std::vector files(1, "test.cpp"); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 1e080755a65a..b617b41e8518 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -127,7 +127,8 @@ class TestCondition : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], const Settings &settings, const char* filename = "test.cpp") { + template + void check_(const char* file, int line, const char (&code)[size], const Settings &settings, const char* filename = "test.cpp") { std::vector files(1, filename); Tokenizer tokenizer(settings, *this); PreprocessorHelper::preprocess(code, files, tokenizer, *this); @@ -139,7 +140,8 @@ class TestCondition : public TestFixture { runChecks(tokenizer, this); } - void check_(const char* file, int line, const char code[], const char* filename = "test.cpp", bool inconclusive = false) { + template + void check_(const char* file, int line, const char (&code)[size], const char* filename = "test.cpp", bool inconclusive = false) { const Settings settings = settingsBuilder(settings0).certainty(Certainty::inconclusive, inconclusive).build(); check_(file, line, code, settings, filename); } diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index e70cffc14807..3343aa29fd12 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -34,7 +34,8 @@ class TestIncompleteStatement : public TestFixture { const Settings settings = settingsBuilder().severity(Severity::warning).build(); #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], bool inconclusive = false, bool cpp = true) { + template + void check_(const char* file, int line, const char (&code)[size], bool inconclusive = false, bool cpp = true) { const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, inconclusive).build(); std::vector files(1, cpp ? "test.cpp" : "test.c"); diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 3c86d7568f8a..c24a3be8859a 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -3096,7 +3096,8 @@ class TestLeakAutoVarRecursiveCountLimit : public TestFixture { const Settings settings = settingsBuilder().library("std.cfg").checkLibrary().build(); #define checkP(...) checkP_(__FILE__, __LINE__, __VA_ARGS__) - void checkP_(const char* file, int line, const char code[], bool cpp = false) { + template + void checkP_(const char* file, int line, const char (&code)[size], bool cpp = false) { std::vector files(1, cpp?"test.cpp":"test.c"); Tokenizer tokenizer(settings, *this); PreprocessorHelper::preprocess(code, files, tokenizer, *this); diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 257749f882b3..9fabf32aaa23 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -48,11 +47,11 @@ class TestPreprocessor : public TestFixture { class OurPreprocessor : public Preprocessor { public: - static std::string expandMacros(const char code[], ErrorLogger *errorLogger = nullptr) { - std::istringstream istr(code); + template + static std::string expandMacros(const char (&code)[size], ErrorLogger *errorLogger = nullptr) { simplecpp::OutputList outputList; std::vector files; - const simplecpp::TokenList tokens1 = simplecpp::TokenList(istr, files, "file.cpp", &outputList); + const simplecpp::TokenList tokens1 = simplecpp::TokenList(code, size-1, files, "file.cpp", &outputList); std::map filedata; simplecpp::TokenList tokens2(files); simplecpp::preprocess(tokens2, tokens1, files, filedata, simplecpp::DUI(), &outputList); @@ -270,7 +269,8 @@ class TestPreprocessor : public TestFixture { TEST_CASE(standard); } - std::string getConfigsStr(const char filedata[], const char *arg = nullptr) { + template + std::string getConfigsStr(const char (&code)[size], const char *arg = nullptr) { Settings settings; if (arg && std::strncmp(arg,"-D",2)==0) settings.userDefines = arg + 2; @@ -278,8 +278,7 @@ class TestPreprocessor : public TestFixture { settings.userUndefs.insert(arg+2); Preprocessor preprocessor(settings, *this); std::vector files; - std::istringstream istr(filedata); - simplecpp::TokenList tokens(istr,files); + simplecpp::TokenList tokens(code,size-1,files); tokens.removeComments(); const std::set configs = preprocessor.getConfigs(tokens); std::string ret; @@ -288,12 +287,12 @@ class TestPreprocessor : public TestFixture { return ret; } - std::size_t getHash(const char filedata[]) { + template + std::size_t getHash(const char (&code)[size]) { Settings settings; Preprocessor preprocessor(settings, *this); std::vector files; - std::istringstream istr(filedata); - simplecpp::TokenList tokens(istr,files); + simplecpp::TokenList tokens(code,size-1,files); tokens.removeComments(); return preprocessor.calculateHash(tokens, ""); } @@ -446,9 +445,8 @@ class TestPreprocessor : public TestFixture { "#else\n" "2\n" "#endif\n"; - std::istringstream istr(filedata); std::vector files; - simplecpp::TokenList tokens(istr, files, "test.c"); + simplecpp::TokenList tokens(filedata, sizeof(filedata), files, "test.c"); // preprocess code with unix32 platform.. { @@ -771,37 +769,37 @@ class TestPreprocessor : public TestFixture { } void if_macro_eq_macro() { - const char *code = "#define A B\n" - "#define B 1\n" - "#define C 1\n" - "#if A == C\n" - "Wilma\n" - "#else\n" - "Betty\n" - "#endif\n"; + const char code[] = "#define A B\n" + "#define B 1\n" + "#define C 1\n" + "#if A == C\n" + "Wilma\n" + "#else\n" + "Betty\n" + "#endif\n"; ASSERT_EQUALS("\n", getConfigsStr(code)); } void ticket_3675() { - const char* code = "#ifdef YYSTACKSIZE\n" - "#define YYMAXDEPTH YYSTACKSIZE\n" - "#else\n" - "#define YYSTACKSIZE YYMAXDEPTH\n" - "#endif\n" - "#if YYDEBUG\n" - "#endif\n"; + const char code[] = "#ifdef YYSTACKSIZE\n" + "#define YYMAXDEPTH YYSTACKSIZE\n" + "#else\n" + "#define YYSTACKSIZE YYMAXDEPTH\n" + "#endif\n" + "#if YYDEBUG\n" + "#endif\n"; (void)PreprocessorHelper::getcode(settings0, *this, code); // There's nothing to assert. It just needs to not hang. } void ticket_3699() { - const char* code = "#define INLINE __forceinline\n" - "#define inline __forceinline\n" - "#define __forceinline inline\n" - "#if !defined(_WIN32)\n" - "#endif\n" - "INLINE inline __forceinline\n"; + const char code[] = "#define INLINE __forceinline\n" + "#define inline __forceinline\n" + "#define __forceinline inline\n" + "#if !defined(_WIN32)\n" + "#endif\n" + "INLINE inline __forceinline\n"; const std::map actual = PreprocessorHelper::getcode(settings0, *this, code); // First, it must not hang. Second, inline must becomes inline, and __forceinline must become __forceinline. @@ -809,9 +807,9 @@ class TestPreprocessor : public TestFixture { } void ticket_4922() { // #4922 - const char* code = "__asm__ \n" - "{ int extern __value) 0; (double return (\"\" } extern\n" - "__typeof __finite (__finite) __finite __inline \"__GI___finite\");"; + const char code[] = "__asm__ \n" + "{ int extern __value) 0; (double return (\"\" } extern\n" + "__typeof __finite (__finite) __finite __inline \"__GI___finite\");"; (void)PreprocessorHelper::getcode(settings0, *this, code); } @@ -2231,12 +2229,12 @@ class TestPreprocessor : public TestFixture { } void if_sizeof() { // #4071 - static const char* code = "#if sizeof(unsigned short) == 2\n" - "Fred & Wilma\n" - "#elif sizeof(unsigned short) == 4\n" - "Fred & Wilma\n" - "#else\n" - "#endif"; + const char code[] = "#if sizeof(unsigned short) == 2\n" + "Fred & Wilma\n" + "#elif sizeof(unsigned short) == 4\n" + "Fred & Wilma\n" + "#else\n" + "#endif"; const std::map actual = PreprocessorHelper::getcode(settings0, *this, code); ASSERT_EQUALS("\nFred & Wilma", actual.at("")); diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index d3fa9c9ecd02..325c7da1bd74 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -27,7 +27,6 @@ #include "tokenlist.h" #include -#include #include #include @@ -272,8 +271,8 @@ class TestSimplifyTypedef : public TestFixture { return tokenizer.tokens()->stringifyList(nullptr, false); } - - std::string simplifyTypedefP(const char code[]) { + template + std::string simplifyTypedefP(const char (&code)[size]) { std::vector files(1, "test.cpp"); Tokenizer tokenizer(settings0, *this); PreprocessorHelper::preprocess(code, files, tokenizer, *this); @@ -312,11 +311,11 @@ class TestSimplifyTypedef : public TestFixture { return tokenizer.tokens()->stringifyList(nullptr, false); } - std::string dumpTypedefInfo(const char code[]) { + template + std::string dumpTypedefInfo(const char (&code)[size]) { Tokenizer tokenizer(settings1, *this); - std::istringstream istr(code); - if (!tokenizer.list.createTokens(istr, "file.c")) + if (!tokenizer.list.createTokens(code, size-1, "file.c")) return {}; tokenizer.createLinks(); tokenizer.simplifyTypedef(); diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index b739932cb516..8bb318f4e037 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -27,7 +27,6 @@ #include "utils.h" #include -#include #include #include @@ -106,8 +105,7 @@ class TestSimplifyUsing : public TestFixture { Tokenizer tokenizer(settings, *this); std::vector files(1, "test.cpp"); PreprocessorHelper::preprocess(code, files, tokenizer, *this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.list.createTokens(istr, "test.cpp"), file, line); // TODO: this creates the tokens a second time + ASSERT_LOC(tokenizer.list.createTokens(code, size-1, "test.cpp"), file, line); // TODO: this creates the tokens a second time ASSERT_LOC(tokenizer.simplifyTokens1(""), file, line); return tokenizer.tokens()->stringifyList(nullptr); } diff --git a/test/teststring.cpp b/test/teststring.cpp index 9a00c1944cbf..b17d3effff12 100644 --- a/test/teststring.cpp +++ b/test/teststring.cpp @@ -62,7 +62,8 @@ class TestString : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], const char filename[] = "test.cpp") { + template + void check_(const char* file, int line, const char (&code)[size], const char filename[] = "test.cpp") { std::vector files(1, filename); Tokenizer tokenizer(settings, *this); PreprocessorHelper::preprocess(code, files, tokenizer, *this); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 5571876f8dff..f3f62da13aa3 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -525,16 +525,17 @@ class TestTokenizer : public TestFixture { return tokenizer.tokens()->stringifyList(true,true,true,true,false); } - void directiveDump(const char filedata[], std::ostream& ostr) { - directiveDump(filedata, "test.c", settingsDefault, ostr); + template + void directiveDump(const char (&code)[size], std::ostream& ostr) { + directiveDump(code, "test.c", settingsDefault, ostr); } - void directiveDump(const char filedata[], const char filename[], const Settings& settings, std::ostream& ostr) { + template + void directiveDump(const char (&code)[size], const char filename[], const Settings& settings, std::ostream& ostr) { Preprocessor preprocessor(settings, *this); - std::istringstream istr(filedata); simplecpp::OutputList outputList; std::vector files{filename}; - const simplecpp::TokenList tokens1(istr, files, filename, &outputList); + const simplecpp::TokenList tokens1(code, size-1, files, filename, &outputList); std::list directives = preprocessor.createDirectives(tokens1); Tokenizer tokenizer(settings, *this); @@ -7776,7 +7777,8 @@ class TestTokenizer : public TestFixture { } #define checkHdrs(...) checkHdrs_(__FILE__, __LINE__, __VA_ARGS__) - std::string checkHdrs_(const char* file, int line, const char code[], bool checkHeadersFlag) { + template + std::string checkHdrs_(const char* file, int line, const char (&code)[size], bool checkHeadersFlag) { const Settings settings = settingsBuilder().checkHeaders(checkHeadersFlag).build(); std::vector files(1, "test.cpp"); @@ -8285,10 +8287,9 @@ class TestTokenizerCompileLimits : public TestFixture "int PTR4 q4_var RBR4 = 0;\n"; // Preprocess file.. - std::istringstream fin(raw_code); simplecpp::OutputList outputList; std::vector files; - const simplecpp::TokenList tokens1(fin, files, emptyString, &outputList); + const simplecpp::TokenList tokens1(raw_code, sizeof(raw_code), files, emptyString, &outputList); const std::string filedata = tokens1.stringify(); const Settings settings; const std::string code = PreprocessorHelper::getcode(settings, *this, filedata, emptyString, emptyString); diff --git a/test/testtokenlist.cpp b/test/testtokenlist.cpp index d1f592ac56b9..20cbbea12bcb 100644 --- a/test/testtokenlist.cpp +++ b/test/testtokenlist.cpp @@ -154,9 +154,8 @@ class TestTokenList : public TestFixture { // analyzing /usr/include/poll.h caused Path::identify() to be called with an empty filename from // TokenList::determineCppC() because there are no tokens const char code[] = "#include "; - std::istringstream istr(code); std::vector files; - simplecpp::TokenList tokens1(istr, files, "poll.h", nullptr); + simplecpp::TokenList tokens1(code, sizeof(code), files, "poll.h", nullptr); Preprocessor preprocessor(settingsDefault, *this); simplecpp::TokenList tokensP = preprocessor.preprocess(tokens1, "", files, true); TokenList tokenlist(&settingsDefault); diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index 179c21af7b91..17f94944f720 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -87,7 +87,8 @@ class TestUnusedPrivateFunction : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], Platform::Type platform = Platform::Type::Native) { + template + void check_(const char* file, int line, const char (&code)[size], Platform::Type platform = Platform::Type::Native) { const Settings settings1 = settingsBuilder(settings).platform(platform).build(); std::vector files(1, "test.cpp"); diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 3d57b789c028..5673dfe535a0 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -275,7 +275,8 @@ class TestUnusedVar : public TestFixture { } #define checkStructMemberUsageP(...) checkStructMemberUsageP_(__FILE__, __LINE__, __VA_ARGS__) - void checkStructMemberUsageP_(const char* file, int line, const char code[]) { + template + void checkStructMemberUsageP_(const char* file, int line, const char (&code)[size]) { std::vector files(1, "test.cpp"); Tokenizer tokenizer(settings, *this); PreprocessorHelper::preprocess(code, files, tokenizer, *this); @@ -289,7 +290,8 @@ class TestUnusedVar : public TestFixture { } #define checkFunctionVariableUsageP(...) checkFunctionVariableUsageP_(__FILE__, __LINE__, __VA_ARGS__) - void checkFunctionVariableUsageP_(const char* file, int line, const char code[], const char* filename = "test.cpp") { + template + void checkFunctionVariableUsageP_(const char* file, int line, const char (&code)[size], const char* filename = "test.cpp") { std::vector files(1, filename); Tokenizer tokenizer(settings, *this); PreprocessorHelper::preprocess(code, files, tokenizer, *this); diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 7cac5ae862a9..2d6f0875b35d 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -26,7 +26,6 @@ #include "tokenlist.h" #include -#include #include #include @@ -273,8 +272,7 @@ class TestVarID : public TestFixture { template std::string tokenizeHeader_(const char* file, int line, const char (&code)[size], const char filename[]) { Tokenizer tokenizer(settings, *this); - std::istringstream istr(code); - ASSERT_LOC(tokenizer.list.createTokens(istr, filename), file, line); + ASSERT_LOC(tokenizer.list.createTokens(code, size-1, filename), file, line); ASSERT_EQUALS(true, tokenizer.simplifyTokens1("")); // result..