improve constness of functions as per cppchecks suggestions.
This commit is contained in:
parent
3a742fdeb1
commit
064a4aa4cc
|
@ -267,7 +267,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::getDeallocationType(const Token *tok
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
void CheckMemoryLeak::memoryLeak(const Token *tok, const std::string &varname, AllocType alloctype)
|
void CheckMemoryLeak::memoryLeak(const Token *tok, const std::string &varname, AllocType alloctype) const
|
||||||
{
|
{
|
||||||
if (alloctype == CheckMemoryLeak::File ||
|
if (alloctype == CheckMemoryLeak::File ||
|
||||||
alloctype == CheckMemoryLeak::Pipe ||
|
alloctype == CheckMemoryLeak::Pipe ||
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
/** @brief What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */
|
/** @brief What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */
|
||||||
enum AllocType { No, Malloc, New, NewArray, File, Fd, Pipe, OtherMem, OtherRes, Many };
|
enum AllocType { No, Malloc, New, NewArray, File, Fd, Pipe, OtherMem, OtherRes, Many };
|
||||||
|
|
||||||
void memoryLeak(const Token *tok, const std::string &varname, AllocType alloctype);
|
void memoryLeak(const Token *tok, const std::string &varname, AllocType alloctype) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get type of deallocation at given position
|
* @brief Get type of deallocation at given position
|
||||||
|
|
|
@ -1117,7 +1117,7 @@ void TokenList::createAst()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TokenList::validateAst()
|
void TokenList::validateAst() const
|
||||||
{
|
{
|
||||||
// Check for some known issues in AST to avoid crash/hang later on
|
// Check for some known issues in AST to avoid crash/hang later on
|
||||||
std::set < const Token* > safeAstTokens; // list of "safe" AST tokens without endless recursion
|
std::set < const Token* > safeAstTokens; // list of "safe" AST tokens without endless recursion
|
||||||
|
|
|
@ -139,7 +139,7 @@ public:
|
||||||
* Check abstract syntax tree.
|
* Check abstract syntax tree.
|
||||||
* Throws InternalError on failure
|
* Throws InternalError on failure
|
||||||
*/
|
*/
|
||||||
void validateAst();
|
void validateAst() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that the given token is an element of the tokenlist.
|
* Verify that the given token is an element of the tokenlist.
|
||||||
|
|
|
@ -33,7 +33,7 @@ private:
|
||||||
TEST_CASE(setIncludePaths2);
|
TEST_CASE(setIncludePaths2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefines() {
|
void setDefines() const {
|
||||||
ImportProject::FileSettings fs;
|
ImportProject::FileSettings fs;
|
||||||
|
|
||||||
fs.setDefines("A");
|
fs.setDefines("A");
|
||||||
|
@ -49,7 +49,7 @@ private:
|
||||||
ASSERT_EQUALS("A=1;B=1", fs.defines);
|
ASSERT_EQUALS("A=1;B=1", fs.defines);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIncludePaths1() {
|
void setIncludePaths1() const {
|
||||||
ImportProject::FileSettings fs;
|
ImportProject::FileSettings fs;
|
||||||
std::list<std::string> in;
|
std::list<std::string> in;
|
||||||
in.push_back("../include");
|
in.push_back("../include");
|
||||||
|
@ -59,7 +59,7 @@ private:
|
||||||
ASSERT_EQUALS("abc/include/", fs.includePaths.front());
|
ASSERT_EQUALS("abc/include/", fs.includePaths.front());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIncludePaths2() {
|
void setIncludePaths2() const {
|
||||||
ImportProject::FileSettings fs;
|
ImportProject::FileSettings fs;
|
||||||
std::list<std::string> in;
|
std::list<std::string> in;
|
||||||
in.push_back("$(SolutionDir)other");
|
in.push_back("$(SolutionDir)other");
|
||||||
|
|
|
@ -341,7 +341,7 @@ private:
|
||||||
ASSERT_EQUALS(0x0A00000000000000LL, MathLib::toLongNumber("0x0A00000000000000LL"));
|
ASSERT_EQUALS(0x0A00000000000000LL, MathLib::toLongNumber("0x0A00000000000000LL"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void toDoubleNumber() {
|
void toDoubleNumber() const {
|
||||||
ASSERT_EQUALS_DOUBLE(10.0 , MathLib::toDoubleNumber("10"));
|
ASSERT_EQUALS_DOUBLE(10.0 , MathLib::toDoubleNumber("10"));
|
||||||
ASSERT_EQUALS_DOUBLE(1000.0, MathLib::toDoubleNumber("10E+2"));
|
ASSERT_EQUALS_DOUBLE(1000.0, MathLib::toDoubleNumber("10E+2"));
|
||||||
ASSERT_EQUALS_DOUBLE(100.0 , MathLib::toDoubleNumber("1.0E+2"));
|
ASSERT_EQUALS_DOUBLE(100.0 , MathLib::toDoubleNumber("1.0E+2"));
|
||||||
|
@ -1133,7 +1133,7 @@ private:
|
||||||
ASSERT_EQUALS("-0" , MathLib::toString(-0.0L));
|
ASSERT_EQUALS("-0" , MathLib::toString(-0.0L));
|
||||||
}
|
}
|
||||||
|
|
||||||
void characterLiteralsNormalization() {
|
void characterLiteralsNormalization() const {
|
||||||
// `A` is 0x41 and 0101
|
// `A` is 0x41 and 0101
|
||||||
ASSERT_EQUALS("A" , MathLib::normalizeCharacterLiteral("\\x41"));
|
ASSERT_EQUALS("A" , MathLib::normalizeCharacterLiteral("\\x41"));
|
||||||
ASSERT_EQUALS("A" , MathLib::normalizeCharacterLiteral("\\101"));
|
ASSERT_EQUALS("A" , MathLib::normalizeCharacterLiteral("\\101"));
|
||||||
|
@ -1154,7 +1154,7 @@ private:
|
||||||
ASSERT_THROW(MathLib::normalizeCharacterLiteral("\\c"), InternalError);
|
ASSERT_THROW(MathLib::normalizeCharacterLiteral("\\c"), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPP14DigitSeparators() { // Ticket #7137, #7565
|
void CPP14DigitSeparators() const { // Ticket #7137, #7565
|
||||||
ASSERT(MathLib::isDigitSeparator("'", 0) == false);
|
ASSERT(MathLib::isDigitSeparator("'", 0) == false);
|
||||||
ASSERT(MathLib::isDigitSeparator("123'0;", 3));
|
ASSERT(MathLib::isDigitSeparator("123'0;", 3));
|
||||||
ASSERT(MathLib::isDigitSeparator("foo(1'2);", 5));
|
ASSERT(MathLib::isDigitSeparator("foo(1'2);", 5));
|
||||||
|
|
|
@ -1222,7 +1222,7 @@ private:
|
||||||
ASSERT_EQUALS("\nabc ( 123 )", OurPreprocessor::expandMacros(filedata));
|
ASSERT_EQUALS("\nabc ( 123 )", OurPreprocessor::expandMacros(filedata));
|
||||||
}
|
}
|
||||||
|
|
||||||
void va_args_5() {
|
void va_args_5() const {
|
||||||
const char filedata1[] = "#define A(...) #__VA_ARGS__\n"
|
const char filedata1[] = "#define A(...) #__VA_ARGS__\n"
|
||||||
"A(123)\n";
|
"A(123)\n";
|
||||||
ASSERT_EQUALS("\n\"123\"", OurPreprocessor::expandMacros(filedata1));
|
ASSERT_EQUALS("\n\"123\"", OurPreprocessor::expandMacros(filedata1));
|
||||||
|
|
Loading…
Reference in New Issue