improve constness of functions as per cppchecks suggestions.

This commit is contained in:
Matthias Krüger 2017-01-07 14:13:22 +01:00
parent 3a742fdeb1
commit 064a4aa4cc
7 changed files with 11 additions and 11 deletions

View File

@ -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 ||
alloctype == CheckMemoryLeak::Pipe ||

View File

@ -95,7 +95,7 @@ public:
/** @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 };
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

View File

@ -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
std::set < const Token* > safeAstTokens; // list of "safe" AST tokens without endless recursion

View File

@ -139,7 +139,7 @@ public:
* Check abstract syntax tree.
* Throws InternalError on failure
*/
void validateAst();
void validateAst() const;
/**
* Verify that the given token is an element of the tokenlist.

View File

@ -33,7 +33,7 @@ private:
TEST_CASE(setIncludePaths2);
}
void setDefines() {
void setDefines() const {
ImportProject::FileSettings fs;
fs.setDefines("A");
@ -49,7 +49,7 @@ private:
ASSERT_EQUALS("A=1;B=1", fs.defines);
}
void setIncludePaths1() {
void setIncludePaths1() const {
ImportProject::FileSettings fs;
std::list<std::string> in;
in.push_back("../include");
@ -59,7 +59,7 @@ private:
ASSERT_EQUALS("abc/include/", fs.includePaths.front());
}
void setIncludePaths2() {
void setIncludePaths2() const {
ImportProject::FileSettings fs;
std::list<std::string> in;
in.push_back("$(SolutionDir)other");

View File

@ -341,7 +341,7 @@ private:
ASSERT_EQUALS(0x0A00000000000000LL, MathLib::toLongNumber("0x0A00000000000000LL"));
}
void toDoubleNumber() {
void toDoubleNumber() const {
ASSERT_EQUALS_DOUBLE(10.0 , MathLib::toDoubleNumber("10"));
ASSERT_EQUALS_DOUBLE(1000.0, MathLib::toDoubleNumber("10E+2"));
ASSERT_EQUALS_DOUBLE(100.0 , MathLib::toDoubleNumber("1.0E+2"));
@ -1133,7 +1133,7 @@ private:
ASSERT_EQUALS("-0" , MathLib::toString(-0.0L));
}
void characterLiteralsNormalization() {
void characterLiteralsNormalization() const {
// `A` is 0x41 and 0101
ASSERT_EQUALS("A" , MathLib::normalizeCharacterLiteral("\\x41"));
ASSERT_EQUALS("A" , MathLib::normalizeCharacterLiteral("\\101"));
@ -1154,7 +1154,7 @@ private:
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("123'0;", 3));
ASSERT(MathLib::isDigitSeparator("foo(1'2);", 5));

View File

@ -1222,7 +1222,7 @@ private:
ASSERT_EQUALS("\nabc ( 123 )", OurPreprocessor::expandMacros(filedata));
}
void va_args_5() {
void va_args_5() const {
const char filedata1[] = "#define A(...) #__VA_ARGS__\n"
"A(123)\n";
ASSERT_EQUALS("\n\"123\"", OurPreprocessor::expandMacros(filedata1));