Skip to content

Commit

Permalink
Fix Misra C++ warnings
Browse files Browse the repository at this point in the history
lib/vfvalue.cpp:118:25: style: A switch statement shall be a well-formed switch statement. [premium-misra-cpp-2008-6-4-3]
            std::string result = "symbolic=" + tokvalue->expressionString();
                        ^
lib/valueflow.cpp:141:75: style: In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##. [premium-misra-cpp-2008-16-0-6]
define bailout2(type, tokenlist, errorLogger, tok, what) bailoutInternal(type, tokenlist, errorLogger, tok, what, __FILE__, __LINE__, __func__)
                                                                          ^
lib/valueflow.cpp:143:81: style: In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##. [premium-misra-cpp-2008-16-0-6]
define bailout(tokenlist, errorLogger, tok, what) bailout2("valueFlowBailout", tokenlist, errorLogger, tok, what)
                                                                                ^
lib/valueflow.cpp:145:114: style: In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##. [premium-misra-cpp-2008-16-0-6]
define bailoutIncompleteVar(tokenlist, errorLogger, tok, what) bailoutInternal("valueFlowBailoutIncompleteVar", tokenlist, errorLogger, tok, what, "", 0, __func__)
                                                                                                                 ^
lib/valueflow.cpp:2391:14: style: All constructors of a class should explicitly call a constructor for all of its immediate base classes and all virtual base classes. [premium-misra-cpp-2008-12-1-2]
    explicit ValueFlowAnalyzer(const TokenList& t, const Settings* s = nullptr) : tokenlist(t), settings(s), pms(settings) {}
             ^
lib/valueflow.cpp:5558:14: style: All constructors of a class should explicitly call a constructor for all of its immediate base classes and all virtual base classes. [premium-misra-cpp-2008-12-1-2]
    explicit SymbolicInferModel(const Token* tok) : expr(tok) {
             ^
lib/valueflow.cpp:9416:270: style: In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##. [premium-misra-cpp-2008-16-0-6]
define VALUEFLOW_ADAPTOR(cpp, ...)                                                                                    \
                                                                                                                                                                                                                                                                             ^
  • Loading branch information
danmar committed Feb 3, 2024
1 parent a5a1de5 commit 901cf49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 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 @@ -2388,7 +2388,7 @@ struct ValueFlowAnalyzer : Analyzer {
const Settings* settings;
ProgramMemoryState pms;

explicit ValueFlowAnalyzer(const TokenList& t, const Settings* s = nullptr) : tokenlist(t), settings(s), pms(settings) {}
explicit ValueFlowAnalyzer(const TokenList& t, const Settings* s = nullptr) : Analyzer(), tokenlist(t), settings(s), pms(settings) {}

virtual const ValueFlow::Value* getValue(const Token* tok) const = 0;
virtual ValueFlow::Value* getValue(const Token* tok) = 0;
Expand Down Expand Up @@ -5555,7 +5555,7 @@ static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, con

struct SymbolicInferModel : InferModel {
const Token* expr;
explicit SymbolicInferModel(const Token* tok) : expr(tok) {
explicit SymbolicInferModel(const Token* tok) : InferModel(), expr(tok) {
assert(expr->exprId() != 0);
}
bool match(const ValueFlow::Value& value) const override
Expand Down Expand Up @@ -9415,7 +9415,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,12 +115,14 @@ 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 901cf49

Please sign in to comment.