2019-02-05 08:52:23 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2022-02-05 11:45:17 +01:00
|
|
|
* Copyright (C) 2007-2022 Cppcheck team.
|
2019-02-05 08:52:23 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2022-01-27 19:03:20 +01:00
|
|
|
#include "errortypes.h"
|
2019-02-05 08:52:23 +01:00
|
|
|
#include "platform.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "testsuite.h"
|
|
|
|
#include "token.h"
|
|
|
|
#include "tokenize.h"
|
|
|
|
|
2022-01-27 19:03:20 +01:00
|
|
|
#include <iosfwd>
|
2022-08-19 18:23:15 +02:00
|
|
|
#include <sstream>
|
2022-01-27 19:03:20 +01:00
|
|
|
#include <string>
|
|
|
|
|
2019-02-05 08:52:23 +01:00
|
|
|
|
|
|
|
class TestSimplifyUsing : public TestFixture {
|
|
|
|
public:
|
2021-08-07 20:51:18 +02:00
|
|
|
TestSimplifyUsing() : TestFixture("TestSimplifyUsing") {}
|
2019-02-05 08:52:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
Settings settings0;
|
|
|
|
Settings settings1;
|
|
|
|
Settings settings2;
|
|
|
|
|
2022-02-10 23:02:24 +01:00
|
|
|
void run() override {
|
2021-02-24 22:00:06 +01:00
|
|
|
settings0.severity.enable(Severity::style);
|
|
|
|
settings2.severity.enable(Severity::style);
|
2019-02-05 08:52:23 +01:00
|
|
|
|
2020-11-22 16:43:36 +01:00
|
|
|
// If there are unused templates, keep those
|
|
|
|
settings0.checkUnusedTemplates = true;
|
|
|
|
settings1.checkUnusedTemplates = true;
|
|
|
|
settings2.checkUnusedTemplates = true;
|
|
|
|
|
2019-02-05 08:52:23 +01:00
|
|
|
TEST_CASE(simplifyUsing1);
|
|
|
|
TEST_CASE(simplifyUsing2);
|
|
|
|
TEST_CASE(simplifyUsing3);
|
|
|
|
TEST_CASE(simplifyUsing4);
|
|
|
|
TEST_CASE(simplifyUsing5);
|
|
|
|
TEST_CASE(simplifyUsing6);
|
|
|
|
TEST_CASE(simplifyUsing7);
|
|
|
|
TEST_CASE(simplifyUsing8);
|
|
|
|
TEST_CASE(simplifyUsing9);
|
|
|
|
TEST_CASE(simplifyUsing10);
|
|
|
|
TEST_CASE(simplifyUsing11);
|
|
|
|
TEST_CASE(simplifyUsing12);
|
|
|
|
TEST_CASE(simplifyUsing13);
|
|
|
|
TEST_CASE(simplifyUsing14);
|
|
|
|
TEST_CASE(simplifyUsing15);
|
|
|
|
TEST_CASE(simplifyUsing16);
|
2021-01-17 16:10:53 +01:00
|
|
|
TEST_CASE(simplifyUsing17);
|
2021-02-15 08:12:29 +01:00
|
|
|
TEST_CASE(simplifyUsing18);
|
2021-02-17 18:12:49 +01:00
|
|
|
TEST_CASE(simplifyUsing19);
|
2021-02-19 22:48:31 +01:00
|
|
|
TEST_CASE(simplifyUsing20);
|
2021-02-23 09:48:15 +01:00
|
|
|
TEST_CASE(simplifyUsing21);
|
|
|
|
TEST_CASE(simplifyUsing22);
|
2021-02-23 20:35:20 +01:00
|
|
|
TEST_CASE(simplifyUsing23);
|
2021-04-17 14:20:16 +02:00
|
|
|
TEST_CASE(simplifyUsing24);
|
2021-04-29 11:09:51 +02:00
|
|
|
TEST_CASE(simplifyUsing25);
|
2022-06-08 09:20:16 +02:00
|
|
|
TEST_CASE(simplifyUsing26); // #11090
|
2019-02-09 08:34:59 +01:00
|
|
|
|
|
|
|
TEST_CASE(simplifyUsing8970);
|
|
|
|
TEST_CASE(simplifyUsing8971);
|
2019-02-12 09:39:01 +01:00
|
|
|
TEST_CASE(simplifyUsing8976);
|
2019-03-26 07:09:56 +01:00
|
|
|
TEST_CASE(simplifyUsing9040);
|
2019-03-27 21:42:50 +01:00
|
|
|
TEST_CASE(simplifyUsing9042);
|
2019-07-06 20:22:13 +02:00
|
|
|
TEST_CASE(simplifyUsing9191);
|
2019-10-02 08:11:04 +02:00
|
|
|
TEST_CASE(simplifyUsing9381);
|
2019-10-03 21:13:03 +02:00
|
|
|
TEST_CASE(simplifyUsing9385);
|
2019-10-05 09:34:37 +02:00
|
|
|
TEST_CASE(simplifyUsing9388);
|
2019-12-05 20:51:36 +01:00
|
|
|
TEST_CASE(simplifyUsing9518);
|
2020-06-06 17:51:15 +02:00
|
|
|
TEST_CASE(simplifyUsing9757);
|
2020-12-26 13:45:17 +01:00
|
|
|
TEST_CASE(simplifyUsing10008);
|
2020-12-30 08:09:34 +01:00
|
|
|
TEST_CASE(simplifyUsing10054);
|
2021-02-05 15:50:32 +01:00
|
|
|
TEST_CASE(simplifyUsing10136);
|
2021-02-07 09:04:57 +01:00
|
|
|
TEST_CASE(simplifyUsing10171);
|
2021-02-11 08:08:45 +01:00
|
|
|
TEST_CASE(simplifyUsing10172);
|
2021-02-12 09:47:16 +01:00
|
|
|
TEST_CASE(simplifyUsing10173);
|
2021-07-02 06:19:26 +02:00
|
|
|
TEST_CASE(simplifyUsing10335);
|
2021-08-20 16:08:01 +02:00
|
|
|
|
|
|
|
TEST_CASE(scopeInfo1);
|
2021-08-21 10:10:40 +02:00
|
|
|
TEST_CASE(scopeInfo2);
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
2021-11-29 07:34:39 +01:00
|
|
|
#define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__)
|
|
|
|
std::string tok_(const char* file, int line, const char code[], Settings::PlatformType type = Settings::Native, bool debugwarnings = true) {
|
2019-02-05 08:52:23 +01:00
|
|
|
errout.str("");
|
|
|
|
|
2021-02-24 22:00:06 +01:00
|
|
|
settings0.certainty.enable(Certainty::inconclusive);
|
2019-02-05 08:52:23 +01:00
|
|
|
settings0.debugwarnings = debugwarnings;
|
|
|
|
settings0.platform(type);
|
|
|
|
Tokenizer tokenizer(&settings0, this);
|
|
|
|
|
|
|
|
std::istringstream istr(code);
|
2021-11-29 07:34:39 +01:00
|
|
|
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
|
2019-02-05 08:52:23 +01:00
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
return tokenizer.tokens()->stringifyList(nullptr);
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing1() {
|
|
|
|
const char code[] = "class A\n"
|
|
|
|
"{\n"
|
|
|
|
"public:\n"
|
|
|
|
" using duplicate = wchar_t;\n"
|
|
|
|
" void foo() {}\n"
|
|
|
|
"};\n"
|
|
|
|
"using duplicate = A;\n"
|
|
|
|
"int main()\n"
|
|
|
|
"{\n"
|
|
|
|
" duplicate a;\n"
|
|
|
|
" a.foo();\n"
|
|
|
|
" A::duplicate c = 0;\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"class A "
|
|
|
|
"{ "
|
|
|
|
"public: "
|
|
|
|
""
|
|
|
|
"void foo ( ) { } "
|
|
|
|
"} ; "
|
|
|
|
"int main ( ) "
|
|
|
|
"{ "
|
|
|
|
"A a ; "
|
|
|
|
"a . foo ( ) ; "
|
|
|
|
"wchar_t c ; c = 0 ; "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing2() {
|
|
|
|
const char code[] = "class A;\n"
|
|
|
|
"using duplicate = A;\n"
|
|
|
|
"class A\n"
|
|
|
|
"{\n"
|
|
|
|
"public:\n"
|
|
|
|
"using duplicate = wchar_t;\n"
|
|
|
|
"duplicate foo() { wchar_t b; return b; }\n"
|
|
|
|
"};";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"class A ; "
|
|
|
|
"class A "
|
|
|
|
"{ "
|
|
|
|
"public: "
|
|
|
|
""
|
|
|
|
"wchar_t foo ( ) { wchar_t b ; return b ; } "
|
|
|
|
"} ;";
|
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing3() {
|
|
|
|
const char code[] = "class A {};\n"
|
|
|
|
"using duplicate = A;\n"
|
|
|
|
"wchar_t foo()\n"
|
|
|
|
"{\n"
|
|
|
|
"using duplicate = wchar_t;\n"
|
|
|
|
"duplicate b;\n"
|
|
|
|
"return b;\n"
|
|
|
|
"}\n"
|
|
|
|
"int main()\n"
|
|
|
|
"{\n"
|
|
|
|
"duplicate b;\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"class A { } ; "
|
|
|
|
"wchar_t foo ( ) "
|
|
|
|
"{ "
|
|
|
|
""
|
|
|
|
"wchar_t b ; "
|
|
|
|
"return b ; "
|
|
|
|
"} "
|
|
|
|
"int main ( ) "
|
|
|
|
"{ "
|
|
|
|
"A b ; "
|
|
|
|
"}";
|
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing4() {
|
|
|
|
const char code[] = "using s32 = int;\n"
|
|
|
|
"using u32 = unsigned int;\n"
|
|
|
|
"void f()\n"
|
|
|
|
"{\n"
|
|
|
|
" s32 ivar = -2;\n"
|
|
|
|
" u32 uvar = 2;\n"
|
|
|
|
" return uvar / ivar;\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"void f ( ) "
|
|
|
|
"{ "
|
|
|
|
"int ivar ; ivar = -2 ; "
|
|
|
|
"unsigned int uvar ; uvar = 2 ; "
|
|
|
|
"return uvar / ivar ; "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing5() {
|
|
|
|
const char code[] =
|
|
|
|
"using YY_BUFFER_STATE = struct yy_buffer_state *;\n"
|
|
|
|
"void f()\n"
|
|
|
|
"{\n"
|
|
|
|
" YY_BUFFER_STATE state;\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"void f ( ) "
|
|
|
|
"{ "
|
|
|
|
"struct yy_buffer_state * state ; "
|
|
|
|
"}";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing6() {
|
|
|
|
const char code[] =
|
|
|
|
"namespace VL {\n"
|
|
|
|
" using float_t = float;\n"
|
|
|
|
" inline VL::float_t fast_atan2(VL::float_t y, VL::float_t x){}\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"namespace VL { "
|
|
|
|
""
|
|
|
|
"float fast_atan2 ( float y , float x ) { } "
|
|
|
|
"}";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing7() {
|
|
|
|
const char code[] = "using abc = int; "
|
|
|
|
"Fred :: abc f ;";
|
|
|
|
const char expected[] = "Fred :: abc f ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing8() {
|
|
|
|
const char code[] = "using INT = int;\n"
|
|
|
|
"using UINT = unsigned int;\n"
|
|
|
|
"using PINT = int *;\n"
|
|
|
|
"using PUINT = unsigned int *;\n"
|
|
|
|
"using RINT = int &;\n"
|
|
|
|
"using RUINT = unsigned int &;\n"
|
|
|
|
"using RCINT = const int &;\n"
|
|
|
|
"using RCUINT = const unsigned int &;\n"
|
|
|
|
"INT ti;\n"
|
|
|
|
"UINT tui;\n"
|
|
|
|
"PINT tpi;\n"
|
|
|
|
"PUINT tpui;\n"
|
|
|
|
"RINT tri;\n"
|
|
|
|
"RUINT trui;\n"
|
|
|
|
"RCINT trci;\n"
|
|
|
|
"RCUINT trcui;";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"int ti ; "
|
|
|
|
"unsigned int tui ; "
|
|
|
|
"int * tpi ; "
|
|
|
|
"unsigned int * tpui ; "
|
|
|
|
"int & tri ; "
|
|
|
|
"unsigned int & trui ; "
|
|
|
|
"const int & trci ; "
|
|
|
|
"const unsigned int & trcui ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing9() {
|
|
|
|
const char code[] = "using S = struct s;\n"
|
|
|
|
"using PS = S *;\n"
|
|
|
|
"using T = struct t { int a; };\n"
|
|
|
|
"using TP = T *;\n"
|
|
|
|
"using U = struct { int a; };\n"
|
|
|
|
"using V = U *;\n"
|
|
|
|
"using W = struct { int a; } *;\n"
|
|
|
|
"S s;\n"
|
|
|
|
"PS ps;\n"
|
|
|
|
"T t;\n"
|
|
|
|
"TP tp;\n"
|
|
|
|
"U u;\n"
|
|
|
|
"V v;\n"
|
|
|
|
"W w;";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"struct t { int a ; } ; "
|
|
|
|
"struct U { int a ; } ; "
|
|
|
|
"struct Unnamed0 { int a ; } ; "
|
|
|
|
"struct s s ; "
|
|
|
|
"struct s * ps ; "
|
|
|
|
"struct t t ; "
|
|
|
|
"struct t * tp ; "
|
|
|
|
"struct U u ; "
|
|
|
|
"struct U * v ; "
|
|
|
|
"struct Unnamed0 * w ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing10() {
|
|
|
|
const char code[] = "using S = union s;\n"
|
|
|
|
"using PS = S *;\n"
|
|
|
|
"using T = union t { int a; float b ; };\n"
|
|
|
|
"using TP = T *;\n"
|
|
|
|
"using U = union { int a; float b; };\n"
|
|
|
|
"using V = U *;\n"
|
|
|
|
"using W = union { int a; float b; } *;\n"
|
|
|
|
"S s;\n"
|
|
|
|
"PS ps;\n"
|
|
|
|
"T t;\n"
|
|
|
|
"TP tp;\n"
|
|
|
|
"U u;\n"
|
|
|
|
"V v;\n"
|
|
|
|
"W w;";
|
|
|
|
|
|
|
|
const char expected[] =
|
|
|
|
"union t { int a ; float b ; } ; "
|
|
|
|
"union U { int a ; float b ; } ; "
|
|
|
|
"union Unnamed0 { int a ; float b ; } ; "
|
|
|
|
"union s s ; "
|
|
|
|
"union s * ps ; "
|
|
|
|
"union t t ; "
|
|
|
|
"union t * tp ; "
|
|
|
|
"union U u ; "
|
|
|
|
"union U * v ; "
|
|
|
|
"union Unnamed0 * w ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing11() {
|
|
|
|
const char code[] = "using abc = enum { a = 0 , b = 1 , c = 2 };\n"
|
|
|
|
"using XYZ = enum xyz { x = 0 , y = 1 , z = 2 };\n"
|
|
|
|
"abc e1;\n"
|
|
|
|
"XYZ e2;";
|
|
|
|
|
|
|
|
const char expected[] = "enum abc { a = 0 , b = 1 , c = 2 } ; "
|
|
|
|
"enum xyz { x = 0 , y = 1 , z = 2 } ; "
|
|
|
|
"enum abc e1 ; "
|
|
|
|
"enum xyz e2 ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing12() {
|
|
|
|
const char code[] = "using V1 = vector<int>;\n"
|
|
|
|
"using V2 = std::vector<int>;\n"
|
|
|
|
"using V3 = std::vector<std::vector<int> >;\n"
|
|
|
|
"using IntListIterator = std::list<int>::iterator;\n"
|
|
|
|
"V1 v1;\n"
|
|
|
|
"V2 v2;\n"
|
|
|
|
"V3 v3;\n"
|
|
|
|
"IntListIterator iter;";
|
|
|
|
|
|
|
|
const char expected[] = "vector < int > v1 ; "
|
|
|
|
"std :: vector < int > v2 ; "
|
|
|
|
"std :: vector < std :: vector < int > > v3 ; "
|
|
|
|
"std :: list < int > :: iterator iter ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing13() {
|
|
|
|
const char code[] = "using Func = std::pair<int(*)(void*), void*>;\n"
|
|
|
|
"using CallQueue = std::vector<Func>;\n"
|
|
|
|
"int main() {\n"
|
|
|
|
" CallQueue q;\n"
|
|
|
|
"}";
|
|
|
|
|
|
|
|
const char expected[] = "int main ( ) { "
|
|
|
|
"std :: vector < std :: pair < int ( * ) ( void * ) , void * > > q ; "
|
|
|
|
"}";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing14() {
|
|
|
|
const char code[] = "template <typename F, unsigned int N> struct E"
|
|
|
|
"{"
|
|
|
|
" using v = E<F,(N>0)?(N-1):0>;"
|
|
|
|
" using val = typename add<v,v>::val;"
|
|
|
|
" FP_M(val);"
|
|
|
|
"};"
|
|
|
|
"template <typename F> struct E <F,0>"
|
|
|
|
"{"
|
|
|
|
" using nal = typename D<1>::val;"
|
|
|
|
" FP_M(val);"
|
|
|
|
"};";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
TODO_ASSERT_THROW(tok(code, Settings::Native, false), InternalError); // TODO: Do not throw AST validation exception
|
2020-03-07 21:46:38 +01:00
|
|
|
//ASSERT_EQUALS("", errout.str());
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing15() {
|
|
|
|
{
|
|
|
|
const char code[] = "using frame = char [10];\n"
|
|
|
|
"frame f;";
|
|
|
|
|
|
|
|
const char expected[] = "char f [ 10 ] ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const char code[] = "using frame = unsigned char [10];\n"
|
|
|
|
"frame f;";
|
|
|
|
|
|
|
|
const char expected[] = "unsigned char f [ 10 ] ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing16() {
|
|
|
|
const char code[] = "using MOT8 = char;\n"
|
|
|
|
"using CHFOO = MOT8 [4096];\n"
|
|
|
|
"using STRFOO = struct {\n"
|
|
|
|
" CHFOO freem;\n"
|
|
|
|
"};\n"
|
|
|
|
"STRFOO s;";
|
|
|
|
|
|
|
|
const char expected[] = "struct STRFOO { "
|
|
|
|
"char freem [ 4096 ] ; "
|
|
|
|
"} ; "
|
|
|
|
"struct STRFOO s ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-05 08:52:23 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
|
2021-01-17 16:10:53 +01:00
|
|
|
void simplifyUsing17() {
|
|
|
|
const char code[] = "class C1 {};\n"
|
|
|
|
"using S1 = class S1 {};\n"
|
|
|
|
"using S2 = class S2 : public C1 {};\n"
|
|
|
|
"using S3 = class {};\n"
|
|
|
|
"using S4 = class : public C1 {};\n"
|
|
|
|
"S1 s1;\n"
|
|
|
|
"S2 s2;\n"
|
|
|
|
"S3 s3;\n"
|
|
|
|
"S4 s4;";
|
|
|
|
|
|
|
|
const char expected[] = "class C1 { } ; "
|
|
|
|
"class S1 { } ; "
|
|
|
|
"class S2 : public C1 { } ; "
|
|
|
|
"class S3 { } ; "
|
|
|
|
"class S4 : public C1 { } ; "
|
|
|
|
"class S1 s1 ; "
|
|
|
|
"class S2 s2 ; "
|
|
|
|
"class S3 s3 ; "
|
|
|
|
"class S4 s4 ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2021-01-17 16:10:53 +01:00
|
|
|
}
|
|
|
|
|
2021-02-15 08:12:29 +01:00
|
|
|
void simplifyUsing18() {
|
|
|
|
const char code[] = "{ { { using a = a; using a; } } }";
|
2021-08-21 10:39:53 +02:00
|
|
|
tok(code); // don't crash
|
2021-02-15 08:12:29 +01:00
|
|
|
}
|
|
|
|
|
2021-02-17 18:12:49 +01:00
|
|
|
void simplifyUsing19() {
|
|
|
|
const char code[] = "namespace a {\n"
|
|
|
|
"using b = int;\n"
|
|
|
|
"void foo::c() { }\n"
|
|
|
|
"void foo::d() { }\n"
|
|
|
|
"void foo::e() {\n"
|
|
|
|
" using b = float;\n"
|
|
|
|
"}\n"
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
tok(code); // don't hang
|
2021-02-17 18:12:49 +01:00
|
|
|
}
|
|
|
|
|
2021-02-19 22:48:31 +01:00
|
|
|
void simplifyUsing20() {
|
|
|
|
const char code[] = "namespace a {\n"
|
|
|
|
"namespace b {\n"
|
|
|
|
"namespace c {\n"
|
|
|
|
"namespace d {\n"
|
|
|
|
"namespace e {\n"
|
|
|
|
"namespace f {\n"
|
|
|
|
"namespace g {\n"
|
|
|
|
"using Changeset = ::IAdaptionCallback::Changeset;\n"
|
|
|
|
"using EProperty = searches::EProperty;\n"
|
|
|
|
"using ChangesetValueType = Changeset::value_type;\n"
|
|
|
|
"namespace {\n"
|
|
|
|
" template <class T>\n"
|
|
|
|
" auto modify(std::shared_ptr<T>& p) -> boost::optional<decltype(p->modify())> {\n"
|
|
|
|
" return nullptr;\n"
|
|
|
|
" }\n"
|
|
|
|
" template <class T>\n"
|
|
|
|
" std::list<T> getValidElements() {\n"
|
|
|
|
" return nullptr;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"std::shared_ptr<ResourceConfiguration>\n"
|
|
|
|
"foo::getConfiguration() {\n"
|
|
|
|
" return nullptr;\n"
|
|
|
|
"}\n"
|
|
|
|
"void\n"
|
|
|
|
"foo::doRegister(const Input & Input) {\n"
|
|
|
|
" UNUSED( Input );\n"
|
|
|
|
"}\n"
|
|
|
|
"foo::MicroServiceReturnValue\n"
|
|
|
|
"foo::post(SearchesPtr element, const Changeset& changeset)\n"
|
|
|
|
"{\n"
|
|
|
|
" using EProperty = ab::ep;\n"
|
|
|
|
" static std::map<EProperty, std::pair<ElementPropertyHandler, CheckComponentState>> updateHandlers =\n"
|
|
|
|
" {\n"
|
|
|
|
" {EProperty::Needle, {&RSISearchesResource::updateNeedle, &RSISearchesResource::isSearcherReady}},\n"
|
|
|
|
" {EProperty::SortBy, {&RSISearchesResource::updateResultsSorting, &RSISearchesResource::isSearcherReady}}\n"
|
|
|
|
" };\n"
|
|
|
|
" return nullptr;\n"
|
|
|
|
"}\n"
|
|
|
|
"}}}}}}}";
|
2021-08-21 10:39:53 +02:00
|
|
|
tok(code); // don't hang
|
2021-02-19 22:48:31 +01:00
|
|
|
}
|
|
|
|
|
2021-02-23 09:48:15 +01:00
|
|
|
void simplifyUsing21() {
|
|
|
|
const char code[] = "using a = b;\n"
|
|
|
|
"enum {}";
|
2021-08-21 10:39:53 +02:00
|
|
|
tok(code); // don't crash
|
2021-02-23 09:48:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing22() {
|
|
|
|
const char code[] = "namespace aa { namespace bb { namespace cc { namespace dd { namespace ee {\n"
|
|
|
|
"class fff {\n"
|
|
|
|
"public:\n"
|
|
|
|
" using icmsp = std::shared_ptr<aa::bb::ee::cm::api::icm>;\n"
|
|
|
|
"private:\n"
|
|
|
|
" using Connection = boost::signals2::connection;\n"
|
|
|
|
" using ESdk = sdk::common::api::Sdk::ESdk;\n"
|
|
|
|
" using co = aa::bb::ee::com::api::com2;\n"
|
|
|
|
"};\n"
|
|
|
|
"fff::fff() : m_icm(icm) {\n"
|
|
|
|
" using ESdk = aa::bb::sdk::common::api::Sdk::ESdk;\n"
|
|
|
|
"}\n"
|
|
|
|
"}}}}}";
|
|
|
|
const char expected[] = "namespace aa { namespace bb { namespace cc { namespace dd { namespace ee { "
|
|
|
|
"class fff { "
|
|
|
|
"public: "
|
|
|
|
"private: "
|
|
|
|
"} ; "
|
|
|
|
"fff :: fff ( ) : m_icm ( icm ) { "
|
|
|
|
"} "
|
|
|
|
"} } } } }";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code)); // don't hang
|
2021-02-23 09:48:15 +01:00
|
|
|
}
|
|
|
|
|
2021-02-23 20:35:20 +01:00
|
|
|
void simplifyUsing23() {
|
|
|
|
const char code[] = "class cmcch {\n"
|
|
|
|
"public:\n"
|
|
|
|
" cmcch(icmsp const& icm, Rtnf&& rtnf = {});\n"
|
|
|
|
"private:\n"
|
|
|
|
" using escs = aa::bb::cc::dd::ee;\n"
|
|
|
|
"private:\n"
|
|
|
|
" icmsp m_icm;\n"
|
|
|
|
" mutable std::atomic<rt> m_rt;\n"
|
|
|
|
"};\n"
|
|
|
|
"cmcch::cmcch(cmcch::icmsp const& icm, Rtnf&& rtnf)\n"
|
|
|
|
" : m_icm(icm)\n"
|
|
|
|
" , m_rt{rt::UNKNOWN_} {\n"
|
|
|
|
" using escs = yy::zz::aa::bb::cc::dd::ee;\n"
|
|
|
|
"}";
|
|
|
|
const char expected[] = "class cmcch { "
|
|
|
|
"public: "
|
|
|
|
"cmcch ( const icmsp & icm , Rtnf && rtnf = { } ) ; "
|
|
|
|
"private: "
|
|
|
|
"private: "
|
|
|
|
"icmsp m_icm ; "
|
|
|
|
"mutable std :: atomic < rt > m_rt ; "
|
|
|
|
"} ; "
|
|
|
|
"cmcch :: cmcch ( const cmcch :: icmsp & icm , Rtnf && rtnf ) "
|
|
|
|
": m_icm ( icm ) "
|
|
|
|
", m_rt { rt :: UNKNOWN_ } { "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code)); // don't hang
|
2021-02-23 20:35:20 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 14:20:16 +02:00
|
|
|
void simplifyUsing24() {
|
|
|
|
const char code[] = "using value_type = const ValueFlow::Value;\n"
|
|
|
|
"value_type vt;";
|
|
|
|
const char expected[] = "const ValueFlow :: Value vt ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2021-04-17 14:20:16 +02:00
|
|
|
}
|
|
|
|
|
2021-04-29 11:09:51 +02:00
|
|
|
void simplifyUsing25() {
|
|
|
|
const char code[] = "struct UnusualType {\n"
|
|
|
|
" using T = vtkm::Id;\n"
|
|
|
|
" T X;\n"
|
|
|
|
"};\n"
|
|
|
|
"namespace vtkm {\n"
|
|
|
|
"template <>\n"
|
|
|
|
"struct VecTraits<UnusualType> : VecTraits<UnusualType::T> { };\n"
|
|
|
|
"}";
|
|
|
|
const char expected[] = "struct UnusualType { "
|
|
|
|
"vtkm :: Id X ; "
|
|
|
|
"} ; "
|
|
|
|
"namespace vtkm { "
|
|
|
|
"struct VecTraits<UnusualType> : VecTraits < vtkm :: Id > { } ; "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2021-04-29 11:09:51 +02:00
|
|
|
}
|
|
|
|
|
2022-06-08 09:20:16 +02:00
|
|
|
void simplifyUsing26() { // #11090
|
|
|
|
const char code[] = "namespace M {\n"
|
|
|
|
" struct A;\n"
|
|
|
|
" struct B;\n"
|
|
|
|
" struct C;\n"
|
|
|
|
" template<typename T>\n"
|
|
|
|
" struct F {};\n"
|
|
|
|
" template<>\n"
|
|
|
|
" struct F<B> : F<A> {};\n"
|
|
|
|
" template<>\n"
|
|
|
|
" struct F<C> : F<A> {};\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace N {\n"
|
|
|
|
" using namespace M;\n"
|
|
|
|
" using A = void;\n"
|
|
|
|
"}\n";
|
|
|
|
const char expected[] = "namespace M { "
|
|
|
|
"struct A ; struct B ; struct C ; "
|
|
|
|
"struct F<C> ; struct F<B> ; struct F<A> ; "
|
|
|
|
"struct F<B> : F<A> { } ; struct F<C> : F<A> { } ; "
|
|
|
|
"} "
|
|
|
|
"namespace N { "
|
|
|
|
"using namespace M ; "
|
|
|
|
"} "
|
|
|
|
"struct M :: F<A> { } ;";
|
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
|
|
|
}
|
|
|
|
|
2019-02-09 08:34:59 +01:00
|
|
|
void simplifyUsing8970() {
|
|
|
|
const char code[] = "using V = std::vector<int>;\n"
|
|
|
|
"struct A {\n"
|
|
|
|
" V p;\n"
|
|
|
|
"};";
|
|
|
|
|
|
|
|
const char expected[] = "struct A { "
|
|
|
|
"std :: vector < int > p ; "
|
|
|
|
"} ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-09 08:34:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing8971() {
|
|
|
|
const char code[] = "class A {\n"
|
|
|
|
"public:\n"
|
|
|
|
" using V = std::vector<double>;\n"
|
|
|
|
"};\n"
|
|
|
|
"using V = std::vector<int>;\n"
|
|
|
|
"class I {\n"
|
|
|
|
"private:\n"
|
|
|
|
" A::V v_;\n"
|
|
|
|
" V v2_;\n"
|
|
|
|
"};";
|
|
|
|
|
|
|
|
const char expected[] = "class A { "
|
|
|
|
"public: "
|
|
|
|
"} ; "
|
|
|
|
"class I { "
|
|
|
|
"private: "
|
|
|
|
"std :: vector < double > v_ ; "
|
|
|
|
"std :: vector < int > v2_ ; "
|
|
|
|
"} ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(expected, tok(code));
|
2019-02-09 08:34:59 +01:00
|
|
|
}
|
|
|
|
|
2019-02-12 09:39:01 +01:00
|
|
|
void simplifyUsing8976() {
|
|
|
|
const char code[] = "using mystring = std::string;";
|
|
|
|
|
|
|
|
const char exp[] = ";";
|
|
|
|
|
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
|
|
|
}
|
|
|
|
|
2019-03-26 07:09:56 +01:00
|
|
|
void simplifyUsing9040() {
|
|
|
|
const char code[] = "using BOOL = unsigned; int i;";
|
|
|
|
|
|
|
|
const char exp[] = "int i ;";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code, Settings::Unix32));
|
|
|
|
ASSERT_EQUALS(exp, tok(code, Settings::Unix64));
|
|
|
|
ASSERT_EQUALS(exp, tok(code, Settings::Win32A));
|
|
|
|
ASSERT_EQUALS(exp, tok(code, Settings::Win32W));
|
|
|
|
ASSERT_EQUALS(exp, tok(code, Settings::Win64));
|
2019-03-26 07:09:56 +01:00
|
|
|
}
|
|
|
|
|
2019-03-27 21:42:50 +01:00
|
|
|
void simplifyUsing9042() {
|
|
|
|
const char code[] = "template <class T>\n"
|
|
|
|
"class c {\n"
|
|
|
|
" int i = 0;\n"
|
|
|
|
" c() { i--; }\n"
|
|
|
|
"};\n"
|
|
|
|
"template <class T>\n"
|
|
|
|
"class s {};\n"
|
|
|
|
"using BOOL = char;";
|
|
|
|
|
|
|
|
const char exp[] = "template < class T > "
|
|
|
|
"class c { "
|
|
|
|
"int i ; i = 0 ; "
|
|
|
|
"c ( ) { i -- ; } "
|
2020-11-22 16:43:36 +01:00
|
|
|
"} ; "
|
|
|
|
"template < class T > class s { } ;";
|
2019-03-27 21:42:50 +01:00
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code, Settings::Win64));
|
2019-03-27 21:42:50 +01:00
|
|
|
}
|
|
|
|
|
2019-07-06 20:22:13 +02:00
|
|
|
void simplifyUsing9191() {
|
|
|
|
const char code[] = "namespace NS1 {\n"
|
|
|
|
" namespace NS2 {\n"
|
|
|
|
" using _LONG = signed long long;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"void f1() {\n"
|
|
|
|
" using namespace NS1;\n"
|
|
|
|
" NS2::_LONG A;\n"
|
|
|
|
"}\n"
|
|
|
|
"void f2() {\n"
|
|
|
|
" using namespace NS1::NS2;\n"
|
|
|
|
" _LONG A;\n"
|
|
|
|
"}";
|
|
|
|
|
2020-06-07 13:49:04 +02:00
|
|
|
const char exp[] = "void f1 ( ) { "
|
2019-07-06 20:22:13 +02:00
|
|
|
"using namespace NS1 ; "
|
|
|
|
"signed long long A ; "
|
|
|
|
"} "
|
|
|
|
"void f2 ( ) { "
|
|
|
|
"using namespace NS1 :: NS2 ; "
|
|
|
|
"signed long long A ; "
|
|
|
|
"}";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2019-07-06 20:22:13 +02:00
|
|
|
}
|
|
|
|
|
2019-10-02 08:11:04 +02:00
|
|
|
void simplifyUsing9381() {
|
|
|
|
const char code[] = "namespace ns {\n"
|
|
|
|
" class Result;\n"
|
|
|
|
" using UniqueResultPtr = std::unique_ptr<Result>;\n"
|
|
|
|
" class A {\n"
|
|
|
|
" public:\n"
|
|
|
|
" void func(UniqueResultPtr);\n"
|
|
|
|
" };\n"
|
|
|
|
" void A::func(UniqueResultPtr) {\n"
|
|
|
|
" }\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace ns { "
|
|
|
|
"class Result ; "
|
|
|
|
"class A { "
|
|
|
|
"public: "
|
|
|
|
"void func ( std :: unique_ptr < Result > ) ; "
|
|
|
|
"} ; "
|
|
|
|
"void A :: func ( std :: unique_ptr < Result > ) { "
|
|
|
|
"} "
|
|
|
|
"}";
|
|
|
|
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2019-10-02 08:11:04 +02:00
|
|
|
}
|
|
|
|
|
2019-10-03 21:13:03 +02:00
|
|
|
void simplifyUsing9385() {
|
|
|
|
{
|
|
|
|
const char code[] = "class A {\n"
|
|
|
|
"public:\n"
|
2019-10-08 19:30:41 +02:00
|
|
|
" using Foo = int;\n"
|
|
|
|
" A(Foo foo);\n"
|
|
|
|
" ~A();\n"
|
2019-10-03 21:13:03 +02:00
|
|
|
" void func(Foo foo);\n"
|
|
|
|
"};\n"
|
2019-10-08 19:30:41 +02:00
|
|
|
"A::A(Foo) { }\n"
|
|
|
|
"A::~A() { Foo foo; }\n"
|
2019-10-03 21:13:03 +02:00
|
|
|
"void A::func(Foo) { }";
|
|
|
|
const char exp[] = "class A { "
|
|
|
|
"public: "
|
2019-10-08 19:30:41 +02:00
|
|
|
"A ( int foo ) ; "
|
|
|
|
"~ A ( ) ; "
|
|
|
|
"void func ( int foo ) ; "
|
2019-10-03 21:13:03 +02:00
|
|
|
"} ; "
|
2019-10-08 19:30:41 +02:00
|
|
|
"A :: A ( int ) { } "
|
|
|
|
"A :: ~ A ( ) { int foo ; } "
|
|
|
|
"void A :: func ( int ) { }";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2019-10-03 21:13:03 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
const char code[] = "class A {\n"
|
|
|
|
"public:\n"
|
|
|
|
" struct B {\n"
|
2019-10-08 19:30:41 +02:00
|
|
|
" using Foo = int;\n"
|
|
|
|
" B(Foo foo);\n"
|
|
|
|
" ~B();\n"
|
|
|
|
" void func(Foo foo);\n"
|
2019-10-03 21:13:03 +02:00
|
|
|
" };\n"
|
|
|
|
"};\n"
|
2019-10-08 19:30:41 +02:00
|
|
|
"A::B::B(Foo) { }\n"
|
|
|
|
"A::B::~B() { Foo foo; }\n"
|
2019-10-03 21:13:03 +02:00
|
|
|
"void A::B::func(Foo) { }";
|
|
|
|
const char exp[] = "class A { "
|
|
|
|
"public: "
|
|
|
|
"struct B { "
|
2019-10-08 19:30:41 +02:00
|
|
|
"B ( int foo ) ; "
|
|
|
|
"~ B ( ) ; "
|
|
|
|
"void func ( int foo ) ; "
|
2019-10-03 21:13:03 +02:00
|
|
|
"} ; "
|
|
|
|
"} ; "
|
2019-10-08 19:30:41 +02:00
|
|
|
"A :: B :: B ( int ) { } "
|
|
|
|
"A :: B :: ~ B ( ) { int foo ; } "
|
|
|
|
"void A :: B :: func ( int ) { }";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2019-10-03 21:13:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-05 09:34:37 +02:00
|
|
|
void simplifyUsing9388() {
|
|
|
|
const char code[] = "class A {\n"
|
|
|
|
"public:\n"
|
|
|
|
" using Type = int;\n"
|
|
|
|
" A(Type&);\n"
|
|
|
|
" Type& t_;\n"
|
|
|
|
"};\n"
|
|
|
|
"A::A(Type& t) : t_(t) { }";
|
|
|
|
const char exp[] = "class A { "
|
|
|
|
"public: "
|
|
|
|
"A ( int & ) ; "
|
|
|
|
"int & t_ ; "
|
|
|
|
"} ; "
|
|
|
|
"A :: A ( int & t ) : t_ ( t ) { }";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2019-10-05 09:34:37 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 20:51:36 +01:00
|
|
|
void simplifyUsing9518() {
|
|
|
|
const char code[] = "namespace a {\n"
|
|
|
|
"using a = enum {};\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace a { "
|
|
|
|
"enum a { } ; "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2019-12-05 20:51:36 +01:00
|
|
|
}
|
|
|
|
|
2020-06-06 17:51:15 +02:00
|
|
|
void simplifyUsing9757() {
|
|
|
|
const char code[] = "enum class Type_t { Nil = 0 };\n"
|
|
|
|
"template<Type_t type> class MappedType { };\n"
|
|
|
|
"template<> class MappedType<Type_t::Nil> { using type = void; };\n"
|
|
|
|
"std::string to_string (Example::Type_t type) {\n"
|
|
|
|
" switch (type) {}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "enum class Type_t { Nil = 0 } ; "
|
|
|
|
"class MappedType<Type_t::Nil> ; "
|
|
|
|
"template < Type_t type > class MappedType { } ; "
|
|
|
|
"class MappedType<Type_t::Nil> { } ; "
|
|
|
|
"std :: string to_string ( Example :: Type_t type ) { "
|
|
|
|
"switch ( type ) { } }";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-06-06 17:51:15 +02:00
|
|
|
}
|
2020-12-26 13:45:17 +01:00
|
|
|
|
|
|
|
void simplifyUsing10008() {
|
|
|
|
const char code[] = "namespace ns {\n"
|
|
|
|
" using ArrayType = std::vector<int>;\n"
|
|
|
|
"}\n"
|
|
|
|
"using namespace ns;\n"
|
|
|
|
"static void f() {\n"
|
|
|
|
" const ArrayType arr;\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "using namespace ns ; "
|
|
|
|
"static void f ( ) { "
|
|
|
|
"const std :: vector < int > arr ; "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-12-26 13:45:17 +01:00
|
|
|
}
|
2020-12-30 08:09:34 +01:00
|
|
|
|
|
|
|
void simplifyUsing10054() { // debug: Executable scope 'x' with unknown function.
|
|
|
|
{
|
|
|
|
// original example: using "namespace external::ns1;" but redundant qualification
|
|
|
|
const char code[] = "namespace external {\n"
|
|
|
|
" namespace ns1 {\n"
|
|
|
|
" template <int size> struct B { };\n"
|
|
|
|
" using V = B<sizeof(bool)>;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" struct A {\n"
|
|
|
|
" void f(external::ns1::V);\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"using namespace external::ns1;\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void A::f(external::ns1::V) {}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace external { "
|
|
|
|
"namespace ns1 { "
|
|
|
|
"struct B<1> ; "
|
|
|
|
"} "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"struct A { "
|
|
|
|
"void f ( external :: ns1 :: B<1> ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"using namespace external :: ns1 ; "
|
|
|
|
"namespace ns { "
|
|
|
|
"void A :: f ( external :: ns1 :: B<1> ) { } "
|
|
|
|
"} "
|
|
|
|
"struct external :: ns1 :: B<1> { } ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-12-30 08:09:34 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// no using "namespace external::ns1;"
|
|
|
|
const char code[] = "namespace external {\n"
|
|
|
|
" namespace ns1 {\n"
|
|
|
|
" template <int size> struct B { };\n"
|
|
|
|
" using V = B<sizeof(bool)>;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" struct A {\n"
|
|
|
|
" void f(external::ns1::V);\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void A::f(external::ns1::V) {}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace external { "
|
|
|
|
"namespace ns1 { "
|
|
|
|
"struct B<1> ; "
|
|
|
|
"} "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"struct A { "
|
|
|
|
"void f ( external :: ns1 :: B<1> ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"void A :: f ( external :: ns1 :: B<1> ) { } "
|
|
|
|
"} "
|
|
|
|
"struct external :: ns1 :: B<1> { } ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-12-30 08:09:34 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// using "namespace external::ns1;" without redundant qualification
|
|
|
|
const char code[] = "namespace external {\n"
|
|
|
|
" namespace ns1 {\n"
|
|
|
|
" template <int size> struct B { };\n"
|
|
|
|
" using V = B<sizeof(bool)>;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" struct A {\n"
|
|
|
|
" void f(external::ns1::V);\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"using namespace external::ns1;\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void A::f(V) {}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace external { "
|
|
|
|
"namespace ns1 { "
|
|
|
|
"struct B<1> ; "
|
|
|
|
"} "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"struct A { "
|
|
|
|
"void f ( external :: ns1 :: B<1> ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"using namespace external :: ns1 ; "
|
|
|
|
"namespace ns { "
|
|
|
|
"void A :: f ( external :: ns1 :: B<1> ) { } "
|
|
|
|
"} "
|
|
|
|
"struct external :: ns1 :: B<1> { } ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-12-30 08:09:34 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// using "namespace external::ns1;" without redundant qualification on declaration and definition
|
|
|
|
const char code[] = "namespace external {\n"
|
|
|
|
" namespace ns1 {\n"
|
|
|
|
" template <int size> struct B { };\n"
|
|
|
|
" using V = B<sizeof(bool)>;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"using namespace external::ns1;\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" struct A {\n"
|
|
|
|
" void f(V);\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void A::f(V) {}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace external { "
|
|
|
|
"namespace ns1 { "
|
|
|
|
"struct B<1> ; "
|
|
|
|
"} "
|
|
|
|
"} "
|
|
|
|
"using namespace external :: ns1 ; "
|
|
|
|
"namespace ns { "
|
|
|
|
"struct A { "
|
|
|
|
"void f ( external :: ns1 :: B<1> ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"void A :: f ( external :: ns1 :: B<1> ) { } "
|
|
|
|
"} "
|
|
|
|
"struct external :: ns1 :: B<1> { } ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-12-30 08:09:34 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const char code[] = "namespace external {\n"
|
|
|
|
" template <int size> struct B { };\n"
|
|
|
|
" namespace ns1 {\n"
|
|
|
|
" using V = B<sizeof(bool)>;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" struct A {\n"
|
|
|
|
" void f(external::ns1::V);\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void A::f(external::ns1::V) {}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace external { "
|
|
|
|
"struct B<1> ; "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"struct A { "
|
|
|
|
"void f ( external :: B<1> ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"void A :: f ( external :: B<1> ) { } "
|
|
|
|
"} "
|
|
|
|
"struct external :: B<1> { } ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-12-30 08:09:34 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const char code[] = "template <int size> struct B { };\n"
|
|
|
|
"namespace external {\n"
|
|
|
|
" namespace ns1 {\n"
|
|
|
|
" using V = B<sizeof(bool)>;\n"
|
|
|
|
" }\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" struct A {\n"
|
|
|
|
" void f(external::ns1::V);\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void A::f(external::ns1::V) {}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "struct B<1> ; "
|
|
|
|
"namespace ns { "
|
|
|
|
"struct A { "
|
|
|
|
"void f ( B<1> ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"void A :: f ( B<1> ) { } "
|
|
|
|
"} "
|
|
|
|
"struct B<1> { } ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2020-12-30 08:09:34 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
}
|
2021-02-05 15:50:32 +01:00
|
|
|
|
|
|
|
void simplifyUsing10136() {
|
|
|
|
{
|
|
|
|
const char code[] = "class B {\n"
|
|
|
|
"public:\n"
|
|
|
|
" using V = std::vector<char>;\n"
|
|
|
|
" virtual void f(const V&) const = 0;\n"
|
|
|
|
"};\n"
|
|
|
|
"class A final : public B {\n"
|
|
|
|
"public:\n"
|
|
|
|
" void f(const V&) const override;\n"
|
|
|
|
"};\n"
|
|
|
|
"void A::f(const std::vector<char>&) const { }";
|
|
|
|
const char exp[] = "class B { "
|
|
|
|
"public: "
|
|
|
|
"virtual void f ( const std :: vector < char > & ) const = 0 ; "
|
|
|
|
"} ; "
|
|
|
|
"class A : public B { "
|
|
|
|
"public: "
|
|
|
|
"void f ( const std :: vector < char > & ) const override ; "
|
|
|
|
"} ; "
|
|
|
|
"void A :: f ( const std :: vector < char > & ) const { }";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-02-05 15:50:32 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const char code[] = "namespace NS1 {\n"
|
|
|
|
" class B {\n"
|
|
|
|
" public:\n"
|
|
|
|
" using V = std::vector<char>;\n"
|
|
|
|
" virtual void f(const V&) const = 0;\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace NS2 {\n"
|
|
|
|
" class A : public NS1::B {\n"
|
|
|
|
" public:\n"
|
|
|
|
" void f(const V&) const override;\n"
|
|
|
|
" };\n"
|
|
|
|
" namespace NS3 {\n"
|
|
|
|
" class C : public A {\n"
|
|
|
|
" public:\n"
|
|
|
|
" void f(const V&) const override;\n"
|
|
|
|
" };\n"
|
|
|
|
" void C::f(const V&) const { }\n"
|
|
|
|
" }\n"
|
|
|
|
" void A::f(const V&) const { }\n"
|
|
|
|
"}\n"
|
|
|
|
"void foo() {\n"
|
|
|
|
" NS2::A a;\n"
|
|
|
|
" NS2::NS3::C c;\n"
|
|
|
|
" NS1::B::V v;\n"
|
|
|
|
" a.f(v);\n"
|
|
|
|
" c.f(v);\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace NS1 { "
|
|
|
|
"class B { "
|
|
|
|
"public: "
|
|
|
|
"virtual void f ( const std :: vector < char > & ) const = 0 ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"namespace NS2 { "
|
|
|
|
"class A : public NS1 :: B { "
|
|
|
|
"public: "
|
|
|
|
"void f ( const std :: vector < char > & ) const override ; "
|
|
|
|
"} ; "
|
|
|
|
"namespace NS3 { "
|
|
|
|
"class C : public A { "
|
|
|
|
"public: "
|
|
|
|
"void f ( const std :: vector < char > & ) const override ; "
|
|
|
|
"} ; "
|
|
|
|
"void C :: f ( const std :: vector < char > & ) const { } "
|
|
|
|
"} "
|
|
|
|
"void A :: f ( const std :: vector < char > & ) const { } "
|
|
|
|
"} "
|
|
|
|
"void foo ( ) { "
|
|
|
|
"NS2 :: A a ; "
|
|
|
|
"NS2 :: NS3 :: C c ; "
|
|
|
|
"std :: vector < char > v ; "
|
|
|
|
"a . f ( v ) ; "
|
|
|
|
"c . f ( v ) ; "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-02-07 21:46:35 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
2021-02-05 15:50:32 +01:00
|
|
|
}
|
2021-02-09 14:19:01 +01:00
|
|
|
{
|
|
|
|
const char code[] = "foo::ResultCodes_e\n"
|
|
|
|
"GemImpl::setR(const ::foo::s _ipSource)\n"
|
|
|
|
"{\n"
|
|
|
|
" M3_LOG_EE_DEBUG();\n"
|
|
|
|
" using MLSource = foo::s::Literal;\n"
|
|
|
|
" auto ret = foo::ResultCodes_e::NO_ERROR;\n"
|
|
|
|
" M3_LOG_INFO(\"foo(\" << static_cast<int>(_ipSource) << \")\");\n"
|
|
|
|
" return ret;\n"
|
|
|
|
"}\n"
|
|
|
|
"foo::ResultCodes_e\n"
|
|
|
|
"GemImpl::getF(::foo::s &_ipSource)\n"
|
|
|
|
"{\n"
|
|
|
|
" M3_LOG_EE_DEBUG();\n"
|
|
|
|
" auto ret = foo::ResultCodes_e::NO_ERROR;\n"
|
|
|
|
" return ret;\n"
|
|
|
|
"}\n"
|
|
|
|
"foo::ResultCodes_e\n"
|
|
|
|
"GemImpl::setF(const ::foo::s _ipSource)\n"
|
|
|
|
"{\n"
|
|
|
|
" M3_LOG_EE_DEBUG();\n"
|
|
|
|
" using MLSource = foo::s::Literal;\n"
|
|
|
|
" auto ret = foo::ResultCodes_e::NO_ERROR;\n"
|
|
|
|
" return ret;\n"
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
tok(code); // don't crash
|
2021-02-09 14:19:01 +01:00
|
|
|
}
|
2021-02-05 15:50:32 +01:00
|
|
|
}
|
2021-02-07 09:04:57 +01:00
|
|
|
|
|
|
|
void simplifyUsing10171() {
|
|
|
|
const char code[] = "namespace ns {\n"
|
|
|
|
" class A {\n"
|
|
|
|
" public:\n"
|
|
|
|
" using V = std::vector<unsigned char>;\n"
|
|
|
|
" virtual void f(const V&) const = 0;\n"
|
|
|
|
" };\n"
|
|
|
|
" class B : public A {\n"
|
|
|
|
" public:\n"
|
|
|
|
" void f(const V&) const override;\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void B::f(const std::vector<unsigned char>&) const { }\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace ns { "
|
|
|
|
"class A { "
|
|
|
|
"public: "
|
|
|
|
"virtual void f ( const std :: vector < unsigned char > & ) const = 0 ; "
|
|
|
|
"} ; "
|
|
|
|
"class B : public A { "
|
|
|
|
"public: "
|
|
|
|
"void f ( const std :: vector < unsigned char > & ) const override ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"void B :: f ( const std :: vector < unsigned char > & ) const { } "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-02-11 08:08:45 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void simplifyUsing10172() {
|
|
|
|
{
|
|
|
|
const char code[] = "namespace ns {\n"
|
|
|
|
" class A {\n"
|
|
|
|
" public:\n"
|
|
|
|
" using h = std::function<void()>;\n"
|
|
|
|
" };\n"
|
|
|
|
" class B : public A {\n"
|
|
|
|
" void f(h);\n"
|
|
|
|
" };\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
" void B::f(h) { }\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace ns { "
|
|
|
|
"class A { "
|
|
|
|
"public: "
|
|
|
|
"} ; "
|
|
|
|
"class B : public A { "
|
|
|
|
"void f ( std :: function < void ( ) > ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"void B :: f ( std :: function < void ( ) > ) { } "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-02-11 08:08:45 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const char code[] = "namespace ns {\n"
|
|
|
|
"namespace external {\n"
|
|
|
|
"class A {\n"
|
|
|
|
"public: \n"
|
|
|
|
" using h = std::function<void()>;\n"
|
|
|
|
"};\n"
|
|
|
|
"class B : public A {\n"
|
|
|
|
" void f(h);\n"
|
|
|
|
"};\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
"namespace ns {\n"
|
|
|
|
"namespace external {\n"
|
|
|
|
"void B::f(h) {}\n"
|
|
|
|
"}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace ns { "
|
|
|
|
"namespace external { "
|
|
|
|
"class A { "
|
|
|
|
"public: "
|
|
|
|
"} ; "
|
|
|
|
"class B : public A { "
|
|
|
|
"void f ( std :: function < void ( ) > ) ; "
|
|
|
|
"} ; "
|
|
|
|
"} "
|
|
|
|
"} "
|
|
|
|
"namespace ns { "
|
|
|
|
"namespace external { "
|
|
|
|
"void B :: f ( std :: function < void ( ) > ) { } "
|
|
|
|
"} "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-02-11 08:08:45 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
2021-02-07 09:04:57 +01:00
|
|
|
}
|
2021-02-12 09:47:16 +01:00
|
|
|
|
|
|
|
void simplifyUsing10173() {
|
2021-02-12 16:21:51 +01:00
|
|
|
{
|
|
|
|
const char code[] = "std::ostream & operator<<(std::ostream &s, const Pr<st> p) {\n"
|
|
|
|
" return s;\n"
|
|
|
|
"}\n"
|
|
|
|
"void foo() {\n"
|
|
|
|
" using Pr = d::Pr<st>;\n"
|
|
|
|
" Pr p;\n"
|
|
|
|
"}\n"
|
|
|
|
"void bar() {\n"
|
|
|
|
" Pr<st> p;\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "std :: ostream & operator<< ( std :: ostream & s , const Pr < st > p ) { "
|
|
|
|
"return s ; "
|
|
|
|
"} "
|
|
|
|
"void foo ( ) { "
|
|
|
|
"d :: Pr < st > p ; "
|
|
|
|
"} "
|
|
|
|
"void bar ( ) { "
|
|
|
|
"Pr < st > p ; "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-02-12 16:21:51 +01:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
|
|
|
{
|
|
|
|
const char code[] = "namespace defsa {\n"
|
|
|
|
"void xxx::foo() {\n"
|
|
|
|
" using NS1 = v1::l;\n"
|
|
|
|
"}\n"
|
|
|
|
"void xxx::bar() {\n"
|
|
|
|
" using NS1 = v1::l;\n"
|
|
|
|
"}\n"
|
|
|
|
"void xxx::foobar() {\n"
|
|
|
|
" using NS1 = v1::l;\n"
|
|
|
|
"}\n"
|
|
|
|
"}";
|
|
|
|
const char exp[] = "namespace defsa { "
|
|
|
|
"void xxx :: foo ( ) { "
|
|
|
|
"} "
|
|
|
|
"void xxx :: bar ( ) { "
|
|
|
|
"} "
|
|
|
|
"void xxx :: foobar ( ) { "
|
|
|
|
"} "
|
|
|
|
"}";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-02-12 16:21:51 +01:00
|
|
|
}
|
2021-02-12 09:47:16 +01:00
|
|
|
}
|
2021-07-02 06:19:26 +02:00
|
|
|
|
|
|
|
void simplifyUsing10335() {
|
|
|
|
const char code[] = "using uint8_t = unsigned char;\n"
|
|
|
|
"enum E : uint8_t { E0 };";
|
|
|
|
const char exp[] = "enum E : unsigned char { E0 } ;";
|
2021-08-21 10:39:53 +02:00
|
|
|
ASSERT_EQUALS(exp, tok(code));
|
2021-07-02 06:19:26 +02:00
|
|
|
}
|
2021-08-20 16:08:01 +02:00
|
|
|
|
|
|
|
void scopeInfo1() {
|
|
|
|
const char code[] = "struct A {\n"
|
|
|
|
" enum class Mode { UNKNOWN, ENABLED, NONE, };\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
|
|
|
"namespace spdlog { class logger; }\n"
|
|
|
|
"using LoggerPtr = std::shared_ptr<spdlog::logger>;";
|
2021-08-21 10:39:53 +02:00
|
|
|
tok(code);
|
2021-08-20 16:08:01 +02:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
2021-08-21 10:10:40 +02:00
|
|
|
|
|
|
|
void scopeInfo2() {
|
|
|
|
const char code[] = "struct A {\n"
|
|
|
|
" using Map = std::map<int, int>;\n"
|
|
|
|
" Map values;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
|
|
|
"static void getInitialProgramState(const A::Map& vars = A::Map {})\n"
|
|
|
|
"{}\n";
|
2021-08-21 10:39:53 +02:00
|
|
|
tok(code);
|
2021-08-21 10:10:40 +02:00
|
|
|
ASSERT_EQUALS("", errout.str());
|
|
|
|
}
|
2019-02-05 08:52:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_TEST(TestSimplifyUsing)
|