Splitted simplification out of tokenize()
This commit is contained in:
parent
c143b02e67
commit
4f0121ee2f
|
@ -305,7 +305,7 @@ void CppCheck::analyseFile(std::istream &fin, const std::string &filename)
|
||||||
Tokenizer tokenizer(&_settings, this);
|
Tokenizer tokenizer(&_settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, filename.c_str(), "");
|
tokenizer.tokenize(istr, filename.c_str(), "");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Analyse the tokens..
|
// Analyse the tokens..
|
||||||
std::set<std::string> data;
|
std::set<std::string> data;
|
||||||
|
@ -376,7 +376,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Timer timer3("Tokenizer::simplifyTokenList", _settings._showtime, &S_timerResults);
|
Timer timer3("Tokenizer::simplifyTokenList", _settings._showtime, &S_timerResults);
|
||||||
result = _tokenizer.simplifyTokenList();
|
result = _tokenizer.simplifyTokenList2();
|
||||||
timer3.Stop();
|
timer3.Stop();
|
||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
998
lib/tokenize.cpp
998
lib/tokenize.cpp
File diff suppressed because it is too large
Load Diff
|
@ -101,12 +101,20 @@ public:
|
||||||
void setVarId();
|
void setVarId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simplify tokenlist
|
* Basic simplification of tokenlist
|
||||||
*
|
*
|
||||||
* @return false if there is an error that requires aborting
|
* @return false if there is an error that requires aborting
|
||||||
* the checking of this file.
|
* the checking of this file.
|
||||||
*/
|
*/
|
||||||
bool simplifyTokenList();
|
bool simplifyTokenList1();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Most aggressive simplification of tokenlist
|
||||||
|
*
|
||||||
|
* @return false if there is an error that requires aborting
|
||||||
|
* the checking of this file.
|
||||||
|
*/
|
||||||
|
bool simplifyTokenList2();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes dead code between 'begin' and 'end'.
|
* Deletes dead code between 'begin' and 'end'.
|
||||||
|
|
|
@ -51,7 +51,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
|
|
||||||
// Ensure that the test case is not bad.
|
// Ensure that the test case is not bad.
|
||||||
|
|
|
@ -53,7 +53,7 @@ private:
|
||||||
|
|
||||||
if (runSimpleChecks) {
|
if (runSimpleChecks) {
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
if (str1 != str2)
|
if (str1 != str2)
|
||||||
warn(("Unsimplified code in test case. It looks like this test "
|
warn(("Unsimplified code in test case. It looks like this test "
|
||||||
|
|
|
@ -79,7 +79,7 @@ private:
|
||||||
// Check...
|
// Check...
|
||||||
CheckBool checkBool(&tokenizer, &settings, this);
|
CheckBool checkBool(&tokenizer, &settings, this);
|
||||||
checkBool.runChecks(&tokenizer, &settings, this);
|
checkBool.runChecks(&tokenizer, &settings, this);
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
checkBool.runSimplifiedChecks(&tokenizer, &settings, this);
|
checkBool.runSimplifiedChecks(&tokenizer, &settings, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
if (str1 != str2)
|
if (str1 != str2)
|
||||||
warn("Unsimplified code in test case");
|
warn("Unsimplified code in test case");
|
||||||
|
|
|
@ -53,7 +53,7 @@ private:
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
|
|
||||||
// Assign variable ids
|
// Assign variable ids
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
|
|
||||||
|
@ -3649,7 +3649,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, filename);
|
tokenizer.tokenize(istr, filename);
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for buffer overruns..
|
// Check for buffer overruns..
|
||||||
CheckBufferOverrun checkBufferOverrun(&tokenizer, &settings, this);
|
CheckBufferOverrun checkBufferOverrun(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -191,7 +191,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -303,7 +303,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -541,7 +541,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -666,7 +666,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -900,7 +900,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -1722,7 +1722,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -1977,7 +1977,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -2536,7 +2536,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
@ -2579,7 +2579,7 @@ private:
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
if (verify && str1 != str2)
|
if (verify && str1 != str2)
|
||||||
warn(("Unsimplified code in test case\nstr1="+str1+"\nstr2="+str2).c_str());
|
warn(("Unsimplified code in test case\nstr1="+str1+"\nstr2="+str2).c_str());
|
||||||
|
@ -5480,7 +5480,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
checkClass.initializerListOrder();
|
checkClass.initializerListOrder();
|
||||||
|
@ -5508,7 +5508,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
checkClass.initializationListUsage();
|
checkClass.initializationListUsage();
|
||||||
|
@ -5661,7 +5661,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
checkClass.checkPureVirtualFunctionCall();
|
checkClass.checkPureVirtualFunctionCall();
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check class constructors..
|
// Check class constructors..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for incomplete statements..
|
// Check for incomplete statements..
|
||||||
CheckOther checkOther(&tokenizer, &settings, this);
|
CheckOther checkOther(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -53,7 +53,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckInternal checkInternal;
|
CheckInternal checkInternal;
|
||||||
|
|
|
@ -82,7 +82,7 @@ private:
|
||||||
checkIO.checkWrongPrintfScanfArguments();
|
checkIO.checkWrongPrintfScanfArguments();
|
||||||
|
|
||||||
// Simplify token list..
|
// Simplify token list..
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
checkIO.checkCoutCerrMisusage();
|
checkIO.checkCoutCerrMisusage();
|
||||||
checkIO.checkFileUsage();
|
checkIO.checkFileUsage();
|
||||||
checkIO.invalidScanf();
|
checkIO.invalidScanf();
|
||||||
|
|
|
@ -122,7 +122,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.c");
|
tokenizer.tokenize(istr, "test.c");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for leaks..
|
// Check for leaks..
|
||||||
CheckLeakAutoVar c;
|
CheckLeakAutoVar c;
|
||||||
|
|
|
@ -136,7 +136,7 @@ private:
|
||||||
Tokenizer tokenizer(settings, this);
|
Tokenizer tokenizer(settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for memory leaks..
|
// Check for memory leaks..
|
||||||
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, settings, this);
|
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, settings, this);
|
||||||
|
@ -378,7 +378,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
if (!tokenizer.tokenize(istr, "test.cpp"))
|
if (!tokenizer.tokenize(istr, "test.cpp"))
|
||||||
return "";
|
return "";
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
const unsigned int varId(Token::findmatch(tokenizer.tokens(), varname)->varId());
|
const unsigned int varId(Token::findmatch(tokenizer.tokens(), varname)->varId());
|
||||||
|
|
||||||
|
@ -4009,7 +4009,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for memory leaks..
|
// Check for memory leaks..
|
||||||
CheckMemoryLeakInClass checkMemoryLeak(&tokenizer, &settings, this);
|
CheckMemoryLeakInClass checkMemoryLeak(&tokenizer, &settings, this);
|
||||||
|
@ -5129,7 +5129,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, fname ? fname : "test.cpp");
|
tokenizer.tokenize(istr, fname ? fname : "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for memory leaks..
|
// Check for memory leaks..
|
||||||
CheckMemoryLeakStructMember checkMemoryLeakStructMember(&tokenizer, &settings, this);
|
CheckMemoryLeakStructMember checkMemoryLeakStructMember(&tokenizer, &settings, this);
|
||||||
|
@ -5499,7 +5499,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for memory leaks..
|
// Check for memory leaks..
|
||||||
CheckMemoryLeakNoVar checkMemoryLeakNoVar(&tokenizer, &settings, this);
|
CheckMemoryLeakNoVar checkMemoryLeakNoVar(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -49,7 +49,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for non reentrant functions..
|
// Check for non reentrant functions..
|
||||||
CheckNonReentrantFunctions checkNonReentrantFunctions(&tokenizer, &settings, this);
|
CheckNonReentrantFunctions checkNonReentrantFunctions(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -98,7 +98,7 @@ private:
|
||||||
checkNullPointer.nullPointer();
|
checkNullPointer.nullPointer();
|
||||||
|
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
if (verify && str1 != str2)
|
if (verify && str1 != str2)
|
||||||
warn(("Unsimplified code in test case. It looks like this test "
|
warn(("Unsimplified code in test case. It looks like this test "
|
||||||
|
|
|
@ -81,7 +81,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, filename);
|
tokenizer.tokenize(istr, filename);
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for obsolete functions..
|
// Check for obsolete functions..
|
||||||
CheckObsoleteFunctions checkObsoleteFunctions(&tokenizer, &settings, this);
|
CheckObsoleteFunctions checkObsoleteFunctions(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -231,7 +231,7 @@ private:
|
||||||
|
|
||||||
if (runSimpleChecks) {
|
if (runSimpleChecks) {
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
if (str1 != str2)
|
if (str1 != str2)
|
||||||
warn(("Unsimplified code in test case\nstr1="+str1+"\nstr2="+str2).c_str());
|
warn(("Unsimplified code in test case\nstr1="+str1+"\nstr2="+str2).c_str());
|
||||||
|
@ -567,7 +567,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr,"test.cpp");
|
tokenizer.tokenize(istr,"test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Assert that the symboldatabase is inconsistent..
|
// Assert that the symboldatabase is inconsistent..
|
||||||
const SymbolDatabase *symbolDatabase = tokenizer.getSymbolDatabase();
|
const SymbolDatabase *symbolDatabase = tokenizer.getSymbolDatabase();
|
||||||
|
@ -5933,7 +5933,7 @@ private:
|
||||||
|
|
||||||
// Simplify token list..
|
// Simplify token list..
|
||||||
CheckOther checkOther(&tokenizer, &settings, this);
|
CheckOther checkOther(&tokenizer, &settings, this);
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
checkOther.checkRedundantCopy();
|
checkOther.checkRedundantCopy();
|
||||||
}
|
}
|
||||||
void checkRedundantCopy() {
|
void checkRedundantCopy() {
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for postfix operators..
|
// Check for postfix operators..
|
||||||
CheckPostfixOperator checkPostfixOperator(&tokenizer, &settings, this);
|
CheckPostfixOperator checkPostfixOperator(&tokenizer, &settings, this);
|
||||||
|
|
|
@ -470,7 +470,7 @@ private:
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
if (simplify)
|
if (simplify)
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
return tokenizer.tokens()->stringifyList(0, !simplify);
|
return tokenizer.tokens()->stringifyList(0, !simplify);
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ private:
|
||||||
|
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, filename);
|
tokenizer.tokenize(istr, filename);
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
return tokenizer.tokens()->stringifyList(0, false);
|
return tokenizer.tokens()->stringifyList(0, false);
|
||||||
}
|
}
|
||||||
|
@ -500,7 +500,7 @@ private:
|
||||||
tokenizer.tokenize(istr, filename);
|
tokenizer.tokenize(istr, filename);
|
||||||
|
|
||||||
if (simplify)
|
if (simplify)
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// result..
|
// result..
|
||||||
return tokenizer.tokens()->stringifyList(true);
|
return tokenizer.tokens()->stringifyList(true);
|
||||||
|
@ -3139,7 +3139,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
const char expect[] = "\n\n##file 0\n"
|
const char expect[] = "\n\n##file 0\n"
|
||||||
"1: void foo ( )\n"
|
"1: void foo ( )\n"
|
||||||
|
@ -3173,7 +3173,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
const char expect[] = "\n\n##file 0\n"
|
const char expect[] = "\n\n##file 0\n"
|
||||||
"1: void foo ( )\n"
|
"1: void foo ( )\n"
|
||||||
|
@ -4233,7 +4233,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
ASSERT_EQUALS(true, tokenizer.validate());
|
ASSERT_EQUALS(true, tokenizer.validate());
|
||||||
}
|
}
|
||||||
|
@ -4296,7 +4296,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
ASSERT_EQUALS(true, tokenizer.validate());
|
ASSERT_EQUALS(true, tokenizer.validate());
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check..
|
// Check..
|
||||||
CheckStl checkStl;
|
CheckStl checkStl;
|
||||||
|
|
|
@ -1020,7 +1020,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// force symbol database creation
|
// force symbol database creation
|
||||||
tokenizer.getSymbolDatabase();
|
tokenizer.getSymbolDatabase();
|
||||||
|
|
|
@ -572,7 +572,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, filename);
|
tokenizer.tokenize(istr, filename);
|
||||||
if (simplify)
|
if (simplify)
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
return tokenizer.tokens()->stringifyList(false, expand, false, true, false, 0, 0);
|
return tokenizer.tokens()->stringifyList(false, expand, false, true, false, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.c");
|
tokenizer.tokenize(istr, "test.c");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
ASSERT_EQUALS("[test.c:1]: (information) The code 'class x y {' is not handled. You can use -I or --include to add handling of this code.\n", errout.str());
|
ASSERT_EQUALS("[test.c:1]: (information) The code 'class x y {' is not handled. You can use -I or --include to add handling of this code.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
@ -3150,7 +3150,7 @@ private:
|
||||||
tokenizer.tokenize(istr, filename);
|
tokenizer.tokenize(istr, filename);
|
||||||
|
|
||||||
if (simplify)
|
if (simplify)
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// result..
|
// result..
|
||||||
return tokenizer.tokens()->stringifyList(true);
|
return tokenizer.tokens()->stringifyList(true);
|
||||||
|
@ -5422,7 +5422,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
ASSERT_EQUALS("void f ( ) { const char * a ; a = { \"hello more world\" } ; }", tokenizer.tokens()->stringifyList(0, false));
|
ASSERT_EQUALS("void f ( ) { const char * a ; a = { \"hello more world\" } ; }", tokenizer.tokens()->stringifyList(0, false));
|
||||||
}
|
}
|
||||||
|
@ -5449,7 +5449,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
ASSERT_EQUALS("void f ( ) { } void g ( ) { }", tokenizer.tokens()->stringifyList(0, false));
|
ASSERT_EQUALS("void f ( ) { } void g ( ) { }", tokenizer.tokens()->stringifyList(0, false));
|
||||||
}
|
}
|
||||||
|
@ -5472,7 +5472,7 @@ private:
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
ASSERT_EQUALS("void f ( Foo & foo , Foo * foo2 ) { foo . a = 90 ; foo2 . a = 45 ; }", tokenizer.tokens()->stringifyList(0, false));
|
ASSERT_EQUALS("void f ( Foo & foo , Foo * foo2 ) { foo . a = 90 ; foo2 . a = 45 ; }", tokenizer.tokens()->stringifyList(0, false));
|
||||||
}
|
}
|
||||||
|
@ -6064,7 +6064,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
ASSERT_EQUALS(true, tokenizer.tokenize(istr, "test.cpp"));
|
ASSERT_EQUALS(true, tokenizer.tokenize(istr, "test.cpp"));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, filename);
|
tokenizer.tokenize(istr, filename);
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check code..
|
// Check code..
|
||||||
CheckUninitVar check(&tokenizer, &settings, this);
|
CheckUninitVar check(&tokenizer, &settings, this);
|
||||||
|
@ -2071,7 +2071,7 @@ private:
|
||||||
tokenizer.tokenize(istr, fname);
|
tokenizer.tokenize(istr, fname);
|
||||||
|
|
||||||
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str1(tokenizer.tokens()->stringifyList(0,true));
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
const std::string str2(tokenizer.tokens()->stringifyList(0,true));
|
||||||
if (verify && str1 != str2)
|
if (verify && str1 != str2)
|
||||||
warn(("Unsimplified code in test case. It looks like this test "
|
warn(("Unsimplified code in test case. It looks like this test "
|
||||||
|
|
|
@ -85,7 +85,7 @@ private:
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
tokenizer.tokenize(istr, "test.cpp");
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
tokenizer.simplifyTokenList();
|
tokenizer.simplifyTokenList2();
|
||||||
|
|
||||||
// Check for unused private functions..
|
// Check for unused private functions..
|
||||||
CheckClass checkClass(&tokenizer, &settings, this);
|
CheckClass checkClass(&tokenizer, &settings, this);
|
||||||
|
|
Loading…
Reference in New Issue