Skip to content

Commit

Permalink
CI: Update Cppcheck Premium to 24.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Feb 5, 2024
1 parent faaabb1 commit 8cacbdc
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/cppcheck-premium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ jobs:
runs-on: ubuntu-22.04 # run on the latest image only

env:
PREMIUM_VERSION: 23.12.0
PREMIUM_VERSION: 24.2.0

steps:
- uses: actions/checkout@v3

- name: Download cppcheckpremium
run: |
wget https://files.cppchecksolutions.com/${{ env.PREMIUM_VERSION }}/ubuntu-22.04/cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
#wget https://files.cppchecksolutions.com/cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
tar xzf cppcheckpremium-${{ env.PREMIUM_VERSION }}-amd64.tar.gz
- name: Generate a license file
Expand Down
44 changes: 44 additions & 0 deletions cppcheckpremium-suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ premium-misra-cpp-2008-0-1-12
# we sometimes don't care about return value from functions
premium-misra-cpp-2008-0-1-7

# c++11
premium-misra-cpp-2008-1-0-1

# TODO: can we prevent commented out code?
premium-misra-cpp-2008-2-7-2
premium-misra-cpp-2008-2-7-3
Expand All @@ -52,6 +55,9 @@ premium-misra-cpp-2008-2-10-1
# objects of a class often has the lowercase name of the class.
premium-misra-cpp-2008-2-10-4

# no suffix on numeric literals
premium-misra-cpp-2008-2-13-3

# flag |= ..
premium-misra-cpp-2008-4-5-1

Expand All @@ -76,6 +82,9 @@ premium-misra-cpp-2008-5-0-11
# conversion of char-to-int is intentional sometimes
premium-misra-cpp-2008-5-0-12

# pointer-to-bool conversion in condition
premium-misra-cpp-2008-5-0-13

# pointer-to-bool conversion is common
premium-misra-cpp-2008-5-0-14

Expand Down Expand Up @@ -106,9 +115,30 @@ premium-misra-cpp-2008-5-2-12
# we write !pointer by intention
premium-misra-cpp-2008-5-3-1

# side effects in conditional code is intentional
premium-misra-cpp-2008-5-14-1

# intentional use of comma operator in variable declarations
premium-misra-cpp-2008-5-18-1

# nested assignments are intentional
premium-misra-cpp-2008-6-2-1

# for (;;)
premium-misra-cpp-2008-6-2-3

# we don't always use braces for single statement loop/switch bodies
premium-misra-cpp-2008-6-3-1

# we don't always use braces for single statement if/else
premium-misra-cpp-2008-6-4-1

# we do not require a final else
premium-misra-cpp-2008-6-4-2

# return in case
premium-misra-cpp-2008-6-4-5

# it's not a bug to not put default at the end of a switch body
premium-misra-cpp-2008-6-4-6

Expand Down Expand Up @@ -143,15 +173,24 @@ premium-misra-cpp-2008-8-5-3
# TODO Fix these
premium-misra-cpp-2008-9-3-1

# returning non-const pointer/reference from method that is non-const
premium-misra-cpp-2008-9-3-2

# we use unions by intention sometimes
premium-misra-cpp-2008-9-5-1

# overridden methods is safe
premium-misra-cpp-2008-10-3-1

# use override/final
premium-misra-cpp-2008-10-3-2

# some classes have public members by intention
premium-misra-cpp-2008-11-0-1

# intentional: clang-tidy warns for redundant base class initializations
premium-misra-cpp-2008-12-1-2

# rule should not apply to deleted copy assignment operator
premium-misra-cpp-2008-12-8-2

Expand All @@ -161,8 +200,13 @@ premium-misra-cpp-2008-14-6-2
# function specializations: TODO check if we should refactor
premium-misra-cpp-2008-14-8-2

# we throw a pointer by intention
premium-misra-cpp-2008-15-0-2
premium-misra-cpp-2008-15-3-5

# we use preprocessor when it makes sense
premium-misra-cpp-2008-16-0-1
premium-misra-cpp-2008-16-0-7
premium-misra-cpp-2008-16-2-1
premium-misra-cpp-2008-16-2-2
premium-misra-cpp-2008-16-3-2
Expand Down
2 changes: 2 additions & 0 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ static void createDumpFile(const Settings& settings,
language = " language=\"cpp\"";
break;
case Standards::Language::None:
{
// TODO: error out on unknown language?
const Standards::Language lang = Path::identify(filename);
if (lang == Standards::Language::CPP)
Expand All @@ -203,6 +204,7 @@ static void createDumpFile(const Settings& settings,
language = " language=\"c\"";
break;
}
}

fdump << "<?xml version=\"1.0\"?>\n";
fdump << "<dumps" << language << ">\n";
Expand Down
8 changes: 4 additions & 4 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ static void bailoutInternal(const std::string& type, const TokenList &tokenlist,
errorLogger->reportErr(errmsg);
}

#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal(type, tokenlist, errorLogger, tok, what, __FILE__, __LINE__, __func__)
#define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal((type), (tokenlist), (errorLogger), (tok), (what), __FILE__, __LINE__, __func__)

#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", tokenlist, errorLogger, tok, what)
#define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", (tokenlist), (errorLogger), (tok), (what))

#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", tokenlist, errorLogger, tok, what, "", 0, __func__)
#define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", (tokenlist), (errorLogger), (tok), (what), "", 0, __func__)

static std::string debugString(const ValueFlow::Value& v)
{
Expand Down Expand Up @@ -9500,7 +9500,7 @@ static ValueFlowPassAdaptor<F> makeValueFlowPassAdaptor(const char* name, bool c

#define VALUEFLOW_ADAPTOR(cpp, ...) \
makeValueFlowPassAdaptor(#__VA_ARGS__, \
cpp, \
(cpp), \
[](TokenList& tokenlist, \
SymbolDatabase& symboldatabase, \
ErrorLogger* errorLogger, \
Expand Down
2 changes: 2 additions & 0 deletions lib/vfvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ namespace ValueFlow {
case ValueType::LIFETIME:
return "lifetime=" + tokvalue->str();
case ValueType::SYMBOLIC:
{
std::string result = "symbolic=" + tokvalue->expressionString();
if (intvalue > 0)
result += "+" + std::to_string(intvalue);
else if (intvalue < 0)
result += "-" + std::to_string(-intvalue);
return result;
}
}
throw InternalError(nullptr, "Invalid ValueFlow Value type");
}

Expand Down

0 comments on commit 8cacbdc

Please sign in to comment.