enabled functionConst and functionStatic in selfcheck (#3862)
* fixed functionConst findings and enabled it in selfcheck * fixed functionStatic findings and enabled it in selfcheck * .travis_suppressions: adjusted comment * testimportproject.cpp: added missing asserts
This commit is contained in:
parent
8e8e6b1170
commit
4a63af02ed
|
@ -1,8 +1,6 @@
|
||||||
unusedPrivateFunction:test/testbufferoverrun.cpp
|
unusedPrivateFunction:test/testbufferoverrun.cpp
|
||||||
unusedPrivateFunction:test/testcmdlineparser.cpp
|
unusedPrivateFunction:test/testcmdlineparser.cpp
|
||||||
shadowFunction
|
shadowFunction
|
||||||
functionConst
|
|
||||||
functionStatic
|
|
||||||
bitwiseOnBoolean
|
bitwiseOnBoolean
|
||||||
|
|
||||||
# temporary suppressions - fix the warnings!
|
# temporary suppressions - fix the warnings!
|
||||||
|
@ -13,7 +11,7 @@ symbolDatabaseWarning:gui/temp/moc_*.cpp
|
||||||
simplifyUsing:gui/temp/moc_*.cpp
|
simplifyUsing:gui/temp/moc_*.cpp
|
||||||
symbolDatabaseWarning:tools/triage/moc_*.cpp
|
symbolDatabaseWarning:tools/triage/moc_*.cpp
|
||||||
|
|
||||||
# debug suppressions
|
# --debug-warnings suppressions
|
||||||
valueFlowBailout
|
valueFlowBailout
|
||||||
valueFlowBailoutIncompleteVar
|
valueFlowBailoutIncompleteVar
|
||||||
autoNoType
|
autoNoType
|
||||||
|
|
|
@ -302,7 +302,7 @@ static bool isOperatorFunction(const std::string & funcName)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CheckUnusedFunctions::check(ErrorLogger * const errorLogger, const Settings& settings)
|
bool CheckUnusedFunctions::check(ErrorLogger * const errorLogger, const Settings& settings) const
|
||||||
{
|
{
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
for (std::map<std::string, FunctionUsage>::const_iterator it = mFunctions.begin(); it != mFunctions.end(); ++it) {
|
for (std::map<std::string, FunctionUsage>::const_iterator it = mFunctions.begin(); it != mFunctions.end(); ++it) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
void parseTokens(const Tokenizer &tokenizer, const char FileName[], const Settings *settings);
|
void parseTokens(const Tokenizer &tokenizer, const char FileName[], const Settings *settings);
|
||||||
|
|
||||||
// Return true if an error is reported.
|
// Return true if an error is reported.
|
||||||
bool check(ErrorLogger * const errorLogger, const Settings& settings);
|
bool check(ErrorLogger * const errorLogger, const Settings& settings) const;
|
||||||
|
|
||||||
/** @brief Parse current TU and extract file info */
|
/** @brief Parse current TU and extract file info */
|
||||||
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
Check::FileInfo *getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const override;
|
||||||
|
|
|
@ -312,7 +312,7 @@ struct ForwardTraversal {
|
||||||
return Token::findsimplematch(endBlock->link(), "goto", endBlock);
|
return Token::findsimplematch(endBlock->link(), "goto", endBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasJump(const Token* endBlock) {
|
static bool hasJump(const Token* endBlock) {
|
||||||
return Token::findmatch(endBlock->link(), "goto|break", endBlock);
|
return Token::findmatch(endBlock->link(), "goto|break", endBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ private:
|
||||||
bool importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories, const std::vector<std::string> &fileFilters);
|
bool importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories, const std::vector<std::string> &fileFilters);
|
||||||
bool importBcb6Prj(const std::string &projectFilename);
|
bool importBcb6Prj(const std::string &projectFilename);
|
||||||
|
|
||||||
void printError(const std::string &message);
|
static void printError(const std::string &message);
|
||||||
|
|
||||||
void setRelativePaths(const std::string &filename);
|
void setRelativePaths(const std::string &filename);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct PathAnalysis {
|
||||||
|
|
||||||
void forward(const std::function<Progress(const Info&)>& f) const;
|
void forward(const std::function<Progress(const Info&)>& f) const;
|
||||||
|
|
||||||
Info forwardFind(std::function<bool(const Info&)> pred) {
|
Info forwardFind(std::function<bool(const Info&)> pred) const {
|
||||||
Info result{};
|
Info result{};
|
||||||
forward([&](const Info& info) {
|
forward([&](const Info& info) {
|
||||||
if (pred(info)) {
|
if (pred(info)) {
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ void SymbolDatabase::createSymbolDatabaseSetTypePointers()
|
||||||
|
|
||||||
const Type *type = findVariableType(tok->scope(), tok);
|
const Type *type = findVariableType(tok->scope(), tok);
|
||||||
if (type)
|
if (type)
|
||||||
const_cast<Token *>(tok)->type(type);
|
const_cast<Token *>(tok)->type(type); // TODO: avoid const_cast
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1428,7 +1428,7 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars()
|
||||||
continue;
|
continue;
|
||||||
if (mSettings->standards.cpp >= Standards::CPP20 && cpp20keywords.count(tok->str()) > 0)
|
if (mSettings->standards.cpp >= Standards::CPP20 && cpp20keywords.count(tok->str()) > 0)
|
||||||
continue;
|
continue;
|
||||||
const_cast<Token *>(tok)->isIncompleteVar(true);
|
const_cast<Token *>(tok)->isIncompleteVar(true); // TODO: avoid const_cast
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1450,10 +1450,12 @@ private:
|
||||||
void createSymbolDatabaseSetScopePointers();
|
void createSymbolDatabaseSetScopePointers();
|
||||||
void createSymbolDatabaseSetFunctionPointers(bool firstPass);
|
void createSymbolDatabaseSetFunctionPointers(bool firstPass);
|
||||||
void createSymbolDatabaseSetVariablePointers();
|
void createSymbolDatabaseSetVariablePointers();
|
||||||
|
// cppcheck-suppress functionConst
|
||||||
void createSymbolDatabaseSetTypePointers();
|
void createSymbolDatabaseSetTypePointers();
|
||||||
void createSymbolDatabaseSetSmartPointerType();
|
void createSymbolDatabaseSetSmartPointerType();
|
||||||
void createSymbolDatabaseEnums();
|
void createSymbolDatabaseEnums();
|
||||||
void createSymbolDatabaseEscapeFunctions();
|
void createSymbolDatabaseEscapeFunctions();
|
||||||
|
// cppcheck-suppress functionConst
|
||||||
void createSymbolDatabaseIncompleteVars();
|
void createSymbolDatabaseIncompleteVars();
|
||||||
|
|
||||||
void addClassFunction(Scope **scope, const Token **tok, const Token *argStart);
|
void addClassFunction(Scope **scope, const Token **tok, const Token *argStart);
|
||||||
|
|
|
@ -1824,7 +1824,7 @@ class SelectValueFromVarIdMapRange {
|
||||||
return mIt->second;
|
return mIt->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer operator->() {
|
pointer operator->() const {
|
||||||
return &mIt->second;
|
return &mIt->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.size());
|
ASSERT_EQUALS(1, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("TEST1=1;TEST2=2", importer.fileSettings.begin()->defines);
|
ASSERT_EQUALS("TEST1=1;TEST2=2", importer.fileSettings.begin()->defines);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.size());
|
ASSERT_EQUALS(1, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("C:/bar.c", importer.fileSettings.begin()->filename);
|
ASSERT_EQUALS("C:/bar.c", importer.fileSettings.begin()->filename);
|
||||||
#else
|
#else
|
||||||
|
@ -143,7 +143,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.size());
|
ASSERT_EQUALS(1, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("/bar.c", importer.fileSettings.begin()->filename);
|
ASSERT_EQUALS("/bar.c", importer.fileSettings.begin()->filename);
|
||||||
#endif
|
#endif
|
||||||
|
@ -157,7 +157,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.size());
|
ASSERT_EQUALS(1, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("/tmp/src.c", importer.fileSettings.begin()->filename);
|
ASSERT_EQUALS("/tmp/src.c", importer.fileSettings.begin()->filename);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(0, importer.fileSettings.size());
|
ASSERT_EQUALS(0, importer.fileSettings.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(2, importer.fileSettings.size());
|
ASSERT_EQUALS(2, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("C:/Users/dan/git/test-cppcheck/mylib/src/", importer.fileSettings.begin()->includePaths.front());
|
ASSERT_EQUALS("C:/Users/dan/git/test-cppcheck/mylib/src/", importer.fileSettings.begin()->includePaths.front());
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(2, importer.fileSettings.size());
|
ASSERT_EQUALS(2, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("C:/Users/dan/git/test-cppcheck/mylib/second src/", importer.fileSettings.begin()->includePaths.front());
|
ASSERT_EQUALS("C:/Users/dan/git/test-cppcheck/mylib/second src/", importer.fileSettings.begin()->includePaths.front());
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.size());
|
ASSERT_EQUALS(1, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("FILESDIR=\"/some/path\"", importer.fileSettings.begin()->defines);
|
ASSERT_EQUALS("FILESDIR=\"/some/path\"", importer.fileSettings.begin()->defines);
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.begin()->includePaths.size());
|
ASSERT_EQUALS(1, importer.fileSettings.begin()->includePaths.size());
|
||||||
|
@ -243,7 +243,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr); // Do not crash
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr)); // Do not crash
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommands9() const {
|
void importCompileCommands9() const {
|
||||||
|
@ -258,7 +258,7 @@ private:
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommandsArgumentsSection() const {
|
void importCompileCommandsArgumentsSection() const {
|
||||||
|
@ -267,7 +267,7 @@ private:
|
||||||
"\"file\": \"src.c\" } ]";
|
"\"file\": \"src.c\" } ]";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.size());
|
ASSERT_EQUALS(1, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("/tmp/src.c", importer.fileSettings.begin()->filename);
|
ASSERT_EQUALS("/tmp/src.c", importer.fileSettings.begin()->filename);
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ private:
|
||||||
"\"file\": \"src.mm\" } ]";
|
"\"file\": \"src.mm\" } ]";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
importer.importCompileCommands(istr);
|
ASSERT_EQUALS(false, importer.importCompileCommands(istr));
|
||||||
ASSERT_EQUALS(0, importer.fileSettings.size());
|
ASSERT_EQUALS(0, importer.fileSettings.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ private:
|
||||||
return library.load(doc);
|
return library.load(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void isCompliantValidationExpression() {
|
void isCompliantValidationExpression() const {
|
||||||
ASSERT_EQUALS(true, Library::isCompliantValidationExpression("-1"));
|
ASSERT_EQUALS(true, Library::isCompliantValidationExpression("-1"));
|
||||||
ASSERT_EQUALS(true, Library::isCompliantValidationExpression("1"));
|
ASSERT_EQUALS(true, Library::isCompliantValidationExpression("1"));
|
||||||
ASSERT_EQUALS(true, Library::isCompliantValidationExpression("1:"));
|
ASSERT_EQUALS(true, Library::isCompliantValidationExpression("1:"));
|
||||||
|
|
|
@ -262,7 +262,7 @@ private:
|
||||||
ASSERT_EQUALS(0, platform.long_long_bit);
|
ASSERT_EQUALS(0, platform.long_long_bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalid_config_file_1() {
|
void invalid_config_file_1() const {
|
||||||
// Invalid XML file: mismatching elements "boolt" vs "bool".
|
// Invalid XML file: mismatching elements "boolt" vs "bool".
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<platform>\n"
|
"<platform>\n"
|
||||||
|
|
|
@ -167,7 +167,7 @@ bool TestFixture::assertEquals(const char * const filename, const unsigned int l
|
||||||
return expected == actual;
|
return expected == actual;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TestFixture::deleteLineNumber(const std::string &message) const
|
std::string TestFixture::deleteLineNumber(const std::string &message)
|
||||||
{
|
{
|
||||||
std::string result(message);
|
std::string result(message);
|
||||||
// delete line number in "...:NUMBER:..."
|
// delete line number in "...:NUMBER:..."
|
||||||
|
@ -290,7 +290,7 @@ void TestFixture::assertNoThrowFail(const char * const filename, const unsigned
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestFixture::complainMissingLib(const char * const libname) const
|
void TestFixture::complainMissingLib(const char * const libname)
|
||||||
{
|
{
|
||||||
missingLibs.insert(libname);
|
missingLibs.insert(libname);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,8 @@ protected:
|
||||||
void assertThrow(const char * const filename, const unsigned int linenr) const;
|
void assertThrow(const char * const filename, const unsigned int linenr) const;
|
||||||
void assertThrowFail(const char * const filename, const unsigned int linenr) const;
|
void assertThrowFail(const char * const filename, const unsigned int linenr) const;
|
||||||
void assertNoThrowFail(const char * const filename, const unsigned int linenr) const;
|
void assertNoThrowFail(const char * const filename, const unsigned int linenr) const;
|
||||||
void complainMissingLib(const char * const libname) const;
|
static void complainMissingLib(const char * const libname);
|
||||||
std::string deleteLineNumber(const std::string &message) const;
|
static std::string deleteLineNumber(const std::string &message);
|
||||||
|
|
||||||
void setVerbose(bool v) {
|
void setVerbose(bool v) {
|
||||||
mVerbose = v;
|
mVerbose = v;
|
||||||
|
|
|
@ -84,7 +84,7 @@ private:
|
||||||
ASSERT_EQUALS("", suppressions.parseFile(s2));
|
ASSERT_EQUALS("", suppressions.parseFile(s2));
|
||||||
}
|
}
|
||||||
|
|
||||||
Suppressions::ErrorMessage errorMessage(const std::string &errorId) const {
|
static Suppressions::ErrorMessage errorMessage(const std::string &errorId) {
|
||||||
Suppressions::ErrorMessage ret;
|
Suppressions::ErrorMessage ret;
|
||||||
ret.errorId = errorId;
|
ret.errorId = errorId;
|
||||||
ret.hash = 0;
|
ret.hash = 0;
|
||||||
|
@ -93,7 +93,7 @@ private:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Suppressions::ErrorMessage errorMessage(const std::string &errorId, const std::string &file, int line) const {
|
static Suppressions::ErrorMessage errorMessage(const std::string &errorId, const std::string &file, int line) {
|
||||||
Suppressions::ErrorMessage ret;
|
Suppressions::ErrorMessage ret;
|
||||||
ret.errorId = errorId;
|
ret.errorId = errorId;
|
||||||
ret.setFileName(file);
|
ret.setFileName(file);
|
||||||
|
@ -484,13 +484,13 @@ private:
|
||||||
ASSERT_EQUALS(true, s2.isSuppressed(errorMessage("abc", "include/1.h", 142)));
|
ASSERT_EQUALS(true, s2.isSuppressed(errorMessage("abc", "include/1.h", 142)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void suppressionsLine0() {
|
void suppressionsLine0() const {
|
||||||
Suppressions suppressions;
|
Suppressions suppressions;
|
||||||
suppressions.addSuppressionLine("syntaxError:*:0");
|
suppressions.addSuppressionLine("syntaxError:*:0");
|
||||||
ASSERT_EQUALS(true, suppressions.isSuppressed(errorMessage("syntaxError", "test.cpp", 0)));
|
ASSERT_EQUALS(true, suppressions.isSuppressed(errorMessage("syntaxError", "test.cpp", 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void suppressionsFileComment() {
|
void suppressionsFileComment() const {
|
||||||
std::istringstream file1("# comment\nabc");
|
std::istringstream file1("# comment\nabc");
|
||||||
Suppressions suppressions1;
|
Suppressions suppressions1;
|
||||||
suppressions1.parseFile(file1);
|
suppressions1.parseFile(file1);
|
||||||
|
@ -746,7 +746,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void symbol() {
|
void symbol() const {
|
||||||
Suppressions::Suppression s;
|
Suppressions::Suppression s;
|
||||||
s.errorId = "foo";
|
s.errorId = "foo";
|
||||||
s.symbolName = "array*";
|
s.symbolName = "array*";
|
||||||
|
|
|
@ -1103,14 +1103,14 @@ private:
|
||||||
ASSERT(t == nullptr);
|
ASSERT(t == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void findClosingBracket() {
|
void findClosingBracket() const {
|
||||||
givenACodeSampleToTokenize var("template<typename X, typename...Y> struct S : public Fred<Wilma<Y...>> {}");
|
givenACodeSampleToTokenize var("template<typename X, typename...Y> struct S : public Fred<Wilma<Y...>> {}");
|
||||||
|
|
||||||
const Token* const t = var.tokens()->next()->findClosingBracket();
|
const Token* const t = var.tokens()->next()->findClosingBracket();
|
||||||
ASSERT(Token::simpleMatch(t, "> struct"));
|
ASSERT(Token::simpleMatch(t, "> struct"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void expressionString() {
|
void expressionString() const {
|
||||||
givenACodeSampleToTokenize var1("void f() { *((unsigned long long *)x) = 0; }");
|
givenACodeSampleToTokenize var1("void f() { *((unsigned long long *)x) = 0; }");
|
||||||
const Token *const tok1 = Token::findsimplematch(var1.tokens(), "*");
|
const Token *const tok1 = Token::findsimplematch(var1.tokens(), "*");
|
||||||
ASSERT_EQUALS("*((unsigned long long*)x)", tok1->expressionString());
|
ASSERT_EQUALS("*((unsigned long long*)x)", tok1->expressionString());
|
||||||
|
@ -1132,7 +1132,7 @@ private:
|
||||||
ASSERT_EQUALS("x=\"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\"", data6.tokens()->next()->expressionString());
|
ASSERT_EQUALS("x=\"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\"", data6.tokens()->next()->expressionString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void hasKnownIntValue() {
|
void hasKnownIntValue() const {
|
||||||
// pointer might be NULL
|
// pointer might be NULL
|
||||||
ValueFlow::Value v1(0);
|
ValueFlow::Value v1(0);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ private:
|
||||||
TEST_CASE(exampleAlgorithms);
|
TEST_CASE(exampleAlgorithms);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string testTokenRange(ConstTokenRange range, const Token* start, const Token* end) const {
|
static std::string testTokenRange(ConstTokenRange range, const Token* start, const Token* end) {
|
||||||
auto tokenToString = [](const Token* t) {
|
auto tokenToString = [](const Token* t) {
|
||||||
return t ? t->str() : "<null>";
|
return t ? t->str() : "<null>";
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@ private:
|
||||||
TEST_CASE(matchglob);
|
TEST_CASE(matchglob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void isValidGlobPattern() {
|
void isValidGlobPattern() const {
|
||||||
ASSERT_EQUALS(true, ::isValidGlobPattern("*"));
|
ASSERT_EQUALS(true, ::isValidGlobPattern("*"));
|
||||||
ASSERT_EQUALS(true, ::isValidGlobPattern("*x"));
|
ASSERT_EQUALS(true, ::isValidGlobPattern("*x"));
|
||||||
ASSERT_EQUALS(true, ::isValidGlobPattern("x*"));
|
ASSERT_EQUALS(true, ::isValidGlobPattern("x*"));
|
||||||
|
@ -52,7 +52,7 @@ private:
|
||||||
ASSERT_EQUALS(false, ::isValidGlobPattern("x??"));
|
ASSERT_EQUALS(false, ::isValidGlobPattern("x??"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void matchglob() {
|
void matchglob() const {
|
||||||
ASSERT_EQUALS(true, ::matchglob("*", "xyz"));
|
ASSERT_EQUALS(true, ::matchglob("*", "xyz"));
|
||||||
ASSERT_EQUALS(true, ::matchglob("x*", "xyz"));
|
ASSERT_EQUALS(true, ::matchglob("x*", "xyz"));
|
||||||
ASSERT_EQUALS(true, ::matchglob("*z", "xyz"));
|
ASSERT_EQUALS(true, ::matchglob("*z", "xyz"));
|
||||||
|
|
|
@ -1946,7 +1946,7 @@ private:
|
||||||
ASSERT(actual.find("X@2 = 0") != std::string::npos);
|
ASSERT(actual.find("X@2 = 0") != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getLine(const std::string &code, int lineNumber) {
|
static std::string getLine(const std::string &code, int lineNumber) {
|
||||||
std::string nr = MathLib::toString(lineNumber);
|
std::string nr = MathLib::toString(lineNumber);
|
||||||
const std::string::size_type pos1 = code.find('\n' + nr + ": ");
|
const std::string::size_type pos1 = code.find('\n' + nr + ": ");
|
||||||
if (pos1 == std::string::npos)
|
if (pos1 == std::string::npos)
|
||||||
|
|
Loading…
Reference in New Issue