fixed some "Variable can be made constexpr" Rider warnings (#5615)
This commit is contained in:
parent
9280b5d7a5
commit
63e00ea918
|
@ -51,9 +51,9 @@
|
||||||
|
|
||||||
// TODO: __USE_DYNAMIC_STACK_SIZE is dependent on the features.h include and not a built-in compiler define, so it might be problematic to depend on it
|
// TODO: __USE_DYNAMIC_STACK_SIZE is dependent on the features.h include and not a built-in compiler define, so it might be problematic to depend on it
|
||||||
#ifdef __USE_DYNAMIC_STACK_SIZE
|
#ifdef __USE_DYNAMIC_STACK_SIZE
|
||||||
static const size_t MYSTACKSIZE = 16*1024+32768; // wild guess about a reasonable buffer
|
static constexpr size_t MYSTACKSIZE = 16*1024+32768; // wild guess about a reasonable buffer
|
||||||
#else
|
#else
|
||||||
static const size_t MYSTACKSIZE = 16*1024+SIGSTKSZ; // wild guess about a reasonable buffer
|
static constexpr size_t MYSTACKSIZE = 16*1024+SIGSTKSZ; // wild guess about a reasonable buffer
|
||||||
#endif
|
#endif
|
||||||
static char mytstack[MYSTACKSIZE]= {0}; // alternative stack for signal handler
|
static char mytstack[MYSTACKSIZE]= {0}; // alternative stack for signal handler
|
||||||
static bool bStackBelowHeap=false; // lame attempt to locate heap vs. stack address space. See CppCheckExecutor::check_wrapper()
|
static bool bStackBelowHeap=false; // lame attempt to locate heap vs. stack address space. See CppCheckExecutor::check_wrapper()
|
||||||
|
|
|
@ -35,7 +35,7 @@ void print_stacktrace(FILE* output, bool demangling, int maxdepth, bool lowMem)
|
||||||
const int fd = fileno(output);
|
const int fd = fileno(output);
|
||||||
void *callstackArray[32]= {nullptr}; // the less resources the better...
|
void *callstackArray[32]= {nullptr}; // the less resources the better...
|
||||||
const int currentdepth = backtrace(callstackArray, (int)getArrayLength(callstackArray));
|
const int currentdepth = backtrace(callstackArray, (int)getArrayLength(callstackArray));
|
||||||
const int offset=2; // some entries on top are within our own exception handling code or libc
|
constexpr int offset=2; // some entries on top are within our own exception handling code or libc
|
||||||
if (maxdepth<0)
|
if (maxdepth<0)
|
||||||
maxdepth=currentdepth-offset;
|
maxdepth=currentdepth-offset;
|
||||||
else
|
else
|
||||||
|
|
|
@ -271,13 +271,14 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
||||||
mUI->mActionEnforceCpp->setActionGroup(mSelectLanguageActions);
|
mUI->mActionEnforceCpp->setActionGroup(mSelectLanguageActions);
|
||||||
mUI->mActionAutoDetectLanguage->setActionGroup(mSelectLanguageActions);
|
mUI->mActionAutoDetectLanguage->setActionGroup(mSelectLanguageActions);
|
||||||
|
|
||||||
|
// TODO: we no longer default to a Windows platform in CLI - so we should probably also get rid of this in the GUI
|
||||||
// For Windows platforms default to Win32 checked platform.
|
// For Windows platforms default to Win32 checked platform.
|
||||||
// For other platforms default to unspecified/default which means the
|
// For other platforms default to unspecified/default which means the
|
||||||
// platform Cppcheck GUI was compiled on.
|
// platform Cppcheck GUI was compiled on.
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
const Platform::Type defaultPlatform = Platform::Type::Win32W;
|
constexpr Platform::Type defaultPlatform = Platform::Type::Win32W;
|
||||||
#else
|
#else
|
||||||
const Platform::Type defaultPlatform = Platform::Type::Unspecified;
|
constexpr Platform::Type defaultPlatform = Platform::Type::Unspecified;
|
||||||
#endif
|
#endif
|
||||||
PlatformData &platform = mPlatforms.get((Platform::Type)mSettings->value(SETTINGS_CHECKED_PLATFORM, defaultPlatform).toInt());
|
PlatformData &platform = mPlatforms.get((Platform::Type)mSettings->value(SETTINGS_CHECKED_PLATFORM, defaultPlatform).toInt());
|
||||||
platform.mActMainWindow->setChecked(true);
|
platform.mActMainWindow->setChecked(true);
|
||||||
|
|
|
@ -57,12 +57,12 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
|
|
||||||
static const char ADDON_MISRA[] = "misra";
|
static constexpr char ADDON_MISRA[] = "misra";
|
||||||
static const char CODING_STANDARD_MISRA_C_2023[] = "misra-c-2023";
|
static constexpr char CODING_STANDARD_MISRA_C_2023[] = "misra-c-2023";
|
||||||
static const char CODING_STANDARD_MISRA_CPP_2008[] = "misra-cpp-2008";
|
static constexpr char CODING_STANDARD_MISRA_CPP_2008[] = "misra-cpp-2008";
|
||||||
static const char CODING_STANDARD_CERT_C[] = "cert-c-2016";
|
static constexpr char CODING_STANDARD_CERT_C[] = "cert-c-2016";
|
||||||
static const char CODING_STANDARD_CERT_CPP[] = "cert-cpp-2016";
|
static constexpr char CODING_STANDARD_CERT_CPP[] = "cert-cpp-2016";
|
||||||
static const char CODING_STANDARD_AUTOSAR[] = "autosar";
|
static constexpr char CODING_STANDARD_AUTOSAR[] = "autosar";
|
||||||
|
|
||||||
/** Return paths from QListWidget */
|
/** Return paths from QListWidget */
|
||||||
static QStringList getPaths(const QListWidget *list)
|
static QStringList getPaths(const QListWidget *list)
|
||||||
|
@ -77,7 +77,7 @@ static QStringList getPaths(const QListWidget *list)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Platforms shown in the platform combobox */
|
/** Platforms shown in the platform combobox */
|
||||||
static const Platform::Type builtinPlatforms[] = {
|
static constexpr Platform::Type builtinPlatforms[] = {
|
||||||
Platform::Type::Native,
|
Platform::Type::Native,
|
||||||
Platform::Type::Win32A,
|
Platform::Type::Win32A,
|
||||||
Platform::Type::Win32W,
|
Platform::Type::Win32W,
|
||||||
|
@ -86,7 +86,7 @@ static const Platform::Type builtinPlatforms[] = {
|
||||||
Platform::Type::Unix64
|
Platform::Type::Unix64
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]);
|
static constexpr int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]);
|
||||||
|
|
||||||
QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName)
|
QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,25 +60,25 @@
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
static const char COLUMN[] = "column";
|
static constexpr char COLUMN[] = "column";
|
||||||
static const char CWE[] = "cwe";
|
static constexpr char CWE[] = "cwe";
|
||||||
static const char ERRORID[] = "id";
|
static constexpr char ERRORID[] = "id";
|
||||||
static const char FILENAME[] = "file";
|
static constexpr char FILENAME[] = "file";
|
||||||
static const char FILE0[] = "file0";
|
static constexpr char FILE0[] = "file0";
|
||||||
static const char HASH[] = "hash";
|
static constexpr char HASH[] = "hash";
|
||||||
static const char HIDE[] = "hide";
|
static constexpr char HIDE[] = "hide";
|
||||||
static const char INCONCLUSIVE[] = "inconclusive";
|
static constexpr char INCONCLUSIVE[] = "inconclusive";
|
||||||
static const char LINE[] = "line";
|
static constexpr char LINE[] = "line";
|
||||||
static const char MESSAGE[] = "message";
|
static constexpr char MESSAGE[] = "message";
|
||||||
static const char SEVERITY[] = "severity";
|
static constexpr char SEVERITY[] = "severity";
|
||||||
static const char SINCEDATE[] = "sinceDate";
|
static constexpr char SINCEDATE[] = "sinceDate";
|
||||||
static const char SYMBOLNAMES[] = "symbolNames";
|
static constexpr char SYMBOLNAMES[] = "symbolNames";
|
||||||
static const char SUMMARY[] = "summary";
|
static constexpr char SUMMARY[] = "summary";
|
||||||
static const char TAGS[] = "tags";
|
static constexpr char TAGS[] = "tags";
|
||||||
|
|
||||||
// These must match column headers given in ResultsTree::translate()
|
// These must match column headers given in ResultsTree::translate()
|
||||||
static const int COLUMN_SINCE_DATE = 6;
|
static constexpr int COLUMN_SINCE_DATE = 6;
|
||||||
static const int COLUMN_TAGS = 7;
|
static constexpr int COLUMN_TAGS = 7;
|
||||||
|
|
||||||
ResultsTree::ResultsTree(QWidget * parent) :
|
ResultsTree::ResultsTree(QWidget * parent) :
|
||||||
QTreeView(parent)
|
QTreeView(parent)
|
||||||
|
|
|
@ -240,7 +240,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void manageStyleControls();
|
void manageStyleControls();
|
||||||
|
|
||||||
static const int mLangCodeRole = Qt::UserRole;
|
static constexpr int mLangCodeRole = Qt::UserRole;
|
||||||
|
|
||||||
bool mPremium;
|
bool mPremium;
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
#include <QStringRef>
|
#include <QStringRef>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char ResultElementName[] = "results";
|
static constexpr char ResultElementName[] = "results";
|
||||||
static const char VersionAttribute[] = "version";
|
static constexpr char VersionAttribute[] = "version";
|
||||||
|
|
||||||
XmlReport::XmlReport(const QString &filename) :
|
XmlReport::XmlReport(const QString &filename) :
|
||||||
Report(filename)
|
Report(filename)
|
||||||
|
|
|
@ -52,9 +52,9 @@ R calculate(const std::string& s, const T& x, const T& y, bool* error = nullptr)
|
||||||
auto wrap = [](T z) {
|
auto wrap = [](T z) {
|
||||||
return R{z};
|
return R{z};
|
||||||
};
|
};
|
||||||
const MathLib::bigint maxBitsShift = sizeof(MathLib::bigint) * 8;
|
constexpr MathLib::bigint maxBitsShift = sizeof(MathLib::bigint) * 8;
|
||||||
// For portability we cannot shift signed integers by 63 bits
|
// For portability we cannot shift signed integers by 63 bits
|
||||||
const MathLib::bigint maxBitsSignedShift = maxBitsShift - 1;
|
constexpr MathLib::bigint maxBitsSignedShift = maxBitsShift - 1;
|
||||||
switch (MathLib::encodeMultiChar(s)) {
|
switch (MathLib::encodeMultiChar(s)) {
|
||||||
case '+':
|
case '+':
|
||||||
return wrap(x + y);
|
return wrap(x + y);
|
||||||
|
|
|
@ -1117,8 +1117,7 @@ void CheckClass::missingMemberCopyError(const Token *tok, Function::Type functio
|
||||||
const std::string message =
|
const std::string message =
|
||||||
"$symbol:" + classname + "::" + varname + "\n" +
|
"$symbol:" + classname + "::" + varname + "\n" +
|
||||||
"Member variable '$symbol' is not assigned in the " + ctor + " constructor. Should it be " + action;
|
"Member variable '$symbol' is not assigned in the " + ctor + " constructor. Should it be " + action;
|
||||||
const char id[] = "missingMemberCopy";
|
reportError(tok, Severity::warning, "missingMemberCopy", message, CWE398, Certainty::inconclusive);
|
||||||
reportError(tok, Severity::warning, id, message, CWE398, Certainty::inconclusive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckClass::operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname, bool inconclusive)
|
void CheckClass::operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname, bool inconclusive)
|
||||||
|
|
|
@ -54,8 +54,8 @@ static const CWE CWE672(672U);
|
||||||
static const CWE CWE415(415U);
|
static const CWE CWE415(415U);
|
||||||
|
|
||||||
// Hardcoded allocation types (not from library)
|
// Hardcoded allocation types (not from library)
|
||||||
static const int NEW_ARRAY = -2;
|
static constexpr int NEW_ARRAY = -2;
|
||||||
static const int NEW = -1;
|
static constexpr int NEW = -1;
|
||||||
|
|
||||||
static const std::array<std::pair<std::string, std::string>, 4> alloc_failed_conds {{{"==", "0"}, {"<", "0"}, {"==", "-1"}, {"<=", "-1"}}};
|
static const std::array<std::pair<std::string, std::string>, 4> alloc_failed_conds {{{"==", "0"}, {"<", "0"}, {"==", "-1"}, {"<=", "-1"}}};
|
||||||
static const std::array<std::pair<std::string, std::string>, 4> alloc_success_conds {{{"!=", "0"}, {">", "0"}, {"!=", "-1"}, {">=", "0"}}};
|
static const std::array<std::pair<std::string, std::string>, 4> alloc_success_conds {{{"!=", "0"}, {">", "0"}, {"!=", "-1"}, {">=", "0"}}};
|
||||||
|
@ -304,9 +304,9 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken,
|
||||||
static const nonneg int recursiveLimit = 300;
|
static const nonneg int recursiveLimit = 300;
|
||||||
#elif defined(__MINGW32__)
|
#elif defined(__MINGW32__)
|
||||||
// testrunner crashes with stack overflow in CI
|
// testrunner crashes with stack overflow in CI
|
||||||
static const nonneg int recursiveLimit = 600;
|
static constexpr nonneg int recursiveLimit = 600;
|
||||||
#else
|
#else
|
||||||
static const nonneg int recursiveLimit = 1000;
|
static constexpr nonneg int recursiveLimit = 1000;
|
||||||
#endif
|
#endif
|
||||||
if (++recursiveCount > recursiveLimit) // maximum number of "else if ()"
|
if (++recursiveCount > recursiveLimit) // maximum number of "else if ()"
|
||||||
throw InternalError(startToken, "Internal limit: CheckLeakAutoVar::checkScope() Maximum recursive count of 1000 reached.", InternalError::LIMIT);
|
throw InternalError(startToken, "Internal limit: CheckLeakAutoVar::checkScope() Maximum recursive count of 1000 reached.", InternalError::LIMIT);
|
||||||
|
|
|
@ -3960,9 +3960,9 @@ void CheckOther::checkOverlappingWrite()
|
||||||
if (nonOverlappingData->sizeArg <= 0 || nonOverlappingData->sizeArg > args.size()) {
|
if (nonOverlappingData->sizeArg <= 0 || nonOverlappingData->sizeArg > args.size()) {
|
||||||
if (nonOverlappingData->sizeArg == -1) {
|
if (nonOverlappingData->sizeArg == -1) {
|
||||||
ErrorPath errorPath;
|
ErrorPath errorPath;
|
||||||
const bool macro = true;
|
constexpr bool macro = true;
|
||||||
const bool pure = true;
|
constexpr bool pure = true;
|
||||||
const bool follow = true;
|
constexpr bool follow = true;
|
||||||
if (!isSameExpression(mTokenizer->isCPP(), macro, ptr1, ptr2, mSettings->library, pure, follow, &errorPath))
|
if (!isSameExpression(mTokenizer->isCPP(), macro, ptr1, ptr2, mSettings->library, pure, follow, &errorPath))
|
||||||
continue;
|
continue;
|
||||||
overlappingWriteFunction(tok);
|
overlappingWriteFunction(tok);
|
||||||
|
@ -3985,9 +3985,9 @@ void CheckOther::checkOverlappingWrite()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ErrorPath errorPath;
|
ErrorPath errorPath;
|
||||||
const bool macro = true;
|
constexpr bool macro = true;
|
||||||
const bool pure = true;
|
constexpr bool pure = true;
|
||||||
const bool follow = true;
|
constexpr bool follow = true;
|
||||||
if (!isSameExpression(mTokenizer->isCPP(), macro, buf1, buf2, mSettings->library, pure, follow, &errorPath))
|
if (!isSameExpression(mTokenizer->isCPP(), macro, buf1, buf2, mSettings->library, pure, follow, &errorPath))
|
||||||
continue;
|
continue;
|
||||||
overlappingWriteFunction(tok);
|
overlappingWriteFunction(tok);
|
||||||
|
|
|
@ -140,7 +140,7 @@ void CheckString::checkAlwaysTrueOrFalseStringCompare()
|
||||||
|
|
||||||
void CheckString::alwaysTrueFalseStringCompareError(const Token *tok, const std::string& str1, const std::string& str2)
|
void CheckString::alwaysTrueFalseStringCompareError(const Token *tok, const std::string& str1, const std::string& str2)
|
||||||
{
|
{
|
||||||
const std::size_t stringLen = 10;
|
constexpr std::size_t stringLen = 10;
|
||||||
const std::string string1 = (str1.size() < stringLen) ? str1 : (str1.substr(0, stringLen-2) + "..");
|
const std::string string1 = (str1.size() < stringLen) ? str1 : (str1.substr(0, stringLen-2) + "..");
|
||||||
const std::string string2 = (str2.size() < stringLen) ? str2 : (str2.substr(0, stringLen-2) + "..");
|
const std::string string2 = (str2.size() < stringLen) ? str2 : (str2.substr(0, stringLen-2) + "..");
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ void CheckType::checkTooBigBitwiseShift()
|
||||||
|
|
||||||
void CheckType::tooBigBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
|
void CheckType::tooBigBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
|
||||||
{
|
{
|
||||||
const char id[] = "shiftTooManyBits";
|
constexpr char id[] = "shiftTooManyBits";
|
||||||
|
|
||||||
if (!tok) {
|
if (!tok) {
|
||||||
reportError(tok, Severity::error, id, "Shifting 32-bit value by 40 bits is undefined behaviour", CWE758, Certainty::normal);
|
reportError(tok, Severity::error, id, "Shifting 32-bit value by 40 bits is undefined behaviour", CWE758, Certainty::normal);
|
||||||
|
@ -131,7 +131,7 @@ void CheckType::tooBigBitwiseShiftError(const Token *tok, int lhsbits, const Val
|
||||||
|
|
||||||
void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
|
void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, const ValueFlow::Value &rhsbits)
|
||||||
{
|
{
|
||||||
const char id[] = "shiftTooManyBitsSigned";
|
constexpr char id[] = "shiftTooManyBitsSigned";
|
||||||
|
|
||||||
const bool cpp14 = mSettings->standards.cpp >= Standards::CPP14;
|
const bool cpp14 = mSettings->standards.cpp >= Standards::CPP14;
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,10 @@
|
||||||
|
|
||||||
class SymbolDatabase;
|
class SymbolDatabase;
|
||||||
|
|
||||||
static const char Version[] = CPPCHECK_VERSION_STRING;
|
static constexpr char Version[] = CPPCHECK_VERSION_STRING;
|
||||||
static const char ExtraVersion[] = "";
|
static constexpr char ExtraVersion[] = "";
|
||||||
|
|
||||||
static const char FILELIST[] = "cppcheck-addon-ctu-file-list";
|
static constexpr char FILELIST[] = "cppcheck-addon-ctu-file-list";
|
||||||
|
|
||||||
static TimerResults s_timerResults;
|
static TimerResults s_timerResults;
|
||||||
|
|
||||||
|
@ -1636,9 +1636,9 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings)
|
||||||
const std::string allDefines = getDefinesFlags(fileSettings.defines);
|
const std::string allDefines = getDefinesFlags(fileSettings.defines);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char exe[] = "clang-tidy.exe";
|
constexpr char exe[] = "clang-tidy.exe";
|
||||||
#else
|
#else
|
||||||
const char exe[] = "clang-tidy";
|
constexpr char exe[] = "clang-tidy";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string args = "-quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename + "\" -- " + allIncludes + allDefines;
|
const std::string args = "-quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename + "\" -- " + allIncludes + allDefines;
|
||||||
|
|
30
lib/ctu.cpp
30
lib/ctu.cpp
|
@ -39,21 +39,21 @@
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static const char ATTR_CALL_ID[] = "call-id";
|
static constexpr char ATTR_CALL_ID[] = "call-id";
|
||||||
static const char ATTR_CALL_FUNCNAME[] = "call-funcname";
|
static constexpr char ATTR_CALL_FUNCNAME[] = "call-funcname";
|
||||||
static const char ATTR_CALL_ARGNR[] = "call-argnr";
|
static constexpr char ATTR_CALL_ARGNR[] = "call-argnr";
|
||||||
static const char ATTR_CALL_ARGEXPR[] = "call-argexpr";
|
static constexpr char ATTR_CALL_ARGEXPR[] = "call-argexpr";
|
||||||
static const char ATTR_CALL_ARGVALUETYPE[] = "call-argvaluetype";
|
static constexpr char ATTR_CALL_ARGVALUETYPE[] = "call-argvaluetype";
|
||||||
static const char ATTR_CALL_ARGVALUE[] = "call-argvalue";
|
static constexpr char ATTR_CALL_ARGVALUE[] = "call-argvalue";
|
||||||
static const char ATTR_WARNING[] = "warning";
|
static constexpr char ATTR_WARNING[] = "warning";
|
||||||
static const char ATTR_LOC_FILENAME[] = "file";
|
static constexpr char ATTR_LOC_FILENAME[] = "file";
|
||||||
static const char ATTR_LOC_LINENR[] = "line";
|
static constexpr char ATTR_LOC_LINENR[] = "line";
|
||||||
static const char ATTR_LOC_COLUMN[] = "col";
|
static constexpr char ATTR_LOC_COLUMN[] = "col";
|
||||||
static const char ATTR_INFO[] = "info";
|
static constexpr char ATTR_INFO[] = "info";
|
||||||
static const char ATTR_MY_ID[] = "my-id";
|
static constexpr char ATTR_MY_ID[] = "my-id";
|
||||||
static const char ATTR_MY_ARGNR[] = "my-argnr";
|
static constexpr char ATTR_MY_ARGNR[] = "my-argnr";
|
||||||
static const char ATTR_MY_ARGNAME[] = "my-argname";
|
static constexpr char ATTR_MY_ARGNAME[] = "my-argname";
|
||||||
static const char ATTR_VALUE[] = "value";
|
static constexpr char ATTR_VALUE[] = "value";
|
||||||
|
|
||||||
int CTU::maxCtuDepth = 2;
|
int CTU::maxCtuDepth = 2;
|
||||||
|
|
||||||
|
|
16
lib/path.cpp
16
lib/path.cpp
|
@ -60,11 +60,11 @@ static constexpr bool caseInsensitiveFilesystem()
|
||||||
std::string Path::toNativeSeparators(std::string path)
|
std::string Path::toNativeSeparators(std::string path)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
const char separ = '/';
|
constexpr char separ = '/';
|
||||||
const char native = '\\';
|
constexpr char native = '\\';
|
||||||
#else
|
#else
|
||||||
const char separ = '\\';
|
constexpr char separ = '\\';
|
||||||
const char native = '/';
|
constexpr char native = '/';
|
||||||
#endif
|
#endif
|
||||||
std::replace(path.begin(), path.end(), separ, native);
|
std::replace(path.begin(), path.end(), separ, native);
|
||||||
return path;
|
return path;
|
||||||
|
@ -72,8 +72,8 @@ std::string Path::toNativeSeparators(std::string path)
|
||||||
|
|
||||||
std::string Path::fromNativeSeparators(std::string path)
|
std::string Path::fromNativeSeparators(std::string path)
|
||||||
{
|
{
|
||||||
const char nonnative = '\\';
|
constexpr char nonnative = '\\';
|
||||||
const char newsepar = '/';
|
constexpr char newsepar = '/';
|
||||||
std::replace(path.begin(), path.end(), nonnative, newsepar);
|
std::replace(path.begin(), path.end(), nonnative, newsepar);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -250,9 +250,9 @@ std::string Path::getAbsoluteFilePath(const std::string& filePath)
|
||||||
std::string Path::stripDirectoryPart(const std::string &file)
|
std::string Path::stripDirectoryPart(const std::string &file)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
const char native = '\\';
|
constexpr char native = '\\';
|
||||||
#else
|
#else
|
||||||
const char native = '/';
|
constexpr char native = '/';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string::size_type p = file.rfind(native);
|
const std::string::size_type p = file.rfind(native);
|
||||||
|
|
|
@ -171,7 +171,7 @@ void Summaries::loadReturn(const std::string &buildDir, std::set<std::string> &s
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(fin, line)) {
|
while (std::getline(fin, line)) {
|
||||||
// Get function name
|
// Get function name
|
||||||
const std::string::size_type pos1 = 0;
|
constexpr std::string::size_type pos1 = 0;
|
||||||
const std::string::size_type pos2 = line.find(' ', pos1);
|
const std::string::size_type pos2 = line.find(' ', pos1);
|
||||||
const std::string functionName = (pos2 == std::string::npos) ? line : line.substr(0, pos2);
|
const std::string functionName = (pos2 == std::string::npos) ? line : line.substr(0, pos2);
|
||||||
std::vector<std::string> call = getSummaryData(line, "call");
|
std::vector<std::string> call = getSummaryData(line, "call");
|
||||||
|
|
|
@ -3763,7 +3763,7 @@ void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime)
|
||||||
mTokenizer.calculateScopes();
|
mTokenizer.calculateScopes();
|
||||||
|
|
||||||
unsigned int passCount = 0;
|
unsigned int passCount = 0;
|
||||||
const unsigned int passCountMax = 10;
|
constexpr unsigned int passCountMax = 10;
|
||||||
for (; passCount < passCountMax; ++passCount) {
|
for (; passCount < passCountMax; ++passCount) {
|
||||||
if (passCount) {
|
if (passCount) {
|
||||||
// it may take more than one pass to simplify type aliases
|
// it may take more than one pass to simplify type aliases
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
// How many compileExpression recursions are allowed?
|
// How many compileExpression recursions are allowed?
|
||||||
// For practical code this could be endless. But in some special torture test
|
// For practical code this could be endless. But in some special torture test
|
||||||
// there needs to be a limit.
|
// there needs to be a limit.
|
||||||
static const int AST_MAX_DEPTH = 150;
|
static constexpr int AST_MAX_DEPTH = 150;
|
||||||
|
|
||||||
|
|
||||||
TokenList::TokenList(const Settings* settings) :
|
TokenList::TokenList(const Settings* settings) :
|
||||||
|
|
|
@ -407,7 +407,7 @@ static ValueFlow::Value castValue(ValueFlow::Value value, const ValueType::Sign
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bit < MathLib::bigint_bits) {
|
if (bit < MathLib::bigint_bits) {
|
||||||
const MathLib::biguint one = 1;
|
constexpr MathLib::biguint one = 1;
|
||||||
value.intvalue &= (one << bit) - 1;
|
value.intvalue &= (one << bit) - 1;
|
||||||
if (sign == ValueType::Sign::SIGNED && value.intvalue & (one << (bit - 1))) {
|
if (sign == ValueType::Sign::SIGNED && value.intvalue & (one << (bit - 1))) {
|
||||||
value.intvalue |= ~((one << bit) - 1ULL);
|
value.intvalue |= ~((one << bit) - 1ULL);
|
||||||
|
@ -3158,7 +3158,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupExprVarIds(const Token* start, int depth = 0) {
|
void setupExprVarIds(const Token* start, int depth = 0) {
|
||||||
const int maxDepth = 4;
|
constexpr int maxDepth = 4;
|
||||||
if (depth > maxDepth)
|
if (depth > maxDepth)
|
||||||
return;
|
return;
|
||||||
visitAstNodes(start, [&](const Token* tok) {
|
visitAstNodes(start, [&](const Token* tok) {
|
||||||
|
@ -8459,7 +8459,7 @@ struct IteratorConditionHandler : SimpleConditionHandler {
|
||||||
if (!tok->astOperand1() || !tok->astOperand2())
|
if (!tok->astOperand1() || !tok->astOperand2())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const ValueFlow::Value::ValueKind kind = ValueFlow::Value::ValueKind::Known;
|
constexpr ValueFlow::Value::ValueKind kind = ValueFlow::Value::ValueKind::Known;
|
||||||
std::list<ValueFlow::Value> values = getIteratorValues(tok->astOperand1()->values(), &kind);
|
std::list<ValueFlow::Value> values = getIteratorValues(tok->astOperand1()->values(), &kind);
|
||||||
if (!values.empty()) {
|
if (!values.empty()) {
|
||||||
cond.vartok = tok->astOperand2();
|
cond.vartok = tok->astOperand2();
|
||||||
|
|
|
@ -33,7 +33,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAnalyzerInfoFile() const {
|
void getAnalyzerInfoFile() const {
|
||||||
const char filesTxt[] = "file1.a4::file1.c\n";
|
constexpr char filesTxt[] = "file1.a4::file1.c\n";
|
||||||
std::istringstream f1(filesTxt);
|
std::istringstream f1(filesTxt);
|
||||||
ASSERT_EQUALS("file1.a4", getAnalyzerInfoFileFromFilesTxt(f1, "file1.c", ""));
|
ASSERT_EQUALS("file1.a4", getAnalyzerInfoFileFromFilesTxt(f1, "file1.c", ""));
|
||||||
std::istringstream f2(filesTxt);
|
std::istringstream f2(filesTxt);
|
||||||
|
|
|
@ -3597,7 +3597,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void buffer_overrun_readSizeFromCfg() {
|
void buffer_overrun_readSizeFromCfg() {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <podtype name=\"u8\" sign=\"u\" size=\"1\"/>\n"
|
" <podtype name=\"u8\" sign=\"u\" size=\"1\"/>\n"
|
||||||
" <function name=\"mystrcpy\">\n"
|
" <function name=\"mystrcpy\">\n"
|
||||||
|
@ -4149,7 +4149,7 @@ private:
|
||||||
// extracttests.disable
|
// extracttests.disable
|
||||||
|
|
||||||
void minsize_argvalue() {
|
void minsize_argvalue() {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"mymemset\">\n"
|
" <function name=\"mymemset\">\n"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
|
@ -4286,7 +4286,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void minsize_sizeof() {
|
void minsize_sizeof() {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"mystrncpy\">\n"
|
" <function name=\"mystrncpy\">\n"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
|
@ -4346,7 +4346,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void minsize_strlen() {
|
void minsize_strlen() {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"mysprintf\">\n"
|
" <function name=\"mysprintf\">\n"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
|
@ -4459,7 +4459,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void minsize_mul() {
|
void minsize_mul() {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"myfread\">\n"
|
" <function name=\"myfread\">\n"
|
||||||
" <arg nr=\"1\">\n"
|
" <arg nr=\"1\">\n"
|
||||||
|
|
|
@ -3444,7 +3444,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void memsetOnStdPodType() { // Ticket #5901
|
void memsetOnStdPodType() { // Ticket #5901
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <podtype name=\"std::uint8_t\" sign=\"u\" size=\"1\"/>\n"
|
" <podtype name=\"std::uint8_t\" sign=\"u\" size=\"1\"/>\n"
|
||||||
" <podtype name=\"std::atomic_bool\"/>\n"
|
" <podtype name=\"std::atomic_bool\"/>\n"
|
||||||
|
|
|
@ -1296,7 +1296,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkIgnoredReturnValue() {
|
void checkIgnoredReturnValue() {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def version=\"2\">\n"
|
"<def version=\"2\">\n"
|
||||||
" <function name=\"mystrcmp,foo::mystrcmp\">\n"
|
" <function name=\"mystrcmp,foo::mystrcmp\">\n"
|
||||||
" <use-retval/>\n"
|
" <use-retval/>\n"
|
||||||
|
|
|
@ -112,7 +112,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommands1() const {
|
void importCompileCommands1() const {
|
||||||
const char json[] = R"([{
|
constexpr char json[] = R"([{
|
||||||
"directory": "/tmp",
|
"directory": "/tmp",
|
||||||
"command": "gcc -DTEST1 -DTEST2=2 -o /tmp/src.o -c /tmp/src.c",
|
"command": "gcc -DTEST1 -DTEST2=2 -o /tmp/src.o -c /tmp/src.c",
|
||||||
"file": "/tmp/src.c"
|
"file": "/tmp/src.c"
|
||||||
|
@ -138,7 +138,7 @@ private:
|
||||||
ASSERT_EQUALS(1, importer.fileSettings.size());
|
ASSERT_EQUALS(1, importer.fileSettings.size());
|
||||||
ASSERT_EQUALS("C:/bar.c", importer.fileSettings.cbegin()->filename);
|
ASSERT_EQUALS("C:/bar.c", importer.fileSettings.cbegin()->filename);
|
||||||
#else
|
#else
|
||||||
const char json[] = R"([{
|
constexpr char json[] = R"([{
|
||||||
"directory": "/foo",
|
"directory": "/foo",
|
||||||
"command": "gcc -c bar.c",
|
"command": "gcc -c bar.c",
|
||||||
"file": "/bar.c"
|
"file": "/bar.c"
|
||||||
|
@ -165,7 +165,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommands4() const {
|
void importCompileCommands4() const {
|
||||||
const char json[] = R"([{
|
constexpr char json[] = R"([{
|
||||||
"directory": "/tmp/",
|
"directory": "/tmp/",
|
||||||
"command": "gcc -c src.mm",
|
"command": "gcc -c src.mm",
|
||||||
"file": "src.mm"
|
"file": "src.mm"
|
||||||
|
@ -177,7 +177,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommands5() const {
|
void importCompileCommands5() const {
|
||||||
const char json[] =
|
constexpr char json[] =
|
||||||
R"([{
|
R"([{
|
||||||
"directory": "C:/Users/dan/git/build-test-cppcheck-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug",
|
"directory": "C:/Users/dan/git/build-test-cppcheck-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug",
|
||||||
"command": "C:\\PROGRA~2\\MICROS~1\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1427~1.291\\bin\\HostX64\\x64\\cl.exe /nologo /TP -IC:\\Users\\dan\\git\\test-cppcheck\\mylib\\src /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++17 /Fomylib\\CMakeFiles\\mylib.dir\\src\\foobar\\mylib.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\Users\\dan\\git\\test-cppcheck\\mylib\\src\\foobar\\mylib.cpp",
|
"command": "C:\\PROGRA~2\\MICROS~1\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1427~1.291\\bin\\HostX64\\x64\\cl.exe /nologo /TP -IC:\\Users\\dan\\git\\test-cppcheck\\mylib\\src /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++17 /Fomylib\\CMakeFiles\\mylib.dir\\src\\foobar\\mylib.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\Users\\dan\\git\\test-cppcheck\\mylib\\src\\foobar\\mylib.cpp",
|
||||||
|
@ -196,7 +196,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommands6() const {
|
void importCompileCommands6() const {
|
||||||
const char json[] =
|
constexpr char json[] =
|
||||||
R"([{
|
R"([{
|
||||||
"directory": "C:/Users/dan/git/build-test-cppcheck-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug",
|
"directory": "C:/Users/dan/git/build-test-cppcheck-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug",
|
||||||
"command": "C:\\PROGRA~2\\MICROS~1\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1427~1.291\\bin\\HostX64\\x64\\cl.exe /nologo /TP -IC:\\Users\\dan\\git\\test-cppcheck\\mylib\\src -I\"C:\\Users\\dan\\git\\test-cppcheck\\mylib\\second src\" /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++17 /Fomylib\\CMakeFiles\\mylib.dir\\src\\foobar\\mylib.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\Users\\dan\\git\\test-cppcheck\\mylib\\src\\foobar\\mylib.cpp",
|
"command": "C:\\PROGRA~2\\MICROS~1\\2019\\COMMUN~1\\VC\\Tools\\MSVC\\1427~1.291\\bin\\HostX64\\x64\\cl.exe /nologo /TP -IC:\\Users\\dan\\git\\test-cppcheck\\mylib\\src -I\"C:\\Users\\dan\\git\\test-cppcheck\\mylib\\second src\" /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -std:c++17 /Fomylib\\CMakeFiles\\mylib.dir\\src\\foobar\\mylib.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\Users\\dan\\git\\test-cppcheck\\mylib\\src\\foobar\\mylib.cpp",
|
||||||
|
@ -218,7 +218,7 @@ private:
|
||||||
|
|
||||||
void importCompileCommands7() const {
|
void importCompileCommands7() const {
|
||||||
// cmake -DFILESDIR="/some/path" ..
|
// cmake -DFILESDIR="/some/path" ..
|
||||||
const char json[] =
|
constexpr char json[] =
|
||||||
R"([{
|
R"([{
|
||||||
"directory": "/home/danielm/cppcheck 2/b/lib",
|
"directory": "/home/danielm/cppcheck 2/b/lib",
|
||||||
"command": "/usr/bin/c++ -DFILESDIR=\\\"/some/path\\\" -I\"/home/danielm/cppcheck 2/b/lib\" -isystem \"/home/danielm/cppcheck 2/externals\" \"/home/danielm/cppcheck 2/lib/astutils.cpp\"",
|
"command": "/usr/bin/c++ -DFILESDIR=\\\"/some/path\\\" -I\"/home/danielm/cppcheck 2/b/lib\" -isystem \"/home/danielm/cppcheck 2/externals\" \"/home/danielm/cppcheck 2/lib/astutils.cpp\"",
|
||||||
|
@ -238,7 +238,7 @@ private:
|
||||||
|
|
||||||
void importCompileCommands8() const {
|
void importCompileCommands8() const {
|
||||||
// cmake -DFILESDIR="C:\Program Files\Cppcheck" -G"NMake Makefiles" ..
|
// cmake -DFILESDIR="C:\Program Files\Cppcheck" -G"NMake Makefiles" ..
|
||||||
const char json[] =
|
constexpr char json[] =
|
||||||
R"([{
|
R"([{
|
||||||
"directory": "C:/Users/danielm/cppcheck/build/lib",
|
"directory": "C:/Users/danielm/cppcheck/build/lib",
|
||||||
"command": "C:\\PROGRA~2\\MICROS~2\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1412~1.258\\bin\\Hostx64\\x64\\cl.exe /nologo /TP -DFILESDIR=\"\\\"C:\\Program Files\\Cppcheck\\\"\" -IC:\\Users\\danielm\\cppcheck\\build\\lib -IC:\\Users\\danielm\\cppcheck\\lib -c C:\\Users\\danielm\\cppcheck\\lib\\astutils.cpp",
|
"command": "C:\\PROGRA~2\\MICROS~2\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1412~1.258\\bin\\Hostx64\\x64\\cl.exe /nologo /TP -DFILESDIR=\"\\\"C:\\Program Files\\Cppcheck\\\"\" -IC:\\Users\\danielm\\cppcheck\\build\\lib -IC:\\Users\\danielm\\cppcheck\\lib -c C:\\Users\\danielm\\cppcheck\\lib\\astutils.cpp",
|
||||||
|
@ -251,7 +251,7 @@ private:
|
||||||
|
|
||||||
void importCompileCommands9() const {
|
void importCompileCommands9() const {
|
||||||
// IAR output (https://sourceforge.net/p/cppcheck/discussion/general/thread/608af51e0a/)
|
// IAR output (https://sourceforge.net/p/cppcheck/discussion/general/thread/608af51e0a/)
|
||||||
const char json[] =
|
constexpr char json[] =
|
||||||
R"([{
|
R"([{
|
||||||
"arguments" : [
|
"arguments" : [
|
||||||
"powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File d:\\Projekte\\xyz\\firmware\\app\\xyz-lib\\build.ps1 -IAR -COMPILER_PATH \"c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 9.0\" -CONTROLLER CC1310F128 -LIB LIB_PERMANENT -COMPILER_DEFINES \"CC1310_HFXO_FREQ=24000000 DEBUG\""
|
"powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File d:\\Projekte\\xyz\\firmware\\app\\xyz-lib\\build.ps1 -IAR -COMPILER_PATH \"c:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 9.0\" -CONTROLLER CC1310F128 -LIB LIB_PERMANENT -COMPILER_DEFINES \"CC1310_HFXO_FREQ=24000000 DEBUG\""
|
||||||
|
@ -266,7 +266,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommands10() const { // #10887
|
void importCompileCommands10() const { // #10887
|
||||||
const char json[] =
|
constexpr char json[] =
|
||||||
R"([{
|
R"([{
|
||||||
"file": "/home/danielm/cppcheck/1/test folder/1.c" ,
|
"file": "/home/danielm/cppcheck/1/test folder/1.c" ,
|
||||||
"directory": "",
|
"directory": "",
|
||||||
|
@ -285,7 +285,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommands11() const { // include path order
|
void importCompileCommands11() const { // include path order
|
||||||
const char json[] =
|
constexpr char json[] =
|
||||||
R"([{
|
R"([{
|
||||||
"file": "1.c" ,
|
"file": "1.c" ,
|
||||||
"directory": "/x",
|
"directory": "/x",
|
||||||
|
@ -307,7 +307,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommandsArgumentsSection() const {
|
void importCompileCommandsArgumentsSection() const {
|
||||||
const char json[] = "[ { \"directory\": \"/tmp/\","
|
constexpr char json[] = "[ { \"directory\": \"/tmp/\","
|
||||||
"\"arguments\": [\"gcc\", \"-c\", \"src.c\"],"
|
"\"arguments\": [\"gcc\", \"-c\", \"src.c\"],"
|
||||||
"\"file\": \"src.c\" } ]";
|
"\"file\": \"src.c\" } ]";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
|
@ -318,7 +318,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCompileCommandsNoCommandSection() const {
|
void importCompileCommandsNoCommandSection() const {
|
||||||
const char json[] = "[ { \"directory\": \"/tmp/\","
|
constexpr char json[] = "[ { \"directory\": \"/tmp/\","
|
||||||
"\"file\": \"src.mm\" } ]";
|
"\"file\": \"src.mm\" } ]";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
|
@ -327,7 +327,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void importCppcheckGuiProject() const {
|
void importCppcheckGuiProject() const {
|
||||||
const char xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
constexpr char xml[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
"<project version=\"1\">\n"
|
"<project version=\"1\">\n"
|
||||||
" <root name=\".\"/>\n"
|
" <root name=\".\"/>\n"
|
||||||
" <builddir>out1</builddir>\n"
|
" <builddir>out1</builddir>\n"
|
||||||
|
|
|
@ -39,7 +39,7 @@ private:
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
|
||||||
void run() override {
|
void run() override {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <podtype name=\"uint8_t\" sign=\"u\" size=\"1\"/>\n"
|
" <podtype name=\"uint8_t\" sign=\"u\" size=\"1\"/>\n"
|
||||||
" <memory>\n"
|
" <memory>\n"
|
||||||
|
@ -2777,7 +2777,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void functionCallCastConfig() { // #9652
|
void functionCallCastConfig() { // #9652
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def format=\"2\">\n"
|
"<def format=\"2\">\n"
|
||||||
" <function name=\"free_func\">\n"
|
" <function name=\"free_func\">\n"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
|
@ -2814,7 +2814,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void functionCallLeakIgnoreConfig() { // #7923
|
void functionCallLeakIgnoreConfig() { // #7923
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def format=\"2\">\n"
|
"<def format=\"2\">\n"
|
||||||
" <function name=\"SomeClass::someMethod\">\n"
|
" <function name=\"SomeClass::someMethod\">\n"
|
||||||
" <leak-ignore/>\n"
|
" <leak-ignore/>\n"
|
||||||
|
|
|
@ -102,14 +102,14 @@ private:
|
||||||
|
|
||||||
void empty() const {
|
void empty() const {
|
||||||
// Reading an empty library file is considered to be OK
|
// Reading an empty library file is considered to be OK
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n<def/>";
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n<def/>";
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
ASSERT(library.functions.empty());
|
ASSERT(library.functions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void function() const {
|
void function() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
|
@ -129,7 +129,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_match_scope() const {
|
void function_match_scope() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"/>"
|
" <arg nr=\"1\"/>"
|
||||||
|
@ -155,7 +155,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_match_args() const {
|
void function_match_args() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"/>"
|
" <arg nr=\"1\"/>"
|
||||||
|
@ -174,7 +174,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_match_args_default() const {
|
void function_match_args_default() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"/>"
|
" <arg nr=\"1\"/>"
|
||||||
|
@ -224,7 +224,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_match_var() const {
|
void function_match_var() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"/>"
|
" <arg nr=\"1\"/>"
|
||||||
|
@ -243,7 +243,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_arg() const {
|
void function_arg() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"><not-uninit/></arg>\n"
|
" <arg nr=\"1\"><not-uninit/></arg>\n"
|
||||||
|
@ -266,7 +266,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_arg_any() const {
|
void function_arg_any() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
"<function name=\"foo\">\n"
|
"<function name=\"foo\">\n"
|
||||||
" <arg nr=\"any\"><not-uninit/></arg>\n"
|
" <arg nr=\"any\"><not-uninit/></arg>\n"
|
||||||
|
@ -279,7 +279,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_arg_variadic() const {
|
void function_arg_variadic() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
"<function name=\"foo\">\n"
|
"<function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"></arg>\n"
|
" <arg nr=\"1\"></arg>\n"
|
||||||
|
@ -303,7 +303,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_arg_direction() const {
|
void function_arg_direction() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
"<function name=\"foo\">\n"
|
"<function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\" direction=\"in\"></arg>\n"
|
" <arg nr=\"1\" direction=\"in\"></arg>\n"
|
||||||
|
@ -328,7 +328,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_arg_valid() const {
|
void function_arg_valid() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"><valid>1:</valid></arg>\n"
|
" <arg nr=\"1\"><valid>1:</valid></arg>\n"
|
||||||
|
@ -476,7 +476,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_arg_minsize() const {
|
void function_arg_minsize() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"foo\">\n"
|
" <function name=\"foo\">\n"
|
||||||
" <arg nr=\"1\"><minsize type=\"strlen\" arg=\"2\"/></arg>\n"
|
" <arg nr=\"1\"><minsize type=\"strlen\" arg=\"2\"/></arg>\n"
|
||||||
|
@ -539,7 +539,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_namespace() const {
|
void function_namespace() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"Foo::foo,bar\">\n"
|
" <function name=\"Foo::foo,bar\">\n"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
|
@ -568,7 +568,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_method() const {
|
void function_method() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"CString::Format\">\n"
|
" <function name=\"CString::Format\">\n"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
|
@ -595,7 +595,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_baseClassMethod() const {
|
void function_baseClassMethod() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"Base::f\">\n"
|
" <function name=\"Base::f\">\n"
|
||||||
" <arg nr=\"1\"><not-null/></arg>\n"
|
" <arg nr=\"1\"><not-null/></arg>\n"
|
||||||
|
@ -621,7 +621,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void function_warn() const {
|
void function_warn() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"a\">\n"
|
" <function name=\"a\">\n"
|
||||||
" <warn severity=\"style\" cstd=\"c99\">Message</warn>\n"
|
" <warn severity=\"style\" cstd=\"c99\">Message</warn>\n"
|
||||||
|
@ -657,7 +657,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void memory() const {
|
void memory() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <memory>\n"
|
" <memory>\n"
|
||||||
" <alloc>CreateX</alloc>\n"
|
" <alloc>CreateX</alloc>\n"
|
||||||
|
@ -677,14 +677,14 @@ private:
|
||||||
ASSERT(df && df->arg == 1);
|
ASSERT(df && df->arg == 1);
|
||||||
}
|
}
|
||||||
void memory2() const {
|
void memory2() const {
|
||||||
const char xmldata1[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata1[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <memory>\n"
|
" <memory>\n"
|
||||||
" <alloc>malloc</alloc>\n"
|
" <alloc>malloc</alloc>\n"
|
||||||
" <dealloc>free</dealloc>\n"
|
" <dealloc>free</dealloc>\n"
|
||||||
" </memory>\n"
|
" </memory>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const char xmldata2[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata2[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <memory>\n"
|
" <memory>\n"
|
||||||
" <alloc>foo</alloc>\n"
|
" <alloc>foo</alloc>\n"
|
||||||
|
@ -700,7 +700,7 @@ private:
|
||||||
ASSERT_EQUALS(library.deallocId("free"), library.allocId("foo"));
|
ASSERT_EQUALS(library.deallocId("free"), library.allocId("foo"));
|
||||||
}
|
}
|
||||||
void memory3() const {
|
void memory3() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <memory>\n"
|
" <memory>\n"
|
||||||
" <alloc arg=\"5\" init=\"false\">CreateX</alloc>\n"
|
" <alloc arg=\"5\" init=\"false\">CreateX</alloc>\n"
|
||||||
|
@ -719,7 +719,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void resource() const {
|
void resource() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <resource>\n"
|
" <resource>\n"
|
||||||
" <alloc>CreateX</alloc>\n"
|
" <alloc>CreateX</alloc>\n"
|
||||||
|
@ -737,7 +737,7 @@ private:
|
||||||
|
|
||||||
void podtype() const {
|
void podtype() const {
|
||||||
{
|
{
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <podtype name=\"s8\" sign=\"s\" size=\"1\"/>\n"
|
" <podtype name=\"s8\" sign=\"s\" size=\"1\"/>\n"
|
||||||
" <podtype name=\"u8\" sign=\"u\" size=\"1\"/>\n"
|
" <podtype name=\"u8\" sign=\"u\" size=\"1\"/>\n"
|
||||||
|
@ -791,7 +791,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void container() const {
|
void container() const {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <container id=\"A\" startPattern=\"std :: A <\" endPattern=\"> !!::\" itEndPattern=\"> :: iterator\">\n"
|
" <container id=\"A\" startPattern=\"std :: A <\" endPattern=\"> !!::\" itEndPattern=\"> :: iterator\">\n"
|
||||||
" <type templateParameter=\"1\"/>\n"
|
" <type templateParameter=\"1\"/>\n"
|
||||||
|
@ -936,21 +936,21 @@ private:
|
||||||
|
|
||||||
void version() const {
|
void version() const {
|
||||||
{
|
{
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def format=\"1\">\n"
|
"<def format=\"1\">\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def format=\"42\">\n"
|
"<def format=\"42\">\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
Library library;
|
Library library;
|
||||||
|
|
|
@ -355,12 +355,12 @@ private:
|
||||||
|
|
||||||
// min/max and out-of-bounds - hex
|
// min/max and out-of-bounds - hex
|
||||||
{
|
{
|
||||||
const MathLib::bigint i = 0xFFFFFFFFFFFFFFFF;
|
constexpr MathLib::bigint i = 0xFFFFFFFFFFFFFFFF;
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber("0xFFFFFFFFFFFFFFFF"));
|
ASSERT_EQUALS(i, MathLib::toBigNumber("0xFFFFFFFFFFFFFFFF"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const MathLib::bigint i = -0xFFFFFFFFFFFFFFFF;
|
constexpr MathLib::bigint i = -0xFFFFFFFFFFFFFFFF;
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber("-0xFFFFFFFFFFFFFFFF"));
|
ASSERT_EQUALS(i, MathLib::toBigNumber("-0xFFFFFFFFFFFFFFFF"));
|
||||||
}
|
}
|
||||||
|
@ -370,12 +370,12 @@ private:
|
||||||
|
|
||||||
// min/max and out-of-bounds - octal
|
// min/max and out-of-bounds - octal
|
||||||
{
|
{
|
||||||
const MathLib::bigint i = 01777777777777777777777;
|
constexpr MathLib::bigint i = 01777777777777777777777;
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber("01777777777777777777777"));
|
ASSERT_EQUALS(i, MathLib::toBigNumber("01777777777777777777777"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const MathLib::bigint i = -01777777777777777777777;
|
constexpr MathLib::bigint i = -01777777777777777777777;
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber("-01777777777777777777777"));
|
ASSERT_EQUALS(i, MathLib::toBigNumber("-01777777777777777777777"));
|
||||||
}
|
}
|
||||||
|
@ -387,12 +387,12 @@ private:
|
||||||
SUPPRESS_WARNING_CLANG_PUSH("-Wimplicitly-unsigned-literal")
|
SUPPRESS_WARNING_CLANG_PUSH("-Wimplicitly-unsigned-literal")
|
||||||
SUPPRESS_WARNING_GCC_PUSH("-Woverflow")
|
SUPPRESS_WARNING_GCC_PUSH("-Woverflow")
|
||||||
{
|
{
|
||||||
const MathLib::bigint i = 18446744073709551615;
|
constexpr MathLib::bigint i = 18446744073709551615;
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber("18446744073709551615"));
|
ASSERT_EQUALS(i, MathLib::toBigNumber("18446744073709551615"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const MathLib::bigint i = -18446744073709551615;
|
constexpr MathLib::bigint i = -18446744073709551615;
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
ASSERT_EQUALS(i, MathLib::toBigNumber(std::to_string(i)));
|
||||||
ASSERT_EQUALS(i, MathLib::toBigNumber("-18446744073709551615"));
|
ASSERT_EQUALS(i, MathLib::toBigNumber("-18446744073709551615"));
|
||||||
}
|
}
|
||||||
|
@ -520,12 +520,12 @@ private:
|
||||||
|
|
||||||
// min/max and out-of-bounds - hex
|
// min/max and out-of-bounds - hex
|
||||||
{
|
{
|
||||||
const MathLib::biguint u = 0xFFFFFFFFFFFFFFFF;
|
constexpr MathLib::biguint u = 0xFFFFFFFFFFFFFFFF;
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber("0xFFFFFFFFFFFFFFFF"));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber("0xFFFFFFFFFFFFFFFF"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const MathLib::biguint u = -0xFFFFFFFFFFFFFFFF;
|
constexpr MathLib::biguint u = -0xFFFFFFFFFFFFFFFF;
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber("-0xFFFFFFFFFFFFFFFF"));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber("-0xFFFFFFFFFFFFFFFF"));
|
||||||
}
|
}
|
||||||
|
@ -535,12 +535,12 @@ private:
|
||||||
|
|
||||||
// min/max and out-of-bounds - octal
|
// min/max and out-of-bounds - octal
|
||||||
{
|
{
|
||||||
const MathLib::biguint u = 01777777777777777777777;
|
constexpr MathLib::biguint u = 01777777777777777777777;
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber("01777777777777777777777"));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber("01777777777777777777777"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const MathLib::biguint u = -01777777777777777777777;
|
constexpr MathLib::biguint u = -01777777777777777777777;
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber("-01777777777777777777777"));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber("-01777777777777777777777"));
|
||||||
}
|
}
|
||||||
|
@ -552,12 +552,12 @@ private:
|
||||||
SUPPRESS_WARNING_CLANG_PUSH("-Wimplicitly-unsigned-literal")
|
SUPPRESS_WARNING_CLANG_PUSH("-Wimplicitly-unsigned-literal")
|
||||||
SUPPRESS_WARNING_GCC_PUSH("-Woverflow")
|
SUPPRESS_WARNING_GCC_PUSH("-Woverflow")
|
||||||
{
|
{
|
||||||
const MathLib::biguint u = 18446744073709551615;
|
constexpr MathLib::biguint u = 18446744073709551615;
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber("18446744073709551615"));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber("18446744073709551615"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const MathLib::biguint u = -18446744073709551615;
|
constexpr MathLib::biguint u = -18446744073709551615;
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber(std::to_string(u)));
|
||||||
ASSERT_EQUALS(u, MathLib::toBigUNumber("-18446744073709551615"));
|
ASSERT_EQUALS(u, MathLib::toBigUNumber("-18446744073709551615"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4702,7 +4702,7 @@ private:
|
||||||
"}", nullptr, false, false);
|
"}", nullptr, false, false);
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str());
|
||||||
|
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"exit\">\n"
|
" <function name=\"exit\">\n"
|
||||||
" <noreturn>true</noreturn>\n"
|
" <noreturn>true</noreturn>\n"
|
||||||
|
@ -6391,7 +6391,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void duplicateExpression3() {
|
void duplicateExpression3() {
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"mystrcmp\">\n"
|
" <function name=\"mystrcmp\">\n"
|
||||||
" <pure/>\n"
|
" <pure/>\n"
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
|
|
||||||
void empty() const {
|
void empty() const {
|
||||||
// An empty platform file does not change values, only the type.
|
// An empty platform file does not change values, only the type.
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n<platform/>";
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n<platform/>";
|
||||||
Platform platform;
|
Platform platform;
|
||||||
// TODO: this should fail - platform files need to be complete
|
// TODO: this should fail - platform files need to be complete
|
||||||
TODO_ASSERT(!readPlatform(platform, xmldata));
|
TODO_ASSERT(!readPlatform(platform, xmldata));
|
||||||
|
@ -189,7 +189,7 @@ private:
|
||||||
void valid_config_file_1() const {
|
void valid_config_file_1() const {
|
||||||
// Valid platform configuration with all possible values specified.
|
// Valid platform configuration with all possible values specified.
|
||||||
// Similar to the avr8 platform file.
|
// Similar to the avr8 platform file.
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<platform>\n"
|
"<platform>\n"
|
||||||
" <char_bit>8</char_bit>\n"
|
" <char_bit>8</char_bit>\n"
|
||||||
" <default-sign>unsigned</default-sign>\n"
|
" <default-sign>unsigned</default-sign>\n"
|
||||||
|
@ -233,7 +233,7 @@ private:
|
||||||
void valid_config_file_2() const {
|
void valid_config_file_2() const {
|
||||||
// Valid platform configuration with all possible values specified and
|
// Valid platform configuration with all possible values specified and
|
||||||
// char_bit > 8.
|
// char_bit > 8.
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<platform>\n"
|
"<platform>\n"
|
||||||
" <char_bit>20</char_bit>\n"
|
" <char_bit>20</char_bit>\n"
|
||||||
" <default-sign>signed</default-sign>\n"
|
" <default-sign>signed</default-sign>\n"
|
||||||
|
@ -277,7 +277,7 @@ private:
|
||||||
void valid_config_file_3() const {
|
void valid_config_file_3() const {
|
||||||
// Valid platform configuration without any usable information.
|
// Valid platform configuration without any usable information.
|
||||||
// Similar like an empty file.
|
// Similar like an empty file.
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<platform>\n"
|
"<platform>\n"
|
||||||
" <char_bit1>8</char_bit1>\n"
|
" <char_bit1>8</char_bit1>\n"
|
||||||
" <default-sign1>unsigned</default-sign1>\n"
|
" <default-sign1>unsigned</default-sign1>\n"
|
||||||
|
@ -303,7 +303,7 @@ private:
|
||||||
void valid_config_file_4() const {
|
void valid_config_file_4() const {
|
||||||
// Valid platform configuration with all possible values specified and
|
// Valid platform configuration with all possible values specified and
|
||||||
// set to 0.
|
// set to 0.
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<platform>\n"
|
"<platform>\n"
|
||||||
" <char_bit>0</char_bit>\n"
|
" <char_bit>0</char_bit>\n"
|
||||||
" <default-sign>z</default-sign>\n"
|
" <default-sign>z</default-sign>\n"
|
||||||
|
@ -346,7 +346,7 @@ private:
|
||||||
|
|
||||||
void invalid_config_file_1() const {
|
void invalid_config_file_1() const {
|
||||||
// Invalid XML file: mismatching elements "boolt" vs "bool".
|
// Invalid XML file: mismatching elements "boolt" vs "bool".
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<platform>\n"
|
"<platform>\n"
|
||||||
" <char_bit>8</char_bit>\n"
|
" <char_bit>8</char_bit>\n"
|
||||||
" <default-sign>unsigned</default-sign>\n"
|
" <default-sign>unsigned</default-sign>\n"
|
||||||
|
@ -371,7 +371,7 @@ private:
|
||||||
void empty_elements() const {
|
void empty_elements() const {
|
||||||
// Valid platform configuration without any usable information.
|
// Valid platform configuration without any usable information.
|
||||||
// Similar like an empty file.
|
// Similar like an empty file.
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<platform>\n"
|
"<platform>\n"
|
||||||
" <char_bit></char_bit>\n"
|
" <char_bit></char_bit>\n"
|
||||||
" <default-sign></default-sign>\n"
|
" <default-sign></default-sign>\n"
|
||||||
|
|
|
@ -289,9 +289,9 @@ private:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char exe[] = "clang-tidy.exe";
|
constexpr char exe[] = "clang-tidy.exe";
|
||||||
#else
|
#else
|
||||||
const char exe[] = "clang-tidy";
|
constexpr char exe[] = "clang-tidy";
|
||||||
#endif
|
#endif
|
||||||
(void)exe;
|
(void)exe;
|
||||||
|
|
||||||
|
|
|
@ -276,9 +276,9 @@ private:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char exe[] = "clang-tidy.exe";
|
constexpr char exe[] = "clang-tidy.exe";
|
||||||
#else
|
#else
|
||||||
const char exe[] = "clang-tidy";
|
constexpr char exe[] = "clang-tidy";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string file = fprefix() + "_001.cpp";
|
const std::string file = fprefix() + "_001.cpp";
|
||||||
|
|
|
@ -6167,7 +6167,7 @@ private:
|
||||||
ASSERT(db);
|
ASSERT(db);
|
||||||
const Scope * bar = db->findScopeByName("bar");
|
const Scope * bar = db->findScopeByName("bar");
|
||||||
ASSERT(bar != nullptr);
|
ASSERT(bar != nullptr);
|
||||||
const unsigned int linenrs[2] = { 2, 1 };
|
constexpr unsigned int linenrs[2] = { 2, 1 };
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
for (const Token * tok = bar->bodyStart->next(); tok != bar->bodyEnd; tok = tok->next()) {
|
for (const Token * tok = bar->bodyStart->next(); tok != bar->bodyEnd; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "%name% (") && !tok->varId() && Token::simpleMatch(tok->linkAt(1), ") ;")) {
|
if (Token::Match(tok, "%name% (") && !tok->varId() && Token::simpleMatch(tok->linkAt(1), ") ;")) {
|
||||||
|
@ -8520,9 +8520,9 @@ private:
|
||||||
{
|
{
|
||||||
// Char types
|
// Char types
|
||||||
Settings settings;
|
Settings settings;
|
||||||
const Library::PodType char8 = { 1, 'u' };
|
constexpr Library::PodType char8 = { 1, 'u' };
|
||||||
const Library::PodType char16 = { 2, 'u' };
|
constexpr Library::PodType char16 = { 2, 'u' };
|
||||||
const Library::PodType char32 = { 4, 'u' };
|
constexpr Library::PodType char32 = { 4, 'u' };
|
||||||
settings.library.mPodTypes["char8_t"] = char8;
|
settings.library.mPodTypes["char8_t"] = char8;
|
||||||
settings.library.mPodTypes["char16_t"] = char16;
|
settings.library.mPodTypes["char16_t"] = char16;
|
||||||
settings.library.mPodTypes["char32_t"] = char32;
|
settings.library.mPodTypes["char32_t"] = char32;
|
||||||
|
@ -8539,8 +8539,8 @@ private:
|
||||||
{
|
{
|
||||||
// PodType
|
// PodType
|
||||||
Settings settingsWin64 = settingsBuilder().platform(Platform::Type::Win64).build();
|
Settings settingsWin64 = settingsBuilder().platform(Platform::Type::Win64).build();
|
||||||
const Library::PodType u32 = { 4, 'u' };
|
constexpr Library::PodType u32 = { 4, 'u' };
|
||||||
const Library::PodType podtype2 = { 0, 'u', Library::PodType::Type::INT };
|
constexpr Library::PodType podtype2 = { 0, 'u', Library::PodType::Type::INT };
|
||||||
settingsWin64.library.mPodTypes["u32"] = u32;
|
settingsWin64.library.mPodTypes["u32"] = u32;
|
||||||
settingsWin64.library.mPodTypes["xyz::x"] = u32;
|
settingsWin64.library.mPodTypes["xyz::x"] = u32;
|
||||||
settingsWin64.library.mPodTypes["podtype2"] = podtype2;
|
settingsWin64.library.mPodTypes["podtype2"] = podtype2;
|
||||||
|
|
|
@ -288,9 +288,9 @@ private:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char exe[] = "clang-tidy.exe";
|
constexpr char exe[] = "clang-tidy.exe";
|
||||||
#else
|
#else
|
||||||
const char exe[] = "clang-tidy";
|
constexpr char exe[] = "clang-tidy";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string file = fprefix() + "_1.cpp";
|
const std::string file = fprefix() + "_1.cpp";
|
||||||
|
|
|
@ -833,7 +833,7 @@ private:
|
||||||
|
|
||||||
{
|
{
|
||||||
// Ticket #6701 - Variable name is a POD type according to cfg
|
// Ticket #6701 - Variable name is a POD type according to cfg
|
||||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def format=\"1\">"
|
"<def format=\"1\">"
|
||||||
" <podtype name=\"_tm\"/>"
|
" <podtype name=\"_tm\"/>"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
@ -4470,7 +4470,7 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
{
|
{
|
||||||
const char argDirectionsTestXmlData[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char argDirectionsTestXmlData[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"uninitvar_funcArgInTest\">\n"
|
" <function name=\"uninitvar_funcArgInTest\">\n"
|
||||||
" <arg nr=\"1\" direction=\"in\"/>\n"
|
" <arg nr=\"1\" direction=\"in\"/>\n"
|
||||||
|
|
|
@ -5354,7 +5354,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void localvarOp() {
|
void localvarOp() {
|
||||||
const char op[] = "+-*/%&|^";
|
constexpr char op[] = "+-*/%&|^";
|
||||||
for (const char *p = op; *p; ++p) {
|
for (const char *p = op; *p; ++p) {
|
||||||
std::string code("int main()\n"
|
std::string code("int main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
|
|
||||||
void run() override {
|
void run() override {
|
||||||
// strcpy, abort cfg
|
// strcpy, abort cfg
|
||||||
const char cfg[] = "<?xml version=\"1.0\"?>\n"
|
constexpr char cfg[] = "<?xml version=\"1.0\"?>\n"
|
||||||
"<def>\n"
|
"<def>\n"
|
||||||
" <function name=\"strcpy\"> <arg nr=\"1\"><not-null/></arg> </function>\n"
|
" <function name=\"strcpy\"> <arg nr=\"1\"><not-null/></arg> </function>\n"
|
||||||
" <function name=\"abort\"> <noreturn>true</noreturn> </function>\n" // abort is a noreturn function
|
" <function name=\"abort\"> <noreturn>true</noreturn> </function>\n" // abort is a noreturn function
|
||||||
|
|
|
@ -431,7 +431,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char makefile[] = "Makefile";
|
static constexpr char makefile[] = "Makefile";
|
||||||
std::ofstream fout(makefile, std::ios_base::trunc);
|
std::ofstream fout(makefile, std::ios_base::trunc);
|
||||||
if (!fout.is_open()) {
|
if (!fout.is_open()) {
|
||||||
std::cerr << "An error occurred while trying to open "
|
std::cerr << "An error occurred while trying to open "
|
||||||
|
|
|
@ -64,7 +64,7 @@ class QWidget;
|
||||||
const QString WORK_FOLDER(QDir::homePath() + "/triage");
|
const QString WORK_FOLDER(QDir::homePath() + "/triage");
|
||||||
const QString DACA2_PACKAGES(QDir::homePath() + "/daca2-packages");
|
const QString DACA2_PACKAGES(QDir::homePath() + "/daca2-packages");
|
||||||
|
|
||||||
const int MAX_ERRORS = 100;
|
constexpr int MAX_ERRORS = 100;
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
|
|
Loading…
Reference in New Issue