Skip to content

refs #12232 - added script to detect missing --errorlist entries and test coverage #7439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3814,4 +3814,5 @@ void CheckClass::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
c.virtualFunctionCallInConstructorError(nullptr, std::list<const Token *>(), "f");
c.thisUseAfterFree(nullptr, nullptr, nullptr);
c.unsafeClassRefMemberError(nullptr, "UnsafeClass::var");
// TODO: ctuOneDefinitionRuleViolation
}
1 change: 1 addition & 0 deletions lib/checknullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,5 +719,6 @@ void CheckNullPointer::getErrorMessages(ErrorLogger *errorLogger, const Settings
CheckNullPointer c(nullptr, settings, errorLogger);
c.nullPointerError(nullptr, "pointer", nullptr, false);
c.pointerArithmeticError(nullptr, nullptr, false);
// TODO: nullPointerArithmeticOutOfMemory
c.redundantConditionWarning(nullptr, nullptr, nullptr, false);
}
4 changes: 4 additions & 0 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4461,6 +4461,8 @@ void CheckOther::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
c.cstyleCastError(nullptr);
c.suspiciousFloatingPointCastError(nullptr);
c.passedByValueError(nullptr, false);
// TODO: iterateByValue
// TODO: passedByValueCallback
c.constVariableError(nullptr, nullptr);
c.constStatementError(nullptr, "type", false);
c.signedCharArrayIndexError(nullptr);
Expand Down Expand Up @@ -4504,8 +4506,10 @@ void CheckOther::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
c.knownArgumentError(nullptr, nullptr, nullptr, "x", false);
c.knownPointerToBoolError(nullptr, nullptr);
c.comparePointersError(nullptr, nullptr, nullptr);
// TODO: subtractPointers
c.redundantAssignmentError(nullptr, nullptr, "var", false);
c.redundantInitializationError(nullptr, nullptr, "var", false);
c.redundantContinueError(nullptr);

const std::vector<const Token *> nullvec;
c.funcArgOrderDifferent("function", nullptr, nullptr, nullvec, nullvec);
Expand Down
2 changes: 2 additions & 0 deletions lib/checktype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,9 @@ void CheckType::getErrorMessages(ErrorLogger *errorLogger, const Settings *setti
c.tooBigBitwiseShiftError(nullptr, 32, ValueFlow::Value(64));
c.tooBigSignedBitwiseShiftError(nullptr, 31, ValueFlow::Value(31));
c.integerOverflowError(nullptr, ValueFlow::Value(1LL<<32));
// TODO: integerOverflowCond
c.signConversionError(nullptr, nullptr, false);
// TODO: signConversionCond
c.longCastAssignError(nullptr);
c.longCastReturnError(nullptr);
ValueFlow::Value f;
Expand Down
2 changes: 1 addition & 1 deletion lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ void CheckUninitVar::getErrorMessages(ErrorLogger* errorLogger, const Settings*

ValueFlow::Value v{};

c.uninitvarError(nullptr, v);
c.uninitvarError(nullptr, v); // TODO: does not produce any output
c.uninitdataError(nullptr, "varname");
c.uninitStructMemberError(nullptr, "a.b");
}
8 changes: 3 additions & 5 deletions lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,9 @@ static bool isOperatorFunction(const std::string & funcName)
return std::find(additionalOperators.cbegin(), additionalOperators.cend(), funcName.substr(operatorPrefix.length())) != additionalOperators.cend();
}

static void staticFunctionError(ErrorLogger& errorLogger,
const std::string &filename,
unsigned int fileIndex,
unsigned int lineNumber,
const std::string &funcname)
void CheckUnusedFunctions::staticFunctionError(ErrorLogger& errorLogger,
const std::string &filename, unsigned int fileIndex, unsigned int lineNumber,
const std::string &funcname)
{
std::list<ErrorMessage::FileLocation> locationList;
if (!filename.empty()) {
Expand Down
5 changes: 5 additions & 0 deletions lib/checkunusedfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class CPPCHECKLIB CheckUnusedFunctions {

static void getErrorMessages(ErrorLogger &errorLogger) {
unusedFunctionError(errorLogger, "", 0, 0, "funcName");
staticFunctionError(errorLogger, "", 0, 0, "funcName");
}

// Return true if an error is reported.
Expand All @@ -70,6 +71,10 @@ class CPPCHECKLIB CheckUnusedFunctions {
const std::string &filename, unsigned int fileIndex, unsigned int lineNumber,
const std::string &funcname);

static void staticFunctionError(ErrorLogger& errorLogger,
const std::string &filename, unsigned int fileIndex, unsigned int lineNumber,
const std::string &funcname);

struct CPPCHECKLIB FunctionUsage {
std::string filename;
unsigned int lineNumber{};
Expand Down
4 changes: 3 additions & 1 deletion test/fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ void TestFixture::assertEquals(const char * const filename, const unsigned int l
}
}

// TODO: handle multiple lines
std::string TestFixture::deleteLineNumber(const std::string &message)
{
std::string result(message);
// skip location
std::string::size_type pos = result.find("]:") + 2;
// delete line number in "...:NUMBER:..."
std::string::size_type pos = 0;
while ((pos = result.find(':', pos)) != std::string::npos) {
// get number
if (pos + 1 == result.find_first_of("0123456789", pos + 1)) {
Expand Down
1 change: 1 addition & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8906,6 +8906,7 @@ class TestClass : public TestFixture {
}


// TODO: add columns and IDs
#define checkThisUseAfterFree(...) checkThisUseAfterFree_(__FILE__, __LINE__, __VA_ARGS__)
template<size_t size>
void checkThisUseAfterFree_(const char* file, int line, const char (&code)[size]) {
Expand Down
Loading