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,17 +3597,17 @@ 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"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
" <arg nr=\"1\">\n"
|
" <arg nr=\"1\">\n"
|
||||||
" <minsize type=\"strlen\" arg=\"2\"/>\n"
|
" <minsize type=\"strlen\" arg=\"2\"/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" <arg nr=\"2\"/>\n"
|
" <arg nr=\"2\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
// Attempt to get size from Cfg files, no false positives if size is not specified
|
// Attempt to get size from Cfg files, no false positives if size is not specified
|
||||||
|
@ -4149,17 +4149,17 @@ 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"
|
||||||
" <arg nr=\"1\">\n"
|
" <arg nr=\"1\">\n"
|
||||||
" <minsize type=\"argvalue\" arg=\"3\"/>\n"
|
" <minsize type=\"argvalue\" arg=\"3\"/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" <arg nr=\"2\"/>\n"
|
" <arg nr=\"2\"/>\n"
|
||||||
" <arg nr=\"3\"/>\n"
|
" <arg nr=\"3\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).severity(Severity::warning).build();
|
Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).severity(Severity::warning).build();
|
||||||
settings.platform.sizeof_wchar_t = 4;
|
settings.platform.sizeof_wchar_t = 4;
|
||||||
|
|
||||||
|
@ -4286,18 +4286,18 @@ 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"
|
||||||
" <arg nr=\"1\">\n"
|
" <arg nr=\"1\">\n"
|
||||||
" <minsize type=\"strlen\" arg=\"2\"/>\n"
|
" <minsize type=\"strlen\" arg=\"2\"/>\n"
|
||||||
" <minsize type=\"argvalue\" arg=\"3\"/>\n"
|
" <minsize type=\"argvalue\" arg=\"3\"/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" <arg nr=\"2\"/>\n"
|
" <arg nr=\"2\"/>\n"
|
||||||
" <arg nr=\"3\"/>\n"
|
" <arg nr=\"3\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
|
@ -4346,19 +4346,19 @@ 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"
|
||||||
" <formatstr/>\n"
|
" <formatstr/>\n"
|
||||||
" <arg nr=\"1\">\n"
|
" <arg nr=\"1\">\n"
|
||||||
" <minsize type=\"strlen\" arg=\"2\"/>\n"
|
" <minsize type=\"strlen\" arg=\"2\"/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" <arg nr=\"2\">\n"
|
" <arg nr=\"2\">\n"
|
||||||
" <formatstr/>\n"
|
" <formatstr/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
// formatstr..
|
// formatstr..
|
||||||
|
@ -4459,17 +4459,17 @@ 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"
|
||||||
" <minsize type=\"mul\" arg=\"2\" arg2=\"3\"/>\n"
|
" <minsize type=\"mul\" arg=\"2\" arg2=\"3\"/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" <arg nr=\"2\"/>\n"
|
" <arg nr=\"2\"/>\n"
|
||||||
" <arg nr=\"3\"/>\n"
|
" <arg nr=\"3\"/>\n"
|
||||||
" <arg nr=\"4\"/>\n"
|
" <arg nr=\"4\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
|
|
|
@ -3444,11 +3444,11 @@ 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"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
checkNoMemset("class A {\n"
|
checkNoMemset("class A {\n"
|
||||||
|
|
|
@ -1296,14 +1296,14 @@ 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"
|
||||||
" <arg nr=\"1\"/>\n"
|
" <arg nr=\"1\"/>\n"
|
||||||
" <arg nr=\"2\"/>\n"
|
" <arg nr=\"2\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings settings2 = settingsBuilder().severity(Severity::warning).libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settings2 = settingsBuilder().severity(Severity::warning).libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
|
|
|
@ -112,11 +112,11 @@ 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"
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
|
@ -138,11 +138,11 @@ 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"
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
|
@ -165,11 +165,11 @@ 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"
|
||||||
}])";
|
}])";
|
||||||
std::istringstream istr(json);
|
std::istringstream istr(json);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
|
@ -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,9 +307,9 @@ 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);
|
||||||
TestImporter importer;
|
TestImporter importer;
|
||||||
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
ASSERT_EQUALS(true, importer.importCompileCommands(istr));
|
||||||
|
@ -318,8 +318,8 @@ 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;
|
||||||
ASSERT_EQUALS(false, importer.importCompileCommands(istr));
|
ASSERT_EQUALS(false, importer.importCompileCommands(istr));
|
||||||
|
@ -327,22 +327,22 @@ 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"
|
||||||
" <analyze-all-vs-configs>true</analyze-all-vs-configs>\n"
|
" <analyze-all-vs-configs>true</analyze-all-vs-configs>\n"
|
||||||
" <includedir>\n"
|
" <includedir>\n"
|
||||||
" <dir name=\"lib/\"/>\n"
|
" <dir name=\"lib/\"/>\n"
|
||||||
" </includedir>\n"
|
" </includedir>\n"
|
||||||
" <paths>\n"
|
" <paths>\n"
|
||||||
" <dir name=\"cli/\"/>\n"
|
" <dir name=\"cli/\"/>\n"
|
||||||
" </paths>\n"
|
" </paths>\n"
|
||||||
" <exclude>\n"
|
" <exclude>\n"
|
||||||
" <path name=\"gui/temp/\"/>\n"
|
" <path name=\"gui/temp/\"/>\n"
|
||||||
" </exclude>\n"
|
" </exclude>\n"
|
||||||
" <project-name>test test</project-name>\n"
|
" <project-name>test test</project-name>\n"
|
||||||
"</project>\n";
|
"</project>\n";
|
||||||
std::istringstream istr(xml);
|
std::istringstream istr(xml);
|
||||||
Settings s;
|
Settings s;
|
||||||
TestImporter project;
|
TestImporter project;
|
||||||
|
|
|
@ -39,28 +39,28 @@ 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"
|
||||||
" <alloc>malloc</alloc>\n"
|
" <alloc>malloc</alloc>\n"
|
||||||
" <realloc>realloc</realloc>\n"
|
" <realloc>realloc</realloc>\n"
|
||||||
" <dealloc>free</dealloc>\n"
|
" <dealloc>free</dealloc>\n"
|
||||||
" </memory>\n"
|
" </memory>\n"
|
||||||
" <resource>\n"
|
" <resource>\n"
|
||||||
" <alloc>socket</alloc>\n"
|
" <alloc>socket</alloc>\n"
|
||||||
" <dealloc>close</dealloc>\n"
|
" <dealloc>close</dealloc>\n"
|
||||||
" </resource>\n"
|
" </resource>\n"
|
||||||
" <resource>\n"
|
" <resource>\n"
|
||||||
" <alloc>fopen</alloc>\n"
|
" <alloc>fopen</alloc>\n"
|
||||||
" <realloc realloc-arg=\"3\">freopen</realloc>\n"
|
" <realloc realloc-arg=\"3\">freopen</realloc>\n"
|
||||||
" <dealloc>fclose</dealloc>\n"
|
" <dealloc>fclose</dealloc>\n"
|
||||||
" </resource>\n"
|
" </resource>\n"
|
||||||
" <smart-pointer class-name=\"std::shared_ptr\"/>\n"
|
" <smart-pointer class-name=\"std::shared_ptr\"/>\n"
|
||||||
" <smart-pointer class-name=\"std::unique_ptr\">\n"
|
" <smart-pointer class-name=\"std::unique_ptr\">\n"
|
||||||
" <unique/>\n"
|
" <unique/>\n"
|
||||||
" </smart-pointer>\n"
|
" </smart-pointer>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
settings = settingsBuilder(settings).libraryxml(xmldata, sizeof(xmldata)).build();
|
settings = settingsBuilder(settings).libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
// Assign
|
// Assign
|
||||||
|
@ -2777,18 +2777,18 @@ 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"
|
||||||
" <arg nr=\"1\">\n"
|
" <arg nr=\"1\">\n"
|
||||||
" <not-uninit/>\n"
|
" <not-uninit/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" <arg nr=\"2\">\n"
|
" <arg nr=\"2\">\n"
|
||||||
" <not-uninit/>\n"
|
" <not-uninit/>\n"
|
||||||
" </arg>\n"
|
" </arg>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings settingsFunctionCall = settingsBuilder(settings).libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settingsFunctionCall = settingsBuilder(settings).libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
check("void test_func()\n"
|
check("void test_func()\n"
|
||||||
|
@ -2814,14 +2814,14 @@ 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"
|
||||||
" <noreturn>false</noreturn>\n"
|
" <noreturn>false</noreturn>\n"
|
||||||
" <arg nr=\"1\" direction=\"in\"/>\n"
|
" <arg nr=\"1\" direction=\"in\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>\n";
|
"</def>\n";
|
||||||
const Settings settingsLeakIgnore = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings settingsLeakIgnore = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" double* a = new double[1024];\n"
|
" double* a = new double[1024];\n"
|
||||||
|
|
|
@ -102,19 +102,19 @@ 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"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
TokenList tokenList(nullptr);
|
TokenList tokenList(nullptr);
|
||||||
std::istringstream istr("foo();");
|
std::istringstream istr("foo();");
|
||||||
|
@ -129,12 +129,12 @@ 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\"/>"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -155,12 +155,12 @@ 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\"/>"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
TokenList tokenList(nullptr);
|
TokenList tokenList(nullptr);
|
||||||
std::istringstream istr("foo();"); // <- too few arguments, not library function
|
std::istringstream istr("foo();"); // <- too few arguments, not library function
|
||||||
|
@ -174,13 +174,13 @@ 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\"/>"
|
||||||
" <arg nr=\"2\" default=\"0\"/>"
|
" <arg nr=\"2\" default=\"0\"/>"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -224,12 +224,12 @@ 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\"/>"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
TokenList tokenList(nullptr);
|
TokenList tokenList(nullptr);
|
||||||
std::istringstream istr("Fred foo(123);"); // <- Variable declaration, not library function
|
std::istringstream istr("Fred foo(123);"); // <- Variable declaration, not library function
|
||||||
|
@ -243,16 +243,16 @@ 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"
|
||||||
" <arg nr=\"2\"><not-null/></arg>\n"
|
" <arg nr=\"2\"><not-null/></arg>\n"
|
||||||
" <arg nr=\"3\"><formatstr/></arg>\n"
|
" <arg nr=\"3\"><formatstr/></arg>\n"
|
||||||
" <arg nr=\"4\"><strz/></arg>\n"
|
" <arg nr=\"4\"><strz/></arg>\n"
|
||||||
" <arg nr=\"5\" default=\"0\"><not-bool/></arg>\n"
|
" <arg nr=\"5\" default=\"0\"><not-bool/></arg>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -266,12 +266,12 @@ 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"
|
||||||
"</function>\n"
|
"</function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -279,13 +279,13 @@ 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"
|
||||||
" <arg nr=\"variadic\"><not-uninit/></arg>\n"
|
" <arg nr=\"variadic\"><not-uninit/></arg>\n"
|
||||||
"</function>\n"
|
"</function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -303,15 +303,15 @@ 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"
|
||||||
" <arg nr=\"2\" direction=\"out\"></arg>\n"
|
" <arg nr=\"2\" direction=\"out\"></arg>\n"
|
||||||
" <arg nr=\"3\" direction=\"inout\"></arg>\n"
|
" <arg nr=\"3\" direction=\"inout\"></arg>\n"
|
||||||
" <arg nr=\"4\"></arg>\n"
|
" <arg nr=\"4\"></arg>\n"
|
||||||
"</function>\n"
|
"</function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -328,22 +328,22 @@ 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"
|
||||||
" <arg nr=\"2\"><valid>-7:0</valid></arg>\n"
|
" <arg nr=\"2\"><valid>-7:0</valid></arg>\n"
|
||||||
" <arg nr=\"3\"><valid>1:5,8</valid></arg>\n"
|
" <arg nr=\"3\"><valid>1:5,8</valid></arg>\n"
|
||||||
" <arg nr=\"4\"><valid>-1,5</valid></arg>\n"
|
" <arg nr=\"4\"><valid>-1,5</valid></arg>\n"
|
||||||
" <arg nr=\"5\"><valid>:1,5</valid></arg>\n"
|
" <arg nr=\"5\"><valid>:1,5</valid></arg>\n"
|
||||||
" <arg nr=\"6\"><valid>1.5:</valid></arg>\n"
|
" <arg nr=\"6\"><valid>1.5:</valid></arg>\n"
|
||||||
" <arg nr=\"7\"><valid>-6.7:-5.5,-3.3:-2.7</valid></arg>\n"
|
" <arg nr=\"7\"><valid>-6.7:-5.5,-3.3:-2.7</valid></arg>\n"
|
||||||
" <arg nr=\"8\"><valid>0.0:</valid></arg>\n"
|
" <arg nr=\"8\"><valid>0.0:</valid></arg>\n"
|
||||||
" <arg nr=\"9\"><valid>:2.0</valid></arg>\n"
|
" <arg nr=\"9\"><valid>:2.0</valid></arg>\n"
|
||||||
" <arg nr=\"10\"><valid>0.0</valid></arg>\n"
|
" <arg nr=\"10\"><valid>0.0</valid></arg>\n"
|
||||||
" <arg nr=\"11\"><valid>!0.0</valid></arg>\n"
|
" <arg nr=\"11\"><valid>!0.0</valid></arg>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -476,16 +476,16 @@ 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"
|
||||||
" <arg nr=\"2\"><minsize type=\"argvalue\" arg=\"3\"/></arg>\n"
|
" <arg nr=\"2\"><minsize type=\"argvalue\" arg=\"3\"/></arg>\n"
|
||||||
" <arg nr=\"3\"/>\n"
|
" <arg nr=\"3\"/>\n"
|
||||||
" <arg nr=\"4\"><minsize type=\"value\" value=\"500\"/></arg>\n"
|
" <arg nr=\"4\"><minsize type=\"value\" value=\"500\"/></arg>\n"
|
||||||
" <arg nr=\"5\"><minsize type=\"value\" value=\"4\" baseType=\"int\"/></arg>\n"
|
" <arg nr=\"5\"><minsize type=\"value\" value=\"4\" baseType=\"int\"/></arg>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -539,12 +539,12 @@ 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"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -568,12 +568,12 @@ 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"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -595,12 +595,12 @@ 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"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -621,15 +621,15 @@ 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"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
" <function name=\"b\">\n"
|
" <function name=\"b\">\n"
|
||||||
" <warn severity=\"performance\" cppstd=\"c++11\" reason=\"Obsolescent\" alternatives=\"c,d,e\"/>\n"
|
" <warn severity=\"performance\" cppstd=\"c++11\" reason=\"Obsolescent\" alternatives=\"c,d,e\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -657,13 +657,13 @@ 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"
|
||||||
" <dealloc>DeleteX</dealloc>\n"
|
" <dealloc>DeleteX</dealloc>\n"
|
||||||
" </memory>\n"
|
" </memory>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -677,20 +677,20 @@ 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"
|
||||||
" <dealloc>free</dealloc>\n"
|
" <dealloc>free</dealloc>\n"
|
||||||
" </memory>\n"
|
" </memory>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT_EQUALS(true, loadxmldata(library, xmldata1, sizeof(xmldata1)));
|
ASSERT_EQUALS(true, loadxmldata(library, xmldata1, sizeof(xmldata1)));
|
||||||
|
@ -700,13 +700,13 @@ 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"
|
||||||
" <dealloc arg=\"2\">DeleteX</dealloc>\n"
|
" <dealloc arg=\"2\">DeleteX</dealloc>\n"
|
||||||
" </memory>\n"
|
" </memory>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -719,13 +719,13 @@ 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"
|
||||||
" <dealloc>DeleteX</dealloc>\n"
|
" <dealloc>DeleteX</dealloc>\n"
|
||||||
" </resource>\n"
|
" </resource>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -737,13 +737,13 @@ 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"
|
||||||
" <podtype name=\"u16\" sign=\"u\" size=\"2\"/>\n"
|
" <podtype name=\"u16\" sign=\"u\" size=\"2\"/>\n"
|
||||||
" <podtype name=\"s16\" sign=\"s\" size=\"2\"/>\n"
|
" <podtype name=\"s16\" sign=\"s\" size=\"2\"/>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
// s8
|
// s8
|
||||||
|
@ -791,37 +791,37 @@ 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"
|
||||||
" <size templateParameter=\"4\">\n"
|
" <size templateParameter=\"4\">\n"
|
||||||
" <function name=\"resize\" action=\"resize\"/>\n"
|
" <function name=\"resize\" action=\"resize\"/>\n"
|
||||||
" <function name=\"clear\" action=\"clear\"/>\n"
|
" <function name=\"clear\" action=\"clear\"/>\n"
|
||||||
" <function name=\"size\" yields=\"size\"/>\n"
|
" <function name=\"size\" yields=\"size\"/>\n"
|
||||||
" <function name=\"empty\" yields=\"empty\"/>\n"
|
" <function name=\"empty\" yields=\"empty\"/>\n"
|
||||||
" <function name=\"push_back\" action=\"push\"/>\n"
|
" <function name=\"push_back\" action=\"push\"/>\n"
|
||||||
" <function name=\"pop_back\" action=\"pop\"/>\n"
|
" <function name=\"pop_back\" action=\"pop\"/>\n"
|
||||||
" </size>\n"
|
" </size>\n"
|
||||||
" <access>\n"
|
" <access>\n"
|
||||||
" <function name=\"at\" yields=\"at_index\"/>\n"
|
" <function name=\"at\" yields=\"at_index\"/>\n"
|
||||||
" <function name=\"begin\" yields=\"start-iterator\"/>\n"
|
" <function name=\"begin\" yields=\"start-iterator\"/>\n"
|
||||||
" <function name=\"end\" yields=\"end-iterator\"/>\n"
|
" <function name=\"end\" yields=\"end-iterator\"/>\n"
|
||||||
" <function name=\"data\" yields=\"buffer\"/>\n"
|
" <function name=\"data\" yields=\"buffer\"/>\n"
|
||||||
" <function name=\"c_str\" yields=\"buffer-nt\"/>\n"
|
" <function name=\"c_str\" yields=\"buffer-nt\"/>\n"
|
||||||
" <function name=\"front\" yields=\"item\"/>\n"
|
" <function name=\"front\" yields=\"item\"/>\n"
|
||||||
" <function name=\"find\" action=\"find\"/>\n"
|
" <function name=\"find\" action=\"find\"/>\n"
|
||||||
" <function name=\"cfind\" action=\"find-const\"/>\n"
|
" <function name=\"cfind\" action=\"find-const\"/>\n"
|
||||||
" </access>\n"
|
" </access>\n"
|
||||||
" </container>\n"
|
" </container>\n"
|
||||||
" <container id=\"B\" startPattern=\"std :: B <\" inherits=\"A\" opLessAllowed=\"false\">\n"
|
" <container id=\"B\" startPattern=\"std :: B <\" inherits=\"A\" opLessAllowed=\"false\">\n"
|
||||||
" <size templateParameter=\"3\"/>\n" // Inherits all but templateParameter
|
" <size templateParameter=\"3\"/>\n" // Inherits all but templateParameter
|
||||||
" </container>\n"
|
" </container>\n"
|
||||||
" <container id=\"C\">\n"
|
" <container id=\"C\">\n"
|
||||||
" <type string=\"std-like\"/>\n"
|
" <type string=\"std-like\"/>\n"
|
||||||
" <access indexOperator=\"array-like\"/>\n"
|
" <access indexOperator=\"array-like\"/>\n"
|
||||||
" </container>\n"
|
" </container>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
|
|
||||||
Library library;
|
Library library;
|
||||||
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
|
||||||
|
@ -936,23 +936,23 @@ 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;
|
||||||
const Library::Error err = readLibrary(library, xmldata);
|
const Library::Error err = readLibrary(library, xmldata);
|
||||||
ASSERT_EQUALS(true, err.errorcode == Library::ErrorCode::UNSUPPORTED_FORMAT);
|
ASSERT_EQUALS(true, err.errorcode == Library::ErrorCode::UNSUPPORTED_FORMAT);
|
||||||
|
|
|
@ -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,13 +4702,13 @@ 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"
|
||||||
" <arg nr=\"1\"/>\n"
|
" <arg nr=\"1\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
|
@ -6391,14 +6391,14 @@ 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"
|
||||||
" <arg nr=\"1\"/>\n"
|
" <arg nr=\"1\"/>\n"
|
||||||
" <arg nr=\"2\"/>\n"
|
" <arg nr=\"2\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
Settings settings = settingsBuilder().libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\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,24 +189,24 @@ 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"
|
||||||
" <sizeof>\n"
|
" <sizeof>\n"
|
||||||
" <bool>1</bool>\n"
|
" <bool>1</bool>\n"
|
||||||
" <short>2</short>\n"
|
" <short>2</short>\n"
|
||||||
" <int>2</int>\n"
|
" <int>2</int>\n"
|
||||||
" <long>4</long>\n"
|
" <long>4</long>\n"
|
||||||
" <long-long>8</long-long>\n"
|
" <long-long>8</long-long>\n"
|
||||||
" <float>4</float>\n"
|
" <float>4</float>\n"
|
||||||
" <double>4</double>\n"
|
" <double>4</double>\n"
|
||||||
" <long-double>4</long-double>\n"
|
" <long-double>4</long-double>\n"
|
||||||
" <pointer>2</pointer>\n"
|
" <pointer>2</pointer>\n"
|
||||||
" <size_t>2</size_t>\n"
|
" <size_t>2</size_t>\n"
|
||||||
" <wchar_t>2</wchar_t>\n"
|
" <wchar_t>2</wchar_t>\n"
|
||||||
" </sizeof>\n"
|
" </sizeof>\n"
|
||||||
" </platform>";
|
" </platform>";
|
||||||
Platform platform;
|
Platform platform;
|
||||||
ASSERT(readPlatform(platform, xmldata));
|
ASSERT(readPlatform(platform, xmldata));
|
||||||
ASSERT_EQUALS(Platform::Type::File, platform.type);
|
ASSERT_EQUALS(Platform::Type::File, platform.type);
|
||||||
|
@ -233,24 +233,24 @@ 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"
|
||||||
" <sizeof>\n"
|
" <sizeof>\n"
|
||||||
" <bool>1</bool>\n"
|
" <bool>1</bool>\n"
|
||||||
" <short>2</short>\n"
|
" <short>2</short>\n"
|
||||||
" <int>3</int>\n"
|
" <int>3</int>\n"
|
||||||
" <long>4</long>\n"
|
" <long>4</long>\n"
|
||||||
" <long-long>5</long-long>\n"
|
" <long-long>5</long-long>\n"
|
||||||
" <float>6</float>\n"
|
" <float>6</float>\n"
|
||||||
" <double>7</double>\n"
|
" <double>7</double>\n"
|
||||||
" <long-double>8</long-double>\n"
|
" <long-double>8</long-double>\n"
|
||||||
" <pointer>9</pointer>\n"
|
" <pointer>9</pointer>\n"
|
||||||
" <size_t>10</size_t>\n"
|
" <size_t>10</size_t>\n"
|
||||||
" <wchar_t>11</wchar_t>\n"
|
" <wchar_t>11</wchar_t>\n"
|
||||||
" </sizeof>\n"
|
" </sizeof>\n"
|
||||||
" </platform>";
|
" </platform>";
|
||||||
Platform platform;
|
Platform platform;
|
||||||
ASSERT(readPlatform(platform, xmldata));
|
ASSERT(readPlatform(platform, xmldata));
|
||||||
ASSERT_EQUALS(Platform::Type::File, platform.type);
|
ASSERT_EQUALS(Platform::Type::File, platform.type);
|
||||||
|
@ -277,24 +277,24 @@ 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"
|
||||||
" <sizeof1>\n"
|
" <sizeof1>\n"
|
||||||
" <bool1>1</bool1>\n"
|
" <bool1>1</bool1>\n"
|
||||||
" <short1>2</short1>\n"
|
" <short1>2</short1>\n"
|
||||||
" <int1>3</int1>\n"
|
" <int1>3</int1>\n"
|
||||||
" <long1>4</long1>\n"
|
" <long1>4</long1>\n"
|
||||||
" <long-long1>5</long-long1>\n"
|
" <long-long1>5</long-long1>\n"
|
||||||
" <float1>6</float1>\n"
|
" <float1>6</float1>\n"
|
||||||
" <double1>7</double1>\n"
|
" <double1>7</double1>\n"
|
||||||
" <long-double1>8</long-double1>\n"
|
" <long-double1>8</long-double1>\n"
|
||||||
" <pointer1>9</pointer1>\n"
|
" <pointer1>9</pointer1>\n"
|
||||||
" <size_t1>10</size_t1>\n"
|
" <size_t1>10</size_t1>\n"
|
||||||
" <wchar_t1>11</wchar_t1>\n"
|
" <wchar_t1>11</wchar_t1>\n"
|
||||||
" </sizeof1>\n"
|
" </sizeof1>\n"
|
||||||
" </platform>";
|
" </platform>";
|
||||||
Platform platform;
|
Platform platform;
|
||||||
// TODO: needs to fail - files need to be complete
|
// TODO: needs to fail - files need to be complete
|
||||||
TODO_ASSERT(!readPlatform(platform, xmldata));
|
TODO_ASSERT(!readPlatform(platform, xmldata));
|
||||||
|
@ -303,24 +303,24 @@ 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"
|
||||||
" <sizeof>\n"
|
" <sizeof>\n"
|
||||||
" <bool>0</bool>\n"
|
" <bool>0</bool>\n"
|
||||||
" <short>0</short>\n"
|
" <short>0</short>\n"
|
||||||
" <int>0</int>\n"
|
" <int>0</int>\n"
|
||||||
" <long>0</long>\n"
|
" <long>0</long>\n"
|
||||||
" <long-long>0</long-long>\n"
|
" <long-long>0</long-long>\n"
|
||||||
" <float>0</float>\n"
|
" <float>0</float>\n"
|
||||||
" <double>0</double>\n"
|
" <double>0</double>\n"
|
||||||
" <long-double>0</long-double>\n"
|
" <long-double>0</long-double>\n"
|
||||||
" <pointer>0</pointer>\n"
|
" <pointer>0</pointer>\n"
|
||||||
" <size_t>0</size_t>\n"
|
" <size_t>0</size_t>\n"
|
||||||
" <wchar_t>0</wchar_t>\n"
|
" <wchar_t>0</wchar_t>\n"
|
||||||
" </sizeof>\n"
|
" </sizeof>\n"
|
||||||
" </platform>";
|
" </platform>";
|
||||||
Platform platform;
|
Platform platform;
|
||||||
ASSERT(readPlatform(platform, xmldata));
|
ASSERT(readPlatform(platform, xmldata));
|
||||||
ASSERT_EQUALS(Platform::Type::File, platform.type);
|
ASSERT_EQUALS(Platform::Type::File, platform.type);
|
||||||
|
@ -346,24 +346,24 @@ 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"
|
||||||
" <sizeof>\n"
|
" <sizeof>\n"
|
||||||
" <boolt>1</bool>\n"
|
" <boolt>1</bool>\n"
|
||||||
" <short>2</short>\n"
|
" <short>2</short>\n"
|
||||||
" <int>2</int>\n"
|
" <int>2</int>\n"
|
||||||
" <long>4</long>\n"
|
" <long>4</long>\n"
|
||||||
" <long-long>8</long-long>\n"
|
" <long-long>8</long-long>\n"
|
||||||
" <float>4</float>\n"
|
" <float>4</float>\n"
|
||||||
" <double>4</double>\n"
|
" <double>4</double>\n"
|
||||||
" <long-double>4</long-double>\n"
|
" <long-double>4</long-double>\n"
|
||||||
" <pointer>2</pointer>\n"
|
" <pointer>2</pointer>\n"
|
||||||
" <size_t>2</size_t>\n"
|
" <size_t>2</size_t>\n"
|
||||||
" <wchar_t>2</wchar_t>\n"
|
" <wchar_t>2</wchar_t>\n"
|
||||||
" </sizeof>\n"
|
" </sizeof>\n"
|
||||||
" </platform>";
|
" </platform>";
|
||||||
Platform platform;
|
Platform platform;
|
||||||
ASSERT(!readPlatform(platform, xmldata));
|
ASSERT(!readPlatform(platform, xmldata));
|
||||||
}
|
}
|
||||||
|
@ -371,24 +371,24 @@ 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"
|
||||||
" <sizeof>\n"
|
" <sizeof>\n"
|
||||||
" <bool></bool>\n"
|
" <bool></bool>\n"
|
||||||
" <short></short>\n"
|
" <short></short>\n"
|
||||||
" <int></int>\n"
|
" <int></int>\n"
|
||||||
" <long></long>\n"
|
" <long></long>\n"
|
||||||
" <long-long></long-long>\n"
|
" <long-long></long-long>\n"
|
||||||
" <float></float>\n"
|
" <float></float>\n"
|
||||||
" <double></double>\n"
|
" <double></double>\n"
|
||||||
" <long-double></long-double>\n"
|
" <long-double></long-double>\n"
|
||||||
" <pointer></pointer>\n"
|
" <pointer></pointer>\n"
|
||||||
" <size_t></size_t>\n"
|
" <size_t></size_t>\n"
|
||||||
" <wchar_t></wchar_t>\n"
|
" <wchar_t></wchar_t>\n"
|
||||||
" </sizeof>\n"
|
" </sizeof>\n"
|
||||||
" </platform>";
|
" </platform>";
|
||||||
Platform platform;
|
Platform platform;
|
||||||
ASSERT(!readPlatform(platform, xmldata));
|
ASSERT(!readPlatform(platform, xmldata));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,10 +833,10 @@ 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>";
|
||||||
const Settings s = settingsBuilder(settings).libraryxml(xmldata, sizeof(xmldata)).build();
|
const Settings s = settingsBuilder(settings).libraryxml(xmldata, sizeof(xmldata)).build();
|
||||||
checkUninitVar("void f() {\n"
|
checkUninitVar("void f() {\n"
|
||||||
" Fred _tm;\n"
|
" Fred _tm;\n"
|
||||||
|
@ -4470,15 +4470,15 @@ 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"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
" <function name=\"uninitvar_funcArgOutTest\">\n"
|
" <function name=\"uninitvar_funcArgOutTest\">\n"
|
||||||
" <arg nr=\"1\" direction=\"out\"/>\n"
|
" <arg nr=\"1\" direction=\"out\"/>\n"
|
||||||
" </function>\n"
|
" </function>\n"
|
||||||
"</def>";
|
"</def>";
|
||||||
const Settings s = settingsBuilder(settings).libraryxml(argDirectionsTestXmlData, sizeof(argDirectionsTestXmlData)).build();
|
const Settings s = settingsBuilder(settings).libraryxml(argDirectionsTestXmlData, sizeof(argDirectionsTestXmlData)).build();
|
||||||
|
|
||||||
checkUninitVar("struct AB { int a; };\n"
|
checkUninitVar("struct AB { int a; };\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,11 +46,11 @@ 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
|
||||||
"</def>";
|
"</def>";
|
||||||
settings = settingsBuilder(settings).libraryxml(cfg, sizeof(cfg)).build();
|
settings = settingsBuilder(settings).libraryxml(cfg, sizeof(cfg)).build();
|
||||||
|
|
||||||
TEST_CASE(valueFlowNumber);
|
TEST_CASE(valueFlowNumber);
|
||||||
|
|
|
@ -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