@@ -3591,6 +3591,17 @@ class TestUninitVar : public TestFixture {
35913591 }
35923592
35933593#define valueFlowUninit (...) valueFlowUninit_(__FILE__, __LINE__, __VA_ARGS__)
3594+ template <size_t size>
3595+ void valueFlowUninit_ (const char * file, int line, const char (&code)[size], bool cpp = true)
3596+ {
3597+ SimpleTokenizer tokenizer (settings, *this , cpp);
3598+ ASSERT_LOC (tokenizer.tokenize (code), file, line);
3599+
3600+ // Check for redundant code..
3601+ CheckUninitVar checkuninitvar (&tokenizer, &settings, this );
3602+ (checkuninitvar.valueFlowUninit )();
3603+ }
3604+
35943605 void valueFlowUninit2_value ()
35953606 {
35963607 valueFlowUninit (" void f() {\n "
@@ -5467,18 +5478,27 @@ class TestUninitVar : public TestFixture {
54675478 TODO_ASSERT_EQUALS (" " , " [test.c:4:14]: (error) Uninitialized variable: d [legacyUninitvar]\n " , errout_str ());
54685479 }
54695480
5481+ #define ctu (...) ctu_(__FILE__, __LINE__, __VA_ARGS__)
54705482 template <size_t size>
5471- void valueFlowUninit_ (const char * file, int line, const char (&code)[size], bool cpp = true)
5472- {
5473- SimpleTokenizer tokenizer (settings, *this , cpp );
5483+ void ctu_ (const char * file, int line, const char (&code)[size]) {
5484+ // Tokenize..
5485+ SimpleTokenizer tokenizer (settings, *this );
54745486 ASSERT_LOC (tokenizer.tokenize (code), file, line);
54755487
5476- // Check for redundant code..
5477- CheckUninitVar checkuninitvar (&tokenizer, &settings, this );
5478- (checkuninitvar.valueFlowUninit )();
5488+ CTU::FileInfo *ctu = CTU::getFileInfo (tokenizer);
5489+
5490+ // Check code..
5491+ std::list<Check::FileInfo*> fileInfo;
5492+ Check& c = getCheck<CheckUninitVar>();
5493+ fileInfo.push_back (c.getFileInfo (tokenizer, settings, " " ));
5494+ c.analyseWholeProgram (*ctu, fileInfo, settings, *this ); // TODO: check result
5495+ while (!fileInfo.empty ()) {
5496+ delete fileInfo.back ();
5497+ fileInfo.pop_back ();
5498+ }
5499+ delete ctu;
54795500 }
54805501
5481- #define ctu (code ) ctu_(__FILE__, __LINE__, code)
54825502 void valueFlowUninitTest () {
54835503 // #9735 - FN
54845504 valueFlowUninit (" typedef struct\n "
@@ -7951,26 +7971,6 @@ class TestUninitVar : public TestFixture {
79517971 ASSERT_EQUALS (" " , errout_str ());
79527972 }
79537973
7954- template <size_t size>
7955- void ctu_ (const char * file, int line, const char (&code)[size]) {
7956- // Tokenize..
7957- SimpleTokenizer tokenizer (settings, *this );
7958- ASSERT_LOC (tokenizer.tokenize (code), file, line);
7959-
7960- CTU::FileInfo *ctu = CTU::getFileInfo (tokenizer);
7961-
7962- // Check code..
7963- std::list<Check::FileInfo*> fileInfo;
7964- Check& c = getCheck<CheckUninitVar>();
7965- fileInfo.push_back (c.getFileInfo (tokenizer, settings, " " ));
7966- c.analyseWholeProgram (*ctu, fileInfo, settings, *this ); // TODO: check result
7967- while (!fileInfo.empty ()) {
7968- delete fileInfo.back ();
7969- fileInfo.pop_back ();
7970- }
7971- delete ctu;
7972- }
7973-
79747974 void ctuTest () {
79757975 ctu (" void f(int *p) {\n "
79767976 " a = *p;\n "
0 commit comments