diff --git a/lib/check.h b/lib/check.h index cf7d7996f..3e03c27f3 100644 --- a/lib/check.h +++ b/lib/check.h @@ -114,40 +114,13 @@ protected: ErrorLogger * const _errorLogger; /** report an error */ - void reportError(const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg) { - std::list callstack; - if (tok) - callstack.push_back(tok); - reportError(callstack, severity, id, msg); + void reportError(const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg, bool inconclusive = false) { + std::list callstack(1, tok); + reportError(callstack, severity, id, msg, inconclusive); } /** report an error */ - void reportError(const std::list &callstack, Severity::SeverityType severity, const std::string &id, const std::string& msg) { - reportError(callstack, severity, id, msg, false); - } - - /** report an inconclusive error */ - void reportInconclusiveError(const Token *tok, const Severity::SeverityType severity, const std::string &id, const std::string &msg) { - std::list callstack; - if (tok) - callstack.push_back(tok); - reportInconclusiveError(callstack, severity, id, msg); - } - - /** report an inconclusive error */ - void reportInconclusiveError(const std::list &callstack, Severity::SeverityType severity, const std::string &id, const std::string& msg) { - reportError(callstack, severity, id, msg, true); - } - - -private: - const std::string _name; - - /** disabled assignment operator */ - void operator=(const Check &); - - /** report an error */ - void reportError(const std::list &callstack, Severity::SeverityType severity, const std::string &id, const std::string& msg, bool inconclusive) { + void reportError(const std::list &callstack, Severity::SeverityType severity, const std::string &id, const std::string& msg, bool inconclusive = false) { ErrorLogger::ErrorMessage errmsg(callstack, _tokenizer?&_tokenizer->list:0, severity, id, msg, inconclusive); if (_errorLogger) _errorLogger->reportErr(errmsg); @@ -155,6 +128,11 @@ private: reportError(errmsg); } +private: + const std::string _name; + + /** disabled assignment operator */ + void operator=(const Check &); }; namespace std { diff --git a/lib/checkautovariables.cpp b/lib/checkautovariables.cpp index 8feb67818..4619d582f 100644 --- a/lib/checkautovariables.cpp +++ b/lib/checkautovariables.cpp @@ -208,12 +208,12 @@ void CheckAutoVariables::errorAutoVariableAssignment(const Token *tok, bool inco "stack is freed when the function ends. So the pointer to a local variable " "is invalid after the function ends."); } else { - reportInconclusiveError(tok, Severity::error, "autoVariables", - "Inconclusive: Assigning address of local auto-variable to a function parameter.\n" - "Inconclusive: function parameter takes the address of a local auto-variable. " - "Local auto-variables are reserved from the stack. And the stack is freed when " - "the function ends. The address is invalid after the function ends and it " - "might 'leak' from the function through the parameter."); + reportError(tok, Severity::error, "autoVariables", + "Assigning address of local auto-variable to a function parameter.\n" + "Function parameter takes the address of a local auto-variable. " + "Local auto-variables are reserved from the stack. And the stack is freed when " + "the function ends. The address is invalid after the function ends and it " + "might 'leak' from the function through the parameter.", true); } } diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index d4ebba796..c6ceb8fd8 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -112,7 +112,7 @@ void CheckBufferOverrun::possibleReadlinkBufferOverrunError(const Token* tok, co funcname + "() might return the full size of '" + varname + "'. Lower the supplied size by one. " "If a " + varname + "[len] = '\\0'; statement follows, it will overrun the buffer."; - reportInconclusiveError(tok, Severity::warning, "possibleReadlinkBufferOverrun", errmsg); + reportError(tok, Severity::warning, "possibleReadlinkBufferOverrun", errmsg, true); } void CheckBufferOverrun::strncatUsageError(const Token *tok) @@ -172,7 +172,7 @@ void CheckBufferOverrun::bufferNotZeroTerminatedError(const Token *tok, const st "The buffer '" + varname + "' is not zero-terminated after the call to " + function + "(). " "This will cause bugs later in the code if the code assumes the buffer is zero-terminated."; - reportInconclusiveError(tok, Severity::warning, "bufferNotZeroTerminated", errmsg); + reportError(tok, Severity::warning, "bufferNotZeroTerminated", errmsg, true); } //--------------------------------------------------------------------------- diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 8f0385803..4f3f011b1 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1425,13 +1425,13 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func) void CheckClass::checkConstError(const Token *tok, const std::string &classname, const std::string &funcname) { - reportInconclusiveError(tok, Severity::style, "functionConst", - "Technically the member function '" + classname + "::" + funcname + "' can be const.\n" - "The member function '" + classname + "::" + funcname + "' can be made a const " - "function. Making this function const function should not cause compiler errors. " - "Even though the function can be made const function technically it may not make " - "sense conceptually. Think about your design and task of the function first - is " - "it a function that must not change object internal state?"); + reportError(tok, Severity::style, "functionConst", + "Technically the member function '" + classname + "::" + funcname + "' can be const.\n" + "The member function '" + classname + "::" + funcname + "' can be made a const " + "function. Making this function const function should not cause compiler errors. " + "Even though the function can be made const function technically it may not make " + "sense conceptually. Think about your design and task of the function first - is " + "it a function that must not change object internal state?", true); } void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const std::string &classname, const std::string &funcname) @@ -1439,13 +1439,13 @@ void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const st std::list toks; toks.push_back(tok1); toks.push_back(tok2); - reportInconclusiveError(toks, Severity::style, "functionConst", - "Technically the member function '" + classname + "::" + funcname + "' can be const.\n" - "The member function '" + classname + "::" + funcname + "' can be made a const " - "function. Making this function const function should not cause compiler errors. " - "Even though the function can be made const function technically it may not make " - "sense conceptually. Think about your design and task of the function first - is " - "it a function that must not change object internal state?"); + reportError(toks, Severity::style, "functionConst", + "Technically the member function '" + classname + "::" + funcname + "' can be const.\n" + "The member function '" + classname + "::" + funcname + "' can be made a const " + "function. Making this function const function should not cause compiler errors. " + "Even though the function can be made const function technically it may not make " + "sense conceptually. Think about your design and task of the function first - is " + "it a function that must not change object internal state?", true); } //--------------------------------------------------------------------------- @@ -1527,11 +1527,11 @@ void CheckClass::initializerListError(const Token *tok1, const Token *tok2, cons std::list toks; toks.push_back(tok1); toks.push_back(tok2); - reportInconclusiveError(toks, Severity::style, "initializerList", - "Member variable '" + classname + "::" + - varname + "' is in the wrong order in the initializer list.\n" - "Members are initialized in the order they are declared, not the " - "order they are in the initializer list. Keeping the initializer list " - "in the same order that the members were declared prevents order dependent " - "initialization errors."); + reportError(toks, Severity::style, "initializerList", + "Member variable '" + classname + "::" + + varname + "' is in the wrong order in the initializer list.\n" + "Members are initialized in the order they are declared, not the " + "order they are in the initializer list. Keeping the initializer list " + "in the same order that the members were declared prevents order dependent " + "initialization errors.", true); } diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index c8224b3bc..3a7300274 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -1421,8 +1421,5 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var void CheckNullPointer::nullPointerError(const Token *tok, const std::string &varname, const unsigned int line, bool inconclusive) { const std::string errmsg("Possible null pointer dereference: " + varname + " - otherwise it is redundant to check if " + varname + " is null at line " + MathLib::toString(line)); - if (inconclusive) - reportInconclusiveError(tok, Severity::error, "nullPointer", errmsg); - else - reportError(tok, Severity::error, "nullPointer", errmsg); + reportError(tok, Severity::error, "nullPointer", errmsg, inconclusive); } diff --git a/lib/checkother.cpp b/lib/checkother.cpp index eba0c7614..c0e2c1944 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -259,8 +259,8 @@ void CheckOther::checkBitwiseOnBoolean() void CheckOther::bitwiseOnBooleanError(const Token *tok, const std::string &varname, const std::string &op) { - reportInconclusiveError(tok, Severity::style, "bitwiseOnBoolean", - "Boolean variable '" + varname + "' is used in bitwise operation. Did you mean " + op + " ?"); + reportError(tok, Severity::style, "bitwiseOnBoolean", + "Boolean variable '" + varname + "' is used in bitwise operation. Did you mean " + op + " ?", true); } void CheckOther::checkSuspiciousSemicolon() @@ -291,8 +291,8 @@ void CheckOther::checkSuspiciousSemicolon() void CheckOther::SuspiciousSemicolonError(const Token* tok) { - reportInconclusiveError(tok, Severity::warning, "suspiciousSemicolon", - "Suspicious use of ; at the end of 'if/for/while' statement."); + reportError(tok, Severity::warning, "suspiciousSemicolon", + "Suspicious use of ; at the end of 'if/for/while' statement.", true); } @@ -418,7 +418,7 @@ void CheckOther::invalidPointerCastError(const Token* tok, const std::string& fr if (!inconclusive) reportError(tok, Severity::portability, "invalidPointerCast", "Casting from " + from + "* to integer* is not portable due to different binary data representations on different platforms"); else - reportInconclusiveError(tok, Severity::portability, "invalidPointerCast", "Casting from " + from + "* to char* might be not portable due to different binary data representations on different platforms"); + reportError(tok, Severity::portability, "invalidPointerCast", "Casting from " + from + "* to char* might be not portable due to different binary data representations on different platforms", true); } else reportError(tok, Severity::warning, "invalidPointerCast", "Casting between " + from + "* and " + to + "* which have an incompatible binary data representation"); } @@ -613,11 +613,11 @@ void CheckOther::checkSizeofForPointerSize() void CheckOther::sizeofForPointerError(const Token *tok, const std::string &varname) { - reportInconclusiveError(tok, Severity::warning, "pointerSize", - "Using size of pointer " + varname + " instead of size of its data.\n" - "Using size of pointer " + varname + " instead of size of its data. " - "This is likely to lead to a buffer overflow. You probably intend to " - "write sizeof(*" + varname + ")"); + reportError(tok, Severity::warning, "pointerSize", + "Using size of pointer " + varname + " instead of size of its data.\n" + "Using size of pointer " + varname + " instead of size of its data. " + "This is likely to lead to a buffer overflow. You probably intend to " + "write sizeof(*" + varname + ")", true); } //--------------------------------------------------------------------------- @@ -1810,24 +1810,15 @@ void CheckOther::checkUnreachableCode() void CheckOther::duplicateBreakError(const Token *tok, bool inconclusive) { - if (inconclusive) - reportInconclusiveError(tok, Severity::style, "duplicateBreak", - "Consecutive return, break, continue, goto or throw statements are unnecessary.\n" - "The second of the two statements can never be executed, and so should be removed."); - else - reportError(tok, Severity::style, "duplicateBreak", - "Consecutive return, break, continue, goto or throw statements are unnecessary.\n" - "The second of the two statements can never be executed, and so should be removed."); + reportError(tok, Severity::style, "duplicateBreak", + "Consecutive return, break, continue, goto or throw statements are unnecessary.\n" + "The second of the two statements can never be executed, and so should be removed.", inconclusive); } void CheckOther::unreachableCodeError(const Token *tok, bool inconclusive) { - if (inconclusive) - reportInconclusiveError(tok, Severity::style, "unreachableCode", - "Statements following return, break, continue, goto or throw will never be executed."); - else - reportError(tok, Severity::style, "unreachableCode", - "Statements following return, break, continue, goto or throw will never be executed."); + reportError(tok, Severity::style, "unreachableCode", + "Statements following return, break, continue, goto or throw will never be executed.", inconclusive); } //--------------------------------------------------------------------------- @@ -1877,7 +1868,7 @@ void CheckOther::checkUnsignedDivision() void CheckOther::udivError(const Token *tok, bool inconclusive) { if (inconclusive) - reportInconclusiveError(tok, Severity::warning, "udivError", "Division with signed and unsigned operators. The result might be wrong."); + reportError(tok, Severity::warning, "udivError", "Division with signed and unsigned operators. The result might be wrong.", true); else reportError(tok, Severity::error, "udivError", "Unsigned division. The result will be wrong."); } @@ -3206,12 +3197,8 @@ void CheckOther::sizeofCalculation() void CheckOther::sizeofCalculationError(const Token *tok, bool inconclusive) { - if (inconclusive) - reportInconclusiveError(tok, Severity::warning, - "sizeofCalculation", "Found calculation inside sizeof()"); - else - reportError(tok, Severity::warning, - "sizeofCalculation", "Found calculation inside sizeof()"); + reportError(tok, Severity::warning, + "sizeofCalculation", "Found calculation inside sizeof()", inconclusive); } //----------------------------------------------------------------------------- @@ -3342,12 +3329,12 @@ void CheckOther::checkSignOfUnsignedVariable() void CheckOther::unsignedLessThanZeroError(const Token *tok, const std::string &varname, bool inconclusive) { if (inconclusive) { - reportInconclusiveError(tok, Severity::style, "unsignedLessThanZero", - "Checking if unsigned variable '" + varname + "' is less than zero. This might be a false warning.\n" - "Checking if unsigned variable '" + varname + "' is less than zero. An unsigned " - "variable will never be negative so it is either pointless or an error to check if it is. " - "It's not known if the used constant is a template parameter or not and therefore " - "this message might be a false warning"); + reportError(tok, Severity::style, "unsignedLessThanZero", + "Checking if unsigned variable '" + varname + "' is less than zero. This might be a false warning.\n" + "Checking if unsigned variable '" + varname + "' is less than zero. An unsigned " + "variable will never be negative so it is either pointless or an error to check if it is. " + "It's not known if the used constant is a template parameter or not and therefore " + "this message might be a false warning", true); } else { reportError(tok, Severity::style, "unsignedLessThanZero", "Checking if unsigned variable '" + varname + "' is less than zero.\n" @@ -3359,11 +3346,11 @@ void CheckOther::unsignedLessThanZeroError(const Token *tok, const std::string & void CheckOther::unsignedPositiveError(const Token *tok, const std::string &varname, bool inconclusive) { if (inconclusive) { - reportInconclusiveError(tok, Severity::style, "unsignedPositive", - "An unsigned variable '" + varname + "' can't be negative so it is unnecessary to test it. This might be a false warning.\n" - "An unsigned variable '" + varname + "' can't be negative so it is unnecessary to test it. " - "It's not known if the used constant is a " - "template parameter or not and therefore this message might be a false warning"); + reportError(tok, Severity::style, "unsignedPositive", + "An unsigned variable '" + varname + "' can't be negative so it is unnecessary to test it. This might be a false warning.\n" + "An unsigned variable '" + varname + "' can't be negative so it is unnecessary to test it. " + "It's not known if the used constant is a " + "template parameter or not and therefore this message might be a false warning", true); } else { reportError(tok, Severity::style, "unsignedPositive", "An unsigned variable '" + varname + "' can't be negative so it is unnecessary to test it."); diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index fc0564c3b..8e5d90abd 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -285,8 +285,12 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string std::ostringstream text; if (!_callStack.empty()) text << callStackToString(_callStack) << ": "; - if (_severity != Severity::none) - text << '(' << Severity::toString(_severity) << ") "; + if (_severity != Severity::none) { + text << '(' << Severity::toString(_severity); + if (_inconclusive) + text << ", inconclusive"; + text << ") "; + } text << (verbose ? _verboseMessage : _shortMessage); return text.str(); } diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp index 27adc7918..c56699d13 100644 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -186,7 +186,7 @@ private: " char a;\n" " ab->a = &a;\n" "}", true); - ASSERT_EQUALS("[test.cpp:4]: (error) Inconclusive: Assigning address of local auto-variable to a function parameter.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (error, inconclusive) Assigning address of local auto-variable to a function parameter.\n", errout.str()); } void testautovar6() { // ticket #2931 @@ -202,7 +202,7 @@ private: " char a[10];\n" " x->str = a;\n" "}", true); - ASSERT_EQUALS("[test.cpp:4]: (error) Inconclusive: Assigning address of local auto-variable to a function parameter.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (error, inconclusive) Assigning address of local auto-variable to a function parameter.\n", errout.str()); } void testautovar7() { // ticket #3066 diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 9faed9af8..16afb56bb 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -3165,7 +3165,7 @@ private: " char c[6];\n" " strncpy(c,\"hello!\",sizeof(c));\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (warning) The buffer 'c' is not zero-terminated after the call to strncpy().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) The buffer 'c' is not zero-terminated after the call to strncpy().\n", errout.str()); check("void f()\n" "{\n" @@ -3565,21 +3565,21 @@ private: " char c[6];\n" " strncpy(c,\"hello!\",sizeof(c));\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (warning) The buffer 'c' is not zero-terminated after the call to strncpy().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) The buffer 'c' is not zero-terminated after the call to strncpy().\n", errout.str()); check("void f()\n" "{\n" " char c[6];\n" " memcpy(c,\"hello!\",sizeof(c));\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (warning) The buffer 'c' is not zero-terminated after the call to memcpy().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) The buffer 'c' is not zero-terminated after the call to memcpy().\n", errout.str()); check("void f()\n" "{\n" " char c[6];\n" " memmove(c,\"hello!\",sizeof(c));\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (warning) The buffer 'c' is not zero-terminated after the call to memmove().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) The buffer 'c' is not zero-terminated after the call to memmove().\n", errout.str()); } void readlink() { @@ -3589,7 +3589,7 @@ private: " ssize_t len = readlink(path, buf, sizeof(buf)-1);\n" " printf(\"%s\n\", buf);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (warning) The buffer 'buf' is not zero-terminated after the call to readlink().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) The buffer 'buf' is not zero-terminated after the call to readlink().\n", errout.str()); // C only: Primitive pointer simplification check("void f()\n" @@ -3598,7 +3598,7 @@ private: " ssize_t len = readlink(path, &buf[0], sizeof(buf)-1);\n" " printf(\"%s\n\", buf);\n" "}\n", true, "test.c"); - ASSERT_EQUALS("[test.c:4]: (warning) The buffer 'buf' is not zero-terminated after the call to readlink().\n", errout.str()); + ASSERT_EQUALS("[test.c:4]: (warning, inconclusive) The buffer 'buf' is not zero-terminated after the call to readlink().\n", errout.str()); check("void f()\n" "{\n" @@ -3622,7 +3622,7 @@ private: " ssize_t len = readlink(path, buf, sizeof(buf));\n" " buf[len] = 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (warning) readlink() might return the full size of 'buf'. Lower the supplied size by one.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) readlink() might return the full size of 'buf'. Lower the supplied size by one.\n", errout.str()); check("void f()\n" "{\n" @@ -3644,7 +3644,7 @@ private: " ssize_t len = readlinkat(dirfd, path, buf, sizeof(buf)-1);\n" " printf(\"%s\n\", buf);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (warning) The buffer 'buf' is not zero-terminated after the call to readlinkat().\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (warning, inconclusive) The buffer 'buf' is not zero-terminated after the call to readlinkat().\n", errout.str()); check("void f()\n" "{\n" @@ -3671,7 +3671,7 @@ private: " ssize_t len = readlinkat(dirfd, path, buf, sizeof(buf));\n" " buf[len] = 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (warning) readlinkat() might return the full size of 'buf'. Lower the supplied size by one.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (warning, inconclusive) readlinkat() might return the full size of 'buf'. Lower the supplied size by one.\n", errout.str()); check("void f()\n" "{\n" diff --git a/test/testclass.cpp b/test/testclass.cpp index 7b7fdfa78..62b3dffc6 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -3613,18 +3613,18 @@ private: " int a;\n" " int getA() { return a; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::getA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::getA' can be const.\n", errout.str()); checkConst("class Fred {\n" " const std::string foo() { return ""; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); checkConst("class Fred {\n" " std::string s;\n" " const std::string & foo() { return ""; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // constructors can't be const.. checkConst("class Fred {\n" @@ -3656,7 +3656,7 @@ private: " int a() const { return x; }\n" " void b() { a(); }\n" "};"); - ASSERT_EQUALS("[test.cpp:5]: (style) Technically the member function 'Fred::b' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::b' can be const.\n", errout.str()); // static functions can't be const.. checkConst("class foo\n" @@ -3687,7 +3687,7 @@ private: " std::string s;\n" " void foo(std::string & a) { a = s; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable can't be const checkConst("class Fred {\n" @@ -3701,7 +3701,7 @@ private: " std::string s;\n" " void foo(std::string & a, std::string & b) { a = s; b = s; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3731,7 +3731,7 @@ private: " int s;\n" " void foo(int * a) { *a = s; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3745,7 +3745,7 @@ private: " std::string s;\n" " void foo(std::string * a, std::string * b) { *a = s; *b = s; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3775,20 +3775,20 @@ private: " int getA();\n" "};\n" "int Fred::getA() { return a; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Technically the member function 'Fred::getA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::getA' can be const.\n", errout.str()); checkConst("class Fred {\n" " const std::string foo();\n" "};\n" "const std::string Fred::foo() { return ""; }"); - ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); checkConst("class Fred {\n" " std::string s;\n" " const std::string & foo();\n" "};\n" "const std::string & Fred::foo() { return ""; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // constructors can't be const.. checkConst("class Fred {\n" @@ -3841,7 +3841,7 @@ private: " void foo(std::string & a);\n" "};\n" "void Fred::foo(std::string & a) { a = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable can't be const checkConst("class Fred {\n" @@ -3857,7 +3857,7 @@ private: " void foo(std::string & a, std::string & b);\n" "};\n" "void Fred::foo(std::string & a, std::string & b) { a = s; b = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3889,7 +3889,7 @@ private: " void foo(int * a);\n" "};\n" "void Fred::foo(int * a) { *a = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3905,7 +3905,7 @@ private: " void foo(std::string * a, std::string * b);\n" "};\n" "void Fred::foo(std::string * a, std::string * b) { *a = s; *b = s; }"); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // assignment to variable, can't be const checkConst("class Fred {\n" @@ -3941,8 +3941,8 @@ private: "void Fred::foo() { }" "void Fred::foo(std::string & a) { a = s; }" "void Fred::foo(const std::string & a) { s = a; }"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (style) Technically the member function 'Fred::foo' can be const.\n" - "[test.cpp:7] -> [test.cpp:4]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n" + "[test.cpp:7] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); // check functions with different or missing parameter names checkConst("class Fred {\n" @@ -3958,11 +3958,11 @@ private: "void Fred::foo3(int a, int b) { }\n" "void Fred::foo4(int a, int b) { }\n" "void Fred::foo5(int, int) { }"); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:3]: (style) Technically the member function 'Fred::foo1' can be const.\n" - "[test.cpp:10] -> [test.cpp:4]: (style) Technically the member function 'Fred::foo2' can be const.\n" - "[test.cpp:11] -> [test.cpp:5]: (style) Technically the member function 'Fred::foo3' can be const.\n" - "[test.cpp:12] -> [test.cpp:6]: (style) Technically the member function 'Fred::foo4' can be const.\n" - "[test.cpp:13] -> [test.cpp:7]: (style) Technically the member function 'Fred::foo5' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::foo1' can be const.\n" + "[test.cpp:10] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::foo2' can be const.\n" + "[test.cpp:11] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::foo3' can be const.\n" + "[test.cpp:12] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'Fred::foo4' can be const.\n" + "[test.cpp:13] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::foo5' can be const.\n", errout.str()); // check nested classes checkConst("class Fred {\n" @@ -3971,7 +3971,7 @@ private: " int getA() { return a; }\n" " };\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'Fred::A::getA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::A::getA' can be const.\n", errout.str()); checkConst("class Fred {\n" " class A {\n" @@ -3980,7 +3980,7 @@ private: " };\n" " int A::getA() { return a; }\n" "};"); - ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:4]: (style) Technically the member function 'Fred::A::getA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::A::getA' can be const.\n", errout.str()); checkConst("class Fred {\n" " class A {\n" @@ -3989,7 +3989,7 @@ private: " };\n" "};\n" "int Fred::A::getA() { return a; }"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:4]: (style) Technically the member function 'Fred::A::getA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::A::getA' can be const.\n", errout.str()); // check deeply nested classes checkConst("class Fred {\n" @@ -4002,8 +4002,8 @@ private: " };\n" " };\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'Fred::B::getB' can be const.\n" - "[test.cpp:7]: (style) Technically the member function 'Fred::B::A::getA' can be const.\n" + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" + "[test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str()); checkConst("class Fred {\n" @@ -4018,8 +4018,8 @@ private: " };\n" " int B::getB() { return b; }\n" "};"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:4]: (style) Technically the member function 'Fred::B::getB' can be const.\n" - "[test.cpp:9] -> [test.cpp:7]: (style) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str()); + ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" + "[test.cpp:9] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str()); checkConst("class Fred {\n" " class B {\n" @@ -4033,8 +4033,8 @@ private: " int B::A::getA() { return a; }\n" " int B::getB() { return b; }\n" "};"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:4]: (style) Technically the member function 'Fred::B::getB' can be const.\n" - "[test.cpp:10] -> [test.cpp:7]: (style) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str()); + ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" + "[test.cpp:10] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str()); checkConst("class Fred {\n" " class B {\n" @@ -4048,8 +4048,8 @@ private: "};\n" "int Fred::B::A::getA() { return a; }\n" "int Fred::B::getB() { return b; }\n"); - ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:4]: (style) Technically the member function 'Fred::B::getB' can be const.\n" - "[test.cpp:11] -> [test.cpp:7]: (style) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str()); + ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n" + "[test.cpp:11] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str()); } // operator< can often be const @@ -4058,7 +4058,7 @@ private: " int a;\n" " bool operator<(const Fred &f) { return (a < f.a); }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::operator<' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::operator<' can be const.\n", errout.str()); } // operator<< @@ -4085,7 +4085,7 @@ private: " std::cout << foo << 123;\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:6]: (style) Technically the member function 'Fred::x' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6]: (style, inconclusive) Technically the member function 'Fred::x' can be const.\n", errout.str()); } void constoperator3() { @@ -4100,7 +4100,7 @@ private: " int array[10];\n" " int const & operator [] (unsigned int index) { return array[index]; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::operator[]' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::operator[]' can be const.\n", errout.str()); } void constoperator4() { @@ -4109,7 +4109,7 @@ private: " typedef int* (Fred::*UnspecifiedBoolType);\n" " operator UnspecifiedBoolType() { };\n" "};\n"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'Fred::operatorint**' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::operatorint**' can be const.\n", errout.str()); checkConst("struct Fred {\n" " int array[10];\n" @@ -4132,14 +4132,14 @@ private: "public:\n" " operator const int& () {return c}\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::operatorconstint&' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::operatorconstint&' can be const.\n", errout.str()); checkConst("class A {\n" " int c;\n" "public:\n" " operator int () {return c}\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::operatorint' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::operatorint' can be const.\n", errout.str()); } @@ -4154,7 +4154,7 @@ private: " return same;\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'A::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str()); } void const6() { @@ -4170,7 +4170,7 @@ private: "public:\n" " void foo() { }\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'Fred::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::foo' can be const.\n", errout.str()); checkConst("struct fast_string\n" "{\n" @@ -4207,7 +4207,7 @@ private: "private:\n" " std::string m_strValue;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::strGetString' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::strGetString' can be const.\n", errout.str()); } void const9() { @@ -4267,7 +4267,7 @@ private: "private:\n" " mutable int x;\n" "};"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'A::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str()); } void const13() { @@ -4281,8 +4281,8 @@ private: " std::vector m_vec;\n" " std::pair m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetVec' can be const.\n" - "[test.cpp:5]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetVec' can be const.\n" + "[test.cpp:5]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4293,8 +4293,8 @@ private: " std::vector m_vec;\n" " std::pair m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetVec' can be const.\n" - "[test.cpp:5]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetVec' can be const.\n" + "[test.cpp:5]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); } void const14() { @@ -4306,7 +4306,7 @@ private: "private:\n" " std::pair,double> m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4315,7 +4315,7 @@ private: "private:\n" " std::pair,double> m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4335,7 +4335,7 @@ private: "private:\n" " pair m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4345,7 +4345,7 @@ private: "private:\n" " pair m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4365,7 +4365,7 @@ private: "private:\n" " std::pair< int,std::vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4374,7 +4374,7 @@ private: "private:\n" " std::pair< int,std::vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4394,7 +4394,7 @@ private: "private:\n" " pair< int,vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4404,7 +4404,7 @@ private: "private:\n" " pair< int,vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4425,7 +4425,7 @@ private: "private:\n" " pair< vector, int > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4435,7 +4435,7 @@ private: "private:\n" " pair< vector, int > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4454,7 +4454,7 @@ private: "private:\n" " std::pair< std::vector,std::vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4463,7 +4463,7 @@ private: "private:\n" " std::pair< std::vector,std::vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4483,7 +4483,7 @@ private: "private:\n" " pair< vector, vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4493,7 +4493,7 @@ private: "private:\n" " pair< vector, vector > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4514,7 +4514,7 @@ private: "private:\n" " std::pair< std::pair < int, char > , int > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4523,7 +4523,7 @@ private: "private:\n" " std::pair< std::pair < int, char > , int > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4542,7 +4542,7 @@ private: "private:\n" " pair< pair < int, char > , int > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4552,7 +4552,7 @@ private: "private:\n" " pair< pair < int, char > , int > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4573,7 +4573,7 @@ private: "private:\n" " pair< int , pair < int, char > > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4583,7 +4583,7 @@ private: "private:\n" " pair< int , pair < int, char > > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("using namespace std;" @@ -4603,7 +4603,7 @@ private: "private:\n" " std::pair< int , std::pair < int, char > > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4612,7 +4612,7 @@ private: "private:\n" " std::pair< int , std::pair < int, char > > m_pair;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetPair' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4632,7 +4632,7 @@ private: "private:\n" " vector m_Vec;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetVec' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetVec' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4642,7 +4642,7 @@ private: "private:\n" " vector m_Vec;\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::GetVec' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetVec' can be const.\n", errout.str()); checkConst("using namespace std;" "class A {\n" @@ -4669,7 +4669,7 @@ private: "private:\n" " const int * x;\n" "};"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'A::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -4677,7 +4677,7 @@ private: "private:\n" " const int * x;\n" "};"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'A::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str()); } void const15() { @@ -4685,7 +4685,7 @@ private: " unsigned long long int a;\n" " unsigned long long int getA() { return a; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::getA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::getA' can be const.\n", errout.str()); // constructors can't be const.. checkConst("class Fred {\n" @@ -4775,7 +4775,7 @@ private: "public:\n" " list get() { return x; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'Fred::get' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::get' can be const.\n", errout.str()); checkConst("class Fred {\n" " std::list x;\n" @@ -4789,7 +4789,7 @@ private: "public:\n" " std::list get() { return x; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'Fred::get' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::get' can be const.\n", errout.str()); } void const21() { @@ -4877,7 +4877,7 @@ private: "std::string m_strVal;\n" "};\n" ); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::strGetString' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::strGetString' can be const.\n", errout.str()); checkConst("class A{\n" "public:\n" @@ -4888,7 +4888,7 @@ private: "std::string m_strVal;\n" "};\n" ); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::strGetString1' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::strGetString1' can be const.\n", errout.str()); checkConst("class A{\n" "public:\n" @@ -4899,7 +4899,7 @@ private: "std::vector m_strVec;\n" "};\n" ); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::strGetSize' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::strGetSize' can be const.\n", errout.str()); checkConst("class A{\n" "public:\n" @@ -4910,7 +4910,7 @@ private: "std::vector m_strVec;\n" "};\n" ); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'A::strGetEmpty' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::strGetEmpty' can be const.\n", errout.str()); } void const26() { // ticket #1847 @@ -4930,7 +4930,7 @@ private: " }\n" " float delays_[4];\n" "};"); - ASSERT_EQUALS("[test.cpp:2]: (style) Technically the member function 'DelayBase::swapSpecificDelays' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Technically the member function 'DelayBase::swapSpecificDelays' can be const.\n", errout.str()); } void const27() { // ticket #1882 @@ -4949,7 +4949,7 @@ private: " return dRet;\n" "};\n" ); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:4]: (style) Technically the member function 'A::dGetValue' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'A::dGetValue' can be const.\n", errout.str()); } void const28() { // ticket #1883 @@ -4987,7 +4987,7 @@ private: " UnknownScope::x = x_;\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:4]: (style) Technically the member function 'AA::vSetXPos' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'AA::vSetXPos' can be const.\n", errout.str()); } @@ -5027,7 +5027,7 @@ private: " return a;\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:7]: (style) Technically the member function 'Derived::get' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7]: (style, inconclusive) Technically the member function 'Derived::get' can be const.\n", errout.str()); checkConst("class Base1 {\n" "public:\n" @@ -5046,8 +5046,8 @@ private: " return b;\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:11]: (style) Technically the member function 'Derived::getA' can be const.\n" - "[test.cpp:14]: (style) Technically the member function 'Derived::getB' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:11]: (style, inconclusive) Technically the member function 'Derived::getA' can be const.\n" + "[test.cpp:14]: (style, inconclusive) Technically the member function 'Derived::getB' can be const.\n", errout.str()); checkConst("class Base {\n" "public:\n" @@ -5060,7 +5060,7 @@ private: " return a;\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:8]: (style) Technically the member function 'Derived2::get' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:8]: (style, inconclusive) Technically the member function 'Derived2::get' can be const.\n", errout.str()); checkConst("class Base {\n" "public:\n" @@ -5075,7 +5075,7 @@ private: " return a;\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:10]: (style) Technically the member function 'Derived4::get' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:10]: (style, inconclusive) Technically the member function 'Derived4::get' can be const.\n", errout.str()); // check for false positives checkConst("class Base {\n" @@ -5145,7 +5145,7 @@ private: " int a;\n" " int get() { return a; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Technically the member function 'Fred::get' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::get' can be const.\n", errout.str()); } void const32() { @@ -5190,7 +5190,7 @@ private: " int var;\n" " };\n" "}\n"); - ASSERT_EQUALS("[test.cpp:12]: (style) Technically the member function 'N::Derived::getResourceName' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:12]: (style, inconclusive) Technically the member function 'N::Derived::getResourceName' can be const.\n", errout.str()); checkConst("namespace N\n" "{\n" @@ -5202,7 +5202,7 @@ private: " };\n" "}\n" "int N::Base::getResourceName() { return var; }\n"); - ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:6]: (style) Technically the member function 'N::Base::getResourceName' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout.str()); checkConst("namespace N\n" "{\n" @@ -5217,7 +5217,7 @@ private: "{\n" " int Base::getResourceName() { return var; }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:6]: (style) Technically the member function 'N::Base::getResourceName' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout.str()); checkConst("namespace N\n" "{\n" @@ -5230,7 +5230,7 @@ private: "}\n" "using namespace N;\n" "int Base::getResourceName() { return var; }\n"); - TODO_ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (style) Technically the member function 'N::Base::getResourceName' can be const.\n", + TODO_ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", "", errout.str()); } @@ -5258,7 +5258,7 @@ private: "private:\n" " std::string m_str;\n" "};\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Technically the member function 'A::operator+' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Technically the member function 'A::operator+' can be const.\n", errout.str()); checkConst("class Fred\n" "{\n" @@ -5272,7 +5272,7 @@ private: " return bool(x == 0x11224488);\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:9]: (style) Technically the member function 'Fred::isValid' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9]: (style, inconclusive) Technically the member function 'Fred::isValid' can be const.\n", errout.str()); } void const38() { // ticket #2135 @@ -5416,7 +5416,7 @@ private: "{\n" "}\n"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style) Technically the member function 'Fred::f' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'Fred::f' can be const.\n", errout.str()); checkConst("class Fred\n" "{\n" @@ -5430,7 +5430,7 @@ private: "{\n" "}\n"); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:7]: (style) Technically the member function 'Fred::f' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::f' can be const.\n", errout.str()); checkConst("namespace NS {\n" " class Fred\n" @@ -5446,7 +5446,7 @@ private: " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:8]: (style) Technically the member function 'NS::Fred::f' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:8]: (style, inconclusive) Technically the member function 'NS::Fred::f' can be const.\n", errout.str()); checkConst("namespace NS {\n" " class Fred\n" @@ -5462,7 +5462,7 @@ private: "{\n" "}\n"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:8]: (style) Technically the member function 'NS::Fred::f' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:8]: (style, inconclusive) Technically the member function 'NS::Fred::f' can be const.\n", errout.str()); checkConst("class Foo {\n" " class Fred\n" @@ -5478,7 +5478,7 @@ private: "{\n" "}\n"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:8]: (style) Technically the member function 'Foo::Fred::f' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:8]: (style, inconclusive) Technically the member function 'Foo::Fred::f' can be const.\n", errout.str()); } void const43() { // ticket 2377 @@ -5567,7 +5567,7 @@ private: " };\n" "}\n"); - ASSERT_EQUALS("[test.cpp:8]: (style) Technically the member function 'tools::WorkspaceControl::toGrid' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:8]: (style, inconclusive) Technically the member function 'tools::WorkspaceControl::toGrid' can be const.\n", errout.str()); } void const46() { // ticket 2663 @@ -5582,8 +5582,8 @@ private: " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Altren::fun1' can be const.\n" - "[test.cpp:7]: (style) Technically the member function 'Altren::fun2' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Altren::fun1' can be const.\n" + "[test.cpp:7]: (style, inconclusive) Technically the member function 'Altren::fun2' can be const.\n", errout.str()); } void const47() { // ticket 2670 @@ -5603,7 +5603,7 @@ private: " void bar() { foo(1); }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Technically the member function 'Altren::bar' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Technically the member function 'Altren::bar' can be const.\n", errout.str()); } void const48() { // ticket 2672 @@ -5737,7 +5737,7 @@ private: " switch (x) { }\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'MyObject::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'MyObject::foo' can be const.\n", errout.str()); checkConst("class A\n" "{\n" @@ -5780,7 +5780,7 @@ private: "\n" " return RET_NOK;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:4]: (style) Technically the member function 'A::f' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'A::f' can be const.\n", errout.str()); checkConst("class MyObject {\n" "public:\n" @@ -5788,7 +5788,7 @@ private: " for (int i = 0; i < 5; i++) { }\n" " }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'MyObject::foo' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'MyObject::foo' can be const.\n", errout.str()); } void const57() { // ticket #2669 @@ -5814,7 +5814,7 @@ private: "private:\n" " MyGUI::IntCoord mCoordValue;\n" "};\n"); - TODO_ASSERT_EQUALS("[test.cpp:15]: (style) Technically the member function 'MyGUI::SelectorControl::getSize' can be const.\n", + TODO_ASSERT_EQUALS("[test.cpp:15]: (style, inconclusive) Technically the member function 'MyGUI::SelectorControl::getSize' can be const.\n", "", errout.str()); } @@ -5875,25 +5875,25 @@ private: "class Fred {\n" " void nextA() { return ++a; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a;\n" "class Fred {\n" " void nextA() { return --a; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a;\n" "class Fred {\n" " void nextA() { return a++; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a;\n" "class Fred {\n" " void nextA() { return a--; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); } void constassign1() { @@ -5931,31 +5931,31 @@ private: "class Fred {\n" " void nextA() { return a=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a;\n" "class Fred {\n" " void nextA() { return a-=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a;\n" "class Fred {\n" " void nextA() { return a+=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a;\n" "class Fred {\n" " void nextA() { return a*=-1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a;\n" "class Fred {\n" " void nextA() { return a/=-2; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); } void constassign2() { @@ -5987,31 +5987,31 @@ private: "class Fred {\n" " void nextA() { return s.a=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("struct A { int a; } s;\n" "class Fred {\n" " void nextA() { return s.a-=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("struct A { int a; } s;\n" "class Fred {\n" " void nextA() { return s.a+=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("struct A { int a; } s;\n" "class Fred {\n" " void nextA() { return s.a*=-1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("struct A { int a; } s;\n" "class Fred {\n" " void nextA() { return s.a/=-2; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("struct A { int a; };\n" "class Fred {\n" @@ -6079,25 +6079,25 @@ private: "class Fred {\n" " void nextA() { return ++a[0]; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a[2];\n" "class Fred {\n" " void nextA() { return --a[0]; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a[2];\n" "class Fred {\n" " void nextA() { return a[0]++; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a[2];\n" "class Fred {\n" " void nextA() { return a[0]--; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); } void constassignarray() { @@ -6135,31 +6135,31 @@ private: "class Fred {\n" " void nextA() { return a[0]=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a[2];\n" "class Fred {\n" " void nextA() { return a[0]-=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a[2];\n" "class Fred {\n" " void nextA() { return a[0]+=1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a[2];\n" "class Fred {\n" " void nextA() { return a[0]*=-1; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); checkConst("int a[2];\n" "class Fred {\n" " void nextA() { return a[0]/=-2; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::nextA' can be const.\n", errout.str()); } // return pointer/reference => not const @@ -6201,7 +6201,7 @@ private: " void f() const { };\n" " void a() { f(); };\n" "};\n"); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'Fred::a' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::a' can be const.\n", errout.str()); // ticket #1593 checkConst("#include \n" @@ -6212,7 +6212,7 @@ private: " A(){}\n" " unsigned int GetVecSize() {return m_v.size();}\n" "};"); - ASSERT_EQUALS("[test.cpp:7]: (style) Technically the member function 'A::GetVecSize' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7]: (style, inconclusive) Technically the member function 'A::GetVecSize' can be const.\n", errout.str()); checkConst("#include \n" "class A\n" @@ -6222,7 +6222,7 @@ private: " A(){}\n" " bool GetVecEmpty() {return m_v.empty();}\n" "};"); - ASSERT_EQUALS("[test.cpp:7]: (style) Technically the member function 'A::GetVecEmpty' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7]: (style, inconclusive) Technically the member function 'A::GetVecEmpty' can be const.\n", errout.str()); } void constVirtualFunc() { @@ -6234,7 +6234,7 @@ private: " B() : b(0) { }\n" " int func() { return b; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:6]: (style) Technically the member function 'B::func' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str()); checkConst("class A { };\n" "class B : public A {\n" @@ -6244,7 +6244,7 @@ private: " int func();\n" "};\n" "int B::func() { return b; }\n"); - ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:6]: (style) Technically the member function 'B::func' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str()); // base class has no virtual function checkConst("class A {\n" @@ -6257,7 +6257,7 @@ private: " B() : b(0) { }\n" " int func() { return b; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:9]: (style) Technically the member function 'B::func' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str()); checkConst("class A {\n" "public:\n" @@ -6270,7 +6270,7 @@ private: " int func();\n" "};\n" "int B::func() { return b; }\n"); - ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:9]: (style) Technically the member function 'B::func' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:9]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str()); // base class has virtual function checkConst("class A {\n" @@ -6330,9 +6330,9 @@ private: " C() : c(0) { }\n" " int func() { return c; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Technically the member function 'A::func' can be const.\n" - "[test.cpp:11]: (style) Technically the member function 'B::func' can be const.\n" - "[test.cpp:17]: (style) Technically the member function 'C::func' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Technically the member function 'A::func' can be const.\n" + "[test.cpp:11]: (style, inconclusive) Technically the member function 'B::func' can be const.\n" + "[test.cpp:17]: (style, inconclusive) Technically the member function 'C::func' can be const.\n", errout.str()); checkConst("class A {\n" " int a;\n" @@ -6355,9 +6355,9 @@ private: " int func();\n" "};\n" "int C::func() { return c; }\n"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style) Technically the member function 'A::func' can be const.\n" - "[test.cpp:14] -> [test.cpp:12]: (style) Technically the member function 'B::func' can be const.\n" - "[test.cpp:21] -> [test.cpp:19]: (style) Technically the member function 'C::func' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'A::func' can be const.\n" + "[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'B::func' can be const.\n" + "[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'C::func' can be const.\n", errout.str()); // base class has virtual function checkConst("class A {\n" @@ -6422,9 +6422,9 @@ private: " Z(int x, int y, int z) : Y(x, y), z(z) { }\n" " int getZ() { return z; }\n" "};\n"); - ASSERT_EQUALS("[test.cpp:5]: (style) Technically the member function 'X::getX' can be const.\n" - "[test.cpp:11]: (style) Technically the member function 'Y::getY' can be const.\n" - "[test.cpp:17]: (style) Technically the member function 'Z::getZ' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Technically the member function 'X::getX' can be const.\n" + "[test.cpp:11]: (style, inconclusive) Technically the member function 'Y::getY' can be const.\n" + "[test.cpp:17]: (style, inconclusive) Technically the member function 'Z::getZ' can be const.\n", errout.str()); checkConst("class X {\n" " int x;\n" @@ -6447,9 +6447,9 @@ private: " int getZ();\n" "};\n" "int Z::getZ() { return z; }\n"); - ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style) Technically the member function 'X::getX' can be const.\n" - "[test.cpp:14] -> [test.cpp:12]: (style) Technically the member function 'Y::getY' can be const.\n" - "[test.cpp:21] -> [test.cpp:19]: (style) Technically the member function 'Z::getZ' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'X::getX' can be const.\n" + "[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'Y::getY' can be const.\n" + "[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'Z::getZ' can be const.\n", errout.str()); } void constIfCfg() { @@ -6466,7 +6466,7 @@ private: settings.addEnabled("style"); checkConst(code, &settings, true); - ASSERT_EQUALS("[test.cpp:3]: (style) Technically the member function 'foo::f' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'foo::f' can be const.\n", errout.str()); checkConst(code, &settings, false); // TODO: Set inconclusive to true (preprocess it) ASSERT_EQUALS("", errout.str()); @@ -6519,8 +6519,8 @@ private: "public:\n" " Fred() : c(0), b(0), a(0) { }\n" "};"); - ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style) Member variable 'Fred::b' is in the wrong order in the initializer list.\n" - "[test.cpp:4] -> [test.cpp:2]: (style) Member variable 'Fred::a' is in the wrong order in the initializer list.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style, inconclusive) Member variable 'Fred::b' is in the wrong order in the initializer list.\n" + "[test.cpp:4] -> [test.cpp:2]: (style, inconclusive) Member variable 'Fred::a' is in the wrong order in the initializer list.\n", errout.str()); } }; diff --git a/test/testdivision.cpp b/test/testdivision.cpp index 8a529f246..f623c42b3 100644 --- a/test/testdivision.cpp +++ b/test/testdivision.cpp @@ -79,7 +79,7 @@ private: " unsigned int uvar = 2;\n" " return ivar / uvar;\n" "}", true); - ASSERT_EQUALS("[test.cpp:5]: (warning) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (warning, inconclusive) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); } void division2() { @@ -89,7 +89,7 @@ private: " unsigned int uvar = 2;\n" " return uvar / ivar;\n" "}", true); - ASSERT_EQUALS("[test.cpp:5]: (warning) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (warning, inconclusive) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); } void division4() { @@ -182,7 +182,7 @@ private: " unsigned long uvar = 2;\n" " return ivar / uvar;\n" "}", true); - ASSERT_EQUALS("[test.cpp:5]: (warning) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (warning, inconclusive) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); check("void f()\n" "{\n" @@ -190,7 +190,7 @@ private: " unsigned long long uvar = 2;\n" " return ivar / uvar;\n" "}", true); - ASSERT_EQUALS("[test.cpp:5]: (warning) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (warning, inconclusive) Division with signed and unsigned operators. The result might be wrong.\n", errout.str()); } void division10() { diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 41846aef8..d9ad68988 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -118,7 +118,7 @@ private: ASSERT_EQUALS("", errout.str()); check(code, true); // inconclusive=true => error - ASSERT_EQUALS("[test.cpp:6]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 3\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6]: (error, inconclusive) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 3\n", errout.str()); } check("void foo()\n" @@ -190,7 +190,7 @@ private: ASSERT_EQUALS("", errout.str()); check(code, true); - ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 3\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (error, inconclusive) Possible null pointer dereference: tok - otherwise it is redundant to check if tok is null at line 3\n", errout.str()); } check("int foo(const Token *tok)\n" @@ -462,7 +462,7 @@ private: check(code); ASSERT_EQUALS("", errout.str()); check(code, true); - ASSERT_EQUALS("[test.cpp:2]: (error) Possible null pointer dereference: fred - otherwise it is redundant to check if fred is null at line 3\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (error, inconclusive) Possible null pointer dereference: fred - otherwise it is redundant to check if fred is null at line 3\n", errout.str()); } // false positives when there are macros @@ -1338,7 +1338,7 @@ private: " }\n" " *p = 0;\n" "}\n", true); - ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 2\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (error, inconclusive) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 2\n", errout.str()); check("void foo(char *p) {\n" " if (!p) {\n" @@ -1599,7 +1599,7 @@ private: ASSERT_EQUALS("", errout.str()); check(code, true); // inconclusive - ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: fred - otherwise it is redundant to check if fred is null at line 2\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (error, inconclusive) Possible null pointer dereference: fred - otherwise it is redundant to check if fred is null at line 2\n", errout.str()); } check("void f(char *s) {\n" // #3358 @@ -2029,7 +2029,7 @@ private: " foo(p);\n" " if (p) { }\n" "}", true); - ASSERT_EQUALS("[test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 4\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (error, inconclusive) Possible null pointer dereference: p - otherwise it is redundant to check if p is null at line 4\n", errout.str()); } // dereference struct pointer and then check if it's null @@ -2068,7 +2068,7 @@ private: " foo(abc);\n" " if (abc) { }\n" "}", true); - ASSERT_EQUALS("[test.cpp:2]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 4\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (error, inconclusive) Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 4\n", errout.str()); } } diff --git a/test/testother.cpp b/test/testother.cpp index 9c9deaffa..c7c308751 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -854,15 +854,15 @@ private: "}"); ASSERT_EQUALS("[test.cpp:2]: (warning) Casting between double* and float* which have an incompatible binary data representation\n", errout.str()); - checkInvalidPointerCast("void test(float* data) {\n" // #3639 + checkInvalidPointerCast("void test(float* data) {\n" " f.write((char*)data,sizeof(float));\n" "}", true, false); ASSERT_EQUALS("", errout.str()); checkInvalidPointerCast("void test(float* data) {\n" " f.write((char*)data,sizeof(float));\n" - "}", true, true); - ASSERT_EQUALS("[test.cpp:2]: (portability) Casting from float* to char* might be not portable due to different binary data representations on different platforms\n", errout.str()); + "}", true, true); // #3639 + ASSERT_EQUALS("[test.cpp:2]: (portability, inconclusive) Casting from float* to char* might be not portable due to different binary data representations on different platforms\n", errout.str()); checkInvalidPointerCast("long long* test(float* f) {\n" @@ -2062,7 +2062,7 @@ private: "\n" // #endif " return 1;\n" "}"); - ASSERT_EQUALS("[test.cpp:5]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (style, inconclusive) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str()); } @@ -3598,71 +3598,71 @@ private: check("void f(_Bool a, _Bool b) {\n" " if(a & b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("void f(_Bool a, _Bool b) {\n" " if(a | b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); check("void f(bool a, bool b) {\n" " if(a & b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("void f(bool a, bool b) {\n" " if(a & !b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("void f(bool a, bool b) {\n" " if(a | b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); check("void f(bool a, bool b) {\n" " if(a | !b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); check("bool a, b;\n" "void f() {\n" " if(a & b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("bool a, b;\n" "void f() {\n" " if(a & !b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("bool a, b;\n" "void f() {\n" " if(a | b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); check("bool a, b;\n" "void f() {\n" " if(a | !b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:3]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean || ?\n", errout.str()); check("void f(bool a, int b) {\n" " if(a & b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("void f(int a, bool b) {\n" " if(a & b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'b' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'b' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("void f(bool a, bool b) {\n" " if(a & b) {}\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Boolean variable 'a' is used in bitwise operation. Did you mean && ?\n", errout.str()); check("void f(int a, int b) {\n" " if(a & b) {}\n" @@ -4293,17 +4293,17 @@ private: check( "int *x = malloc(sizeof(x));\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:1]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(100 * sizeof(x));\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:1]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(sizeof(x) * 100);\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:1]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(sizeof *x);\n" @@ -4313,12 +4313,12 @@ private: check( "int *x = malloc(sizeof x);\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:1]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(100 * sizeof x);\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:1]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = calloc(1, sizeof(*x));\n" @@ -4333,12 +4333,12 @@ private: check( "int *x = calloc(1, sizeof(x));\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:1]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = calloc(1, sizeof x);\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:1]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = calloc(1, sizeof(int));\n" @@ -4382,25 +4382,25 @@ private: "int *x = malloc(sizeof(int));\n" "memset(x, 0, sizeof x);\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(sizeof(int));\n" "memset(x, 0, sizeof(x));\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(sizeof(int) * 10);\n" "memset(x, 0, sizeof(x) * 10);\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(sizeof(int) * 10);\n" "memset(x, 0, sizeof x * 10);\n" "free(x);"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Using size of pointer x instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Using size of pointer x instead of size of its data.\n", errout.str()); check( "int *x = malloc(sizeof(int) * 10);\n" @@ -4426,13 +4426,13 @@ private: " const char *buf1_ex = \"foobarbaz\";\n" " return strncmp(buf1, buf1_ex, sizeof(buf1_ex)) == 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (warning) Using size of pointer buf1_ex instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (warning, inconclusive) Using size of pointer buf1_ex instead of size of its data.\n", errout.str()); check( "int fun(const char *buf1) {\n" " return strncmp(buf1, foo(buf2), sizeof(buf1)) == 0;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Using size of pointer buf1 instead of size of its data.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Using size of pointer buf1 instead of size of its data.\n", errout.str()); } void check_signOfUnsignedVariable(const char code[], bool inconclusive=false) { @@ -4673,7 +4673,7 @@ private: check_signOfUnsignedVariable(code, false); ASSERT_EQUALS("", errout.str()); check_signOfUnsignedVariable(code, true); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero. This might be a false warning.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Checking if unsigned variable 'x' is less than zero. This might be a false warning.\n", errout.str()); } } @@ -4690,7 +4690,7 @@ private: " for(int i = 0; i < 10; ++i); {\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); // Block with some tokens to make sure the tokenizer output // stays the same for "for(); {}" @@ -4700,7 +4700,7 @@ private: " int j = 123;\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); check( "void foo() {\n" @@ -4708,7 +4708,7 @@ private: " do_something();\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); } void checkForSuspiciousSemicolon2() { @@ -4718,7 +4718,7 @@ private: " do_something();\n" " }\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (warning) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning, inconclusive) Suspicious use of ; at the end of 'if/for/while' statement.\n", errout.str()); // Seen this in the wild check( diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 302cedc64..a4c81d72c 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -4385,10 +4385,10 @@ private: ASSERT_EQUALS(expected, tok(code, false)); checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:1]: (style) The typedef 'A' hides a typedef with the same name.\n" - "[test.cpp:20] -> [test.cpp:1]: (style) The function parameter 'A' hides a typedef with the same name.\n" - "[test.cpp:21] -> [test.cpp:1]: (style) The variable 'A' hides a typedef with the same name.\n" - "[test.cpp:24] -> [test.cpp:1]: (style) The typedef 'A' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:1]: (style, inconclusive) The typedef 'A' hides a typedef with the same name.\n" + "[test.cpp:20] -> [test.cpp:1]: (style, inconclusive) The function parameter 'A' hides a typedef with the same name.\n" + "[test.cpp:21] -> [test.cpp:1]: (style, inconclusive) The variable 'A' hides a typedef with the same name.\n" + "[test.cpp:24] -> [test.cpp:1]: (style, inconclusive) The typedef 'A' hides a typedef with the same name.\n", errout.str()); } void simplifyTypedef36() { @@ -4415,8 +4415,8 @@ private: "typedef int B;"; checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style) The typedef 'A' hides a typedef with the same name.\n" - "[test.cpp:5] -> [test.cpp:3]: (style) The typedef 'B' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (style, inconclusive) The typedef 'A' hides a typedef with the same name.\n" + "[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) The typedef 'B' hides a typedef with the same name.\n", errout.str()); } { @@ -4461,8 +4461,8 @@ private: ASSERT_EQUALS(expected, tok(code, false)); checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (style) The template parameter 'A' hides a typedef with the same name.\n" - "[test.cpp:3] -> [test.cpp:2]: (style) The template parameter 'B' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (style, inconclusive) The template parameter 'A' hides a typedef with the same name.\n" + "[test.cpp:3] -> [test.cpp:2]: (style, inconclusive) The template parameter 'B' hides a typedef with the same name.\n", errout.str()); checkSimplifyTypedef("typedef tuple t2;\n" "void ordering_test()\n" @@ -4470,7 +4470,7 @@ private: " tuple t2(5, 3.3f);\n" " BOOST_CHECK(t3 > t2);\n" "}"); - ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (style) The template instantiation 't2' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (style, inconclusive) The template instantiation 't2' hides a typedef with the same name.\n", errout.str()); checkSimplifyTypedef("class MyOverflowingUnsigned\n" "{\n" @@ -4551,7 +4551,7 @@ private: ASSERT_EQUALS(expected, tok(code)); checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The struct 'A' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style, inconclusive) The struct 'A' hides a typedef with the same name.\n", errout.str()); } { @@ -4569,7 +4569,7 @@ private: ASSERT_EQUALS(expected, tok(code)); checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The union 'A' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style, inconclusive) The union 'A' hides a typedef with the same name.\n", errout.str()); } { @@ -4587,7 +4587,7 @@ private: ASSERT_EQUALS(expected, tok(code)); checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The class 'A' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style, inconclusive) The class 'A' hides a typedef with the same name.\n", errout.str()); } } @@ -4816,14 +4816,14 @@ private: "typedef int (*PPDMarkOption)(ppd_file_t *ppd, const char *keyword, const char *option);\n"; checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The typedef 'PPDMarkOption' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style, inconclusive) The typedef 'PPDMarkOption' hides a typedef with the same name.\n", errout.str()); } { const char code[] = "typedef int * A;\n" "typedef int * A;\n"; checkSimplifyTypedef(code); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) The typedef 'A' hides a typedef with the same name.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style, inconclusive) The typedef 'A' hides a typedef with the same name.\n", errout.str()); } }