2013-07-02 07:18:19 +02:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2021-03-21 20:58:32 +01:00
|
|
|
* Copyright (C) 2007-2021 Cppcheck team.
|
2013-07-02 07:18:19 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-09-04 20:59:49 +02:00
|
|
|
//---------------------------------------------------------------------------
|
2013-07-08 18:26:18 +02:00
|
|
|
#ifndef libraryH
|
|
|
|
#define libraryH
|
2013-09-04 20:59:49 +02:00
|
|
|
//---------------------------------------------------------------------------
|
2013-07-02 07:18:19 +02:00
|
|
|
|
2013-07-04 13:09:34 +02:00
|
|
|
#include "config.h"
|
2013-12-23 10:06:45 +01:00
|
|
|
#include "mathlib.h"
|
2020-05-23 07:16:49 +02:00
|
|
|
#include "errortypes.h"
|
2015-11-21 20:24:30 +01:00
|
|
|
#include "standards.h"
|
2013-10-27 17:10:43 +01:00
|
|
|
|
2017-05-27 04:33:47 +02:00
|
|
|
#include <cstddef>
|
2013-07-02 07:18:19 +02:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
2021-01-16 13:52:09 +01:00
|
|
|
#include <unordered_map>
|
2017-05-27 04:33:47 +02:00
|
|
|
#include <utility>
|
2015-11-29 10:49:10 +01:00
|
|
|
#include <vector>
|
2013-10-20 14:09:10 +02:00
|
|
|
|
2017-05-27 04:33:47 +02:00
|
|
|
class Token;
|
|
|
|
|
2013-12-31 12:30:17 +01:00
|
|
|
namespace tinyxml2 {
|
|
|
|
class XMLDocument;
|
2015-08-09 21:27:57 +02:00
|
|
|
class XMLElement;
|
2013-12-31 12:30:17 +01:00
|
|
|
}
|
2013-12-23 10:06:45 +01:00
|
|
|
|
2013-07-02 07:18:19 +02:00
|
|
|
/// @addtogroup Core
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/**
|
2013-07-08 18:26:18 +02:00
|
|
|
* @brief Library definitions handling
|
2013-07-02 07:18:19 +02:00
|
|
|
*/
|
2013-07-08 18:26:18 +02:00
|
|
|
class CPPCHECKLIB Library {
|
2016-07-31 19:47:34 +02:00
|
|
|
friend class TestSymbolDatabase; // For testing only
|
|
|
|
|
2013-07-02 07:18:19 +02:00
|
|
|
public:
|
2013-07-08 18:26:18 +02:00
|
|
|
Library();
|
2013-07-02 07:18:19 +02:00
|
|
|
|
2021-01-08 10:29:01 +01:00
|
|
|
enum class ErrorCode { OK, FILE_NOT_FOUND, BAD_XML, UNKNOWN_ELEMENT, MISSING_ATTRIBUTE, BAD_ATTRIBUTE_VALUE, UNSUPPORTED_FORMAT, DUPLICATE_PLATFORM_TYPE, PLATFORM_TYPE_REDEFINED };
|
2014-05-26 17:00:41 +02:00
|
|
|
|
|
|
|
class Error {
|
|
|
|
public:
|
2021-01-08 10:29:01 +01:00
|
|
|
Error() : errorcode(ErrorCode::OK) {}
|
2016-12-06 12:31:16 +01:00
|
|
|
explicit Error(ErrorCode e) : errorcode(e) {}
|
|
|
|
template<typename T>
|
|
|
|
Error(ErrorCode e, T&& r) : errorcode(e), reason(r) {}
|
2021-08-07 20:51:18 +02:00
|
|
|
ErrorCode errorcode;
|
|
|
|
std::string reason;
|
2014-05-26 17:00:41 +02:00
|
|
|
};
|
|
|
|
|
2021-08-07 20:51:18 +02:00
|
|
|
Error load(const char exename[], const char path[]);
|
2014-05-26 17:00:41 +02:00
|
|
|
Error load(const tinyxml2::XMLDocument &doc);
|
|
|
|
|
2022-01-03 12:40:20 +01:00
|
|
|
/** this is used for unit tests */
|
2014-01-09 21:58:56 +01:00
|
|
|
bool loadxmldata(const char xmldata[], std::size_t len);
|
2013-07-02 07:18:19 +02:00
|
|
|
|
2016-05-22 17:18:50 +02:00
|
|
|
struct AllocFunc {
|
|
|
|
int groupId;
|
|
|
|
int arg;
|
2019-03-20 06:46:55 +01:00
|
|
|
enum class BufferSize {none,malloc,calloc,strdup};
|
|
|
|
BufferSize bufferSize;
|
2019-03-20 19:26:57 +01:00
|
|
|
int bufferSizeArg1;
|
|
|
|
int bufferSizeArg2;
|
2019-07-05 12:44:52 +02:00
|
|
|
int reallocArg;
|
2020-06-28 21:00:50 +02:00
|
|
|
bool initData;
|
2016-05-22 17:18:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/** get allocation info for function */
|
2019-07-05 12:44:52 +02:00
|
|
|
const AllocFunc* getAllocFuncInfo(const Token *tok) const;
|
2016-05-22 17:18:50 +02:00
|
|
|
|
|
|
|
/** get deallocation info for function */
|
2019-07-05 12:44:52 +02:00
|
|
|
const AllocFunc* getDeallocFuncInfo(const Token *tok) const;
|
|
|
|
|
|
|
|
/** get reallocation info for function */
|
|
|
|
const AllocFunc* getReallocFuncInfo(const Token *tok) const;
|
2013-07-02 07:18:19 +02:00
|
|
|
|
2014-04-20 14:59:16 +02:00
|
|
|
/** get allocation id for function */
|
2019-07-05 12:44:52 +02:00
|
|
|
int getAllocId(const Token *tok, int arg) const;
|
2014-04-20 14:59:16 +02:00
|
|
|
|
|
|
|
/** get deallocation id for function */
|
2019-07-05 12:44:52 +02:00
|
|
|
int getDeallocId(const Token *tok, int arg) const;
|
|
|
|
|
|
|
|
/** get reallocation id for function */
|
|
|
|
int getReallocId(const Token *tok, int arg) const;
|
2016-05-22 17:18:50 +02:00
|
|
|
|
|
|
|
/** get allocation info for function by name (deprecated, use other alloc) */
|
2019-07-05 12:44:52 +02:00
|
|
|
const AllocFunc* getAllocFuncInfo(const char name[]) const {
|
2018-06-17 16:32:08 +02:00
|
|
|
return getAllocDealloc(mAlloc, name);
|
2016-05-22 17:18:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** get deallocation info for function by name (deprecated, use other alloc) */
|
2019-07-05 12:44:52 +02:00
|
|
|
const AllocFunc* getDeallocFuncInfo(const char name[]) const {
|
2018-06-17 16:39:10 +02:00
|
|
|
return getAllocDealloc(mDealloc, name);
|
2016-05-22 17:18:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** get allocation id for function by name (deprecated, use other alloc) */
|
|
|
|
int allocId(const char name[]) const {
|
2018-06-17 16:32:08 +02:00
|
|
|
const AllocFunc* af = getAllocDealloc(mAlloc, name);
|
2016-05-22 17:18:50 +02:00
|
|
|
return af ? af->groupId : 0;
|
|
|
|
}
|
2014-04-20 14:59:16 +02:00
|
|
|
|
2015-08-10 18:36:09 +02:00
|
|
|
/** get deallocation id for function by name (deprecated, use other alloc) */
|
2016-05-22 17:18:50 +02:00
|
|
|
int deallocId(const char name[]) const {
|
2018-06-17 16:39:10 +02:00
|
|
|
const AllocFunc* af = getAllocDealloc(mDealloc, name);
|
2016-05-22 17:18:50 +02:00
|
|
|
return af ? af->groupId : 0;
|
2013-07-02 07:18:19 +02:00
|
|
|
}
|
|
|
|
|
2013-07-20 17:12:56 +02:00
|
|
|
/** set allocation id for function */
|
2016-05-22 17:18:50 +02:00
|
|
|
void setalloc(const std::string &functionname, int id, int arg) {
|
2018-06-17 16:32:08 +02:00
|
|
|
mAlloc[functionname].groupId = id;
|
|
|
|
mAlloc[functionname].arg = arg;
|
2013-07-20 17:12:56 +02:00
|
|
|
}
|
|
|
|
|
2016-05-22 17:18:50 +02:00
|
|
|
void setdealloc(const std::string &functionname, int id, int arg) {
|
2018-06-17 16:39:10 +02:00
|
|
|
mDealloc[functionname].groupId = id;
|
|
|
|
mDealloc[functionname].arg = arg;
|
2013-07-20 17:12:56 +02:00
|
|
|
}
|
|
|
|
|
2019-07-05 12:44:52 +02:00
|
|
|
void setrealloc(const std::string &functionname, int id, int arg, int reallocArg = 1) {
|
|
|
|
mRealloc[functionname].groupId = id;
|
|
|
|
mRealloc[functionname].arg = arg;
|
|
|
|
mRealloc[functionname].reallocArg = reallocArg;
|
|
|
|
}
|
|
|
|
|
2013-08-06 11:11:59 +02:00
|
|
|
/** add noreturn function setting */
|
2014-11-20 14:20:09 +01:00
|
|
|
void setnoreturn(const std::string& funcname, bool noreturn) {
|
2020-12-28 19:59:51 +01:00
|
|
|
mNoReturn[funcname] = noreturn ? FalseTrueMaybe::True : FalseTrueMaybe::False;
|
2013-08-06 11:11:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 16:06:43 +02:00
|
|
|
static bool isCompliantValidationExpression(const char* p);
|
|
|
|
|
2013-07-02 07:18:19 +02:00
|
|
|
/** is allocation type memory? */
|
2018-05-24 17:06:20 +02:00
|
|
|
static bool ismemory(const int id) {
|
2013-07-02 07:18:19 +02:00
|
|
|
return ((id > 0) && ((id & 1) == 0));
|
|
|
|
}
|
2018-05-24 17:06:20 +02:00
|
|
|
static bool ismemory(const AllocFunc* const func) {
|
2016-05-22 17:18:50 +02:00
|
|
|
return ((func->groupId > 0) && ((func->groupId & 1) == 0));
|
|
|
|
}
|
2013-07-02 07:18:19 +02:00
|
|
|
|
|
|
|
/** is allocation type resource? */
|
2018-05-24 17:06:20 +02:00
|
|
|
static bool isresource(const int id) {
|
2013-07-02 07:18:19 +02:00
|
|
|
return ((id > 0) && ((id & 1) == 1));
|
|
|
|
}
|
2018-05-24 17:06:20 +02:00
|
|
|
static bool isresource(const AllocFunc* const func) {
|
2016-05-22 17:18:50 +02:00
|
|
|
return ((func->groupId > 0) && ((func->groupId & 1) == 1));
|
|
|
|
}
|
2013-07-02 07:18:19 +02:00
|
|
|
|
2016-08-19 17:36:27 +02:00
|
|
|
bool formatstr_function(const Token* ftok) const;
|
|
|
|
int formatstr_argno(const Token* ftok) const;
|
|
|
|
bool formatstr_scan(const Token* ftok) const;
|
|
|
|
bool formatstr_secure(const Token* ftok) const;
|
2014-01-12 12:44:24 +01:00
|
|
|
|
2021-06-12 21:16:52 +02:00
|
|
|
struct NonOverlappingData {
|
|
|
|
int ptr1Arg;
|
|
|
|
int ptr2Arg;
|
|
|
|
int sizeArg;
|
2021-07-09 13:25:01 +02:00
|
|
|
int strlenArg;
|
2021-06-12 21:16:52 +02:00
|
|
|
};
|
|
|
|
const NonOverlappingData* getNonOverlappingData(const Token *ftok) const;
|
|
|
|
|
2015-11-21 20:24:30 +01:00
|
|
|
struct WarnInfo {
|
|
|
|
std::string message;
|
|
|
|
Standards standards;
|
|
|
|
Severity::SeverityType severity;
|
|
|
|
};
|
|
|
|
std::map<std::string, WarnInfo> functionwarn;
|
|
|
|
|
|
|
|
const WarnInfo* getWarnInfo(const Token* ftok) const;
|
|
|
|
|
2015-01-08 19:31:41 +01:00
|
|
|
// returns true if ftok is not a library function
|
2015-01-27 17:55:18 +01:00
|
|
|
bool isNotLibraryFunction(const Token *ftok) const;
|
2016-09-04 14:14:21 +02:00
|
|
|
bool matchArguments(const Token *ftok, const std::string &functionName) const;
|
2015-08-15 12:19:14 +02:00
|
|
|
|
2020-11-05 13:35:52 +01:00
|
|
|
enum class UseRetValType { NONE, DEFAULT, ERROR_CODE };
|
|
|
|
UseRetValType getUseRetValType(const Token* ftok) const;
|
2015-08-15 12:19:14 +02:00
|
|
|
|
2016-12-05 17:30:06 +01:00
|
|
|
const std::string& returnValue(const Token *ftok) const;
|
|
|
|
const std::string& returnValueType(const Token *ftok) const;
|
2016-11-01 14:08:42 +01:00
|
|
|
int returnValueContainer(const Token *ftok) const;
|
2019-07-11 16:05:34 +02:00
|
|
|
std::vector<MathLib::bigint> unknownReturnValues(const Token *ftok) const;
|
2016-10-17 13:05:19 +02:00
|
|
|
|
2015-03-11 20:52:54 +01:00
|
|
|
bool isnoreturn(const Token *ftok) const;
|
|
|
|
bool isnotnoreturn(const Token *ftok) const;
|
2013-07-14 10:10:11 +02:00
|
|
|
|
2014-06-22 19:13:15 +02:00
|
|
|
bool isScopeNoReturn(const Token *end, std::string *unknownFunc) const;
|
|
|
|
|
2015-01-03 20:35:33 +01:00
|
|
|
class Container {
|
|
|
|
public:
|
2021-10-05 08:28:19 +02:00
|
|
|
Container()
|
|
|
|
: type_templateArgNo(-1),
|
2015-01-03 20:35:33 +01:00
|
|
|
size_templateArgNo(-1),
|
|
|
|
arrayLike_indexOp(false),
|
2015-11-20 12:46:59 +01:00
|
|
|
stdStringLike(false),
|
2019-05-02 11:04:23 +02:00
|
|
|
stdAssociativeLike(false),
|
2019-11-17 03:22:04 +01:00
|
|
|
opLessAllowed(true),
|
2020-04-03 13:16:57 +02:00
|
|
|
hasInitializerListConstructor(false),
|
|
|
|
unstableErase(false),
|
2021-10-05 08:28:19 +02:00
|
|
|
unstableInsert(false),
|
|
|
|
view(false)
|
|
|
|
{}
|
2015-01-03 20:35:33 +01:00
|
|
|
|
2019-07-17 11:39:30 +02:00
|
|
|
enum class Action {
|
2021-10-05 08:28:19 +02:00
|
|
|
RESIZE,
|
|
|
|
CLEAR,
|
|
|
|
PUSH,
|
|
|
|
POP,
|
|
|
|
FIND,
|
|
|
|
INSERT,
|
|
|
|
ERASE,
|
|
|
|
CHANGE_CONTENT,
|
|
|
|
CHANGE,
|
|
|
|
CHANGE_INTERNAL,
|
2015-01-03 20:35:33 +01:00
|
|
|
NO_ACTION
|
|
|
|
};
|
2019-07-17 11:39:30 +02:00
|
|
|
enum class Yield {
|
2021-10-05 08:28:19 +02:00
|
|
|
AT_INDEX,
|
|
|
|
ITEM,
|
|
|
|
BUFFER,
|
|
|
|
BUFFER_NT,
|
|
|
|
START_ITERATOR,
|
|
|
|
END_ITERATOR,
|
|
|
|
ITERATOR,
|
|
|
|
SIZE,
|
|
|
|
EMPTY,
|
2015-01-03 20:35:33 +01:00
|
|
|
NO_YIELD
|
|
|
|
};
|
|
|
|
struct Function {
|
|
|
|
Action action;
|
|
|
|
Yield yield;
|
|
|
|
};
|
2021-12-11 15:16:54 +01:00
|
|
|
struct RangeItemRecordTypeItem {
|
|
|
|
std::string name;
|
|
|
|
int templateParameter;
|
|
|
|
};
|
2019-04-06 06:42:01 +02:00
|
|
|
std::string startPattern, startPattern2, endPattern, itEndPattern;
|
2015-01-03 20:35:33 +01:00
|
|
|
std::map<std::string, Function> functions;
|
|
|
|
int type_templateArgNo;
|
2021-12-11 15:16:54 +01:00
|
|
|
std::vector<RangeItemRecordTypeItem> rangeItemRecordType;
|
2015-01-03 20:35:33 +01:00
|
|
|
int size_templateArgNo;
|
|
|
|
bool arrayLike_indexOp;
|
|
|
|
bool stdStringLike;
|
2019-05-02 11:04:23 +02:00
|
|
|
bool stdAssociativeLike;
|
2015-11-20 12:46:59 +01:00
|
|
|
bool opLessAllowed;
|
2019-11-17 03:22:04 +01:00
|
|
|
bool hasInitializerListConstructor;
|
2020-04-03 13:16:57 +02:00
|
|
|
bool unstableErase;
|
|
|
|
bool unstableInsert;
|
2021-10-05 08:28:19 +02:00
|
|
|
bool view;
|
2015-01-03 20:35:33 +01:00
|
|
|
|
|
|
|
Action getAction(const std::string& function) const {
|
2018-04-04 21:51:31 +02:00
|
|
|
const std::map<std::string, Function>::const_iterator i = functions.find(function);
|
2015-01-03 20:35:33 +01:00
|
|
|
if (i != functions.end())
|
|
|
|
return i->second.action;
|
2019-07-17 11:39:30 +02:00
|
|
|
return Action::NO_ACTION;
|
2015-01-03 20:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Yield getYield(const std::string& function) const {
|
2018-04-04 21:51:31 +02:00
|
|
|
const std::map<std::string, Function>::const_iterator i = functions.find(function);
|
2015-01-03 20:35:33 +01:00
|
|
|
if (i != functions.end())
|
|
|
|
return i->second.yield;
|
2019-07-17 11:39:30 +02:00
|
|
|
return Yield::NO_YIELD;
|
2015-01-03 20:35:33 +01:00
|
|
|
}
|
2021-08-23 09:03:48 +02:00
|
|
|
|
|
|
|
static Yield yieldFrom(const std::string& yieldName);
|
|
|
|
static Action actionFrom(const std::string& actionName);
|
2015-01-03 20:35:33 +01:00
|
|
|
};
|
|
|
|
std::map<std::string, Container> containers;
|
2015-11-20 12:46:59 +01:00
|
|
|
const Container* detectContainer(const Token* typeStart, bool iterator = false) const;
|
2015-01-03 20:35:33 +01:00
|
|
|
|
2013-12-23 10:06:45 +01:00
|
|
|
class ArgumentChecks {
|
|
|
|
public:
|
2014-01-06 08:02:04 +01:00
|
|
|
ArgumentChecks() :
|
|
|
|
notbool(false),
|
|
|
|
notnull(false),
|
2019-11-13 12:46:54 +01:00
|
|
|
notuninit(-1),
|
2014-01-06 08:02:04 +01:00
|
|
|
formatstr(false),
|
2016-07-09 12:42:46 +02:00
|
|
|
strz(false),
|
2016-10-25 23:07:18 +02:00
|
|
|
optional(false),
|
2017-03-14 17:41:34 +01:00
|
|
|
variadic(false),
|
2019-03-01 15:47:08 +01:00
|
|
|
iteratorInfo(),
|
2021-08-07 20:51:18 +02:00
|
|
|
direction(Direction::DIR_UNKNOWN) {}
|
2013-07-22 20:21:45 +02:00
|
|
|
|
2021-08-07 20:51:18 +02:00
|
|
|
bool notbool;
|
|
|
|
bool notnull;
|
|
|
|
int notuninit;
|
|
|
|
bool formatstr;
|
|
|
|
bool strz;
|
|
|
|
bool optional;
|
|
|
|
bool variadic;
|
|
|
|
std::string valid;
|
2014-07-05 20:31:43 +02:00
|
|
|
|
2016-10-25 23:07:18 +02:00
|
|
|
class IteratorInfo {
|
|
|
|
public:
|
2017-03-14 17:41:34 +01:00
|
|
|
IteratorInfo() : container(0), it(false), first(false), last(false) {}
|
2016-10-25 23:07:18 +02:00
|
|
|
|
2021-08-07 20:51:18 +02:00
|
|
|
int container;
|
2017-03-14 17:41:34 +01:00
|
|
|
bool it;
|
2016-10-25 23:07:18 +02:00
|
|
|
bool first;
|
|
|
|
bool last;
|
|
|
|
};
|
|
|
|
IteratorInfo iteratorInfo;
|
|
|
|
|
2014-07-05 20:31:43 +02:00
|
|
|
class MinSize {
|
|
|
|
public:
|
2021-01-08 10:29:01 +01:00
|
|
|
enum class Type { NONE, STRLEN, ARGVALUE, SIZEOF, MUL, VALUE };
|
2019-03-17 14:22:26 +01:00
|
|
|
MinSize(Type t, int a) : type(t), arg(a), arg2(0), value(0) {}
|
2014-07-05 20:31:43 +02:00
|
|
|
Type type;
|
|
|
|
int arg;
|
|
|
|
int arg2;
|
2019-03-17 14:22:26 +01:00
|
|
|
long long value;
|
2014-07-05 20:31:43 +02:00
|
|
|
};
|
2017-03-27 17:33:26 +02:00
|
|
|
std::vector<MinSize> minsizes;
|
2019-03-01 15:47:08 +01:00
|
|
|
|
2019-08-01 20:56:02 +02:00
|
|
|
enum class Direction {
|
2019-03-04 22:57:40 +01:00
|
|
|
DIR_IN, ///< Input to called function. Data is treated as read-only.
|
|
|
|
DIR_OUT, ///< Output to caller. Data is passed by reference or address and is potentially written.
|
|
|
|
DIR_INOUT, ///< Input to called function, and output to caller. Data is passed by reference or address and is potentially modified.
|
|
|
|
DIR_UNKNOWN ///< direction not known / specified
|
|
|
|
};
|
2019-03-01 15:47:08 +01:00
|
|
|
Direction direction;
|
2013-07-14 10:10:11 +02:00
|
|
|
};
|
|
|
|
|
2016-12-06 12:31:16 +01:00
|
|
|
struct Function {
|
|
|
|
std::map<int, ArgumentChecks> argumentChecks; // argument nr => argument data
|
|
|
|
bool use;
|
|
|
|
bool leakignore;
|
|
|
|
bool isconst;
|
|
|
|
bool ispure;
|
2020-11-05 13:35:52 +01:00
|
|
|
UseRetValType useretval;
|
2016-12-06 12:31:16 +01:00
|
|
|
bool ignore; // ignore functions/macros from a library (gtk, qt etc)
|
|
|
|
bool formatstr;
|
|
|
|
bool formatstr_scan;
|
|
|
|
bool formatstr_secure;
|
2021-08-23 09:03:48 +02:00
|
|
|
Container::Action containerAction;
|
|
|
|
Container::Yield containerYield;
|
|
|
|
Function()
|
|
|
|
: use(false),
|
|
|
|
leakignore(false),
|
|
|
|
isconst(false),
|
|
|
|
ispure(false),
|
|
|
|
useretval(UseRetValType::NONE),
|
|
|
|
ignore(false),
|
|
|
|
formatstr(false),
|
|
|
|
formatstr_scan(false),
|
|
|
|
formatstr_secure(false),
|
|
|
|
containerAction(Container::Action::NO_ACTION),
|
|
|
|
containerYield(Container::Yield::NO_YIELD)
|
|
|
|
{}
|
2016-12-06 12:31:16 +01:00
|
|
|
};
|
|
|
|
|
2020-05-23 17:50:24 +02:00
|
|
|
const Function *getFunction(const Token *ftok) const;
|
2021-01-16 13:52:09 +01:00
|
|
|
std::unordered_map<std::string, Function> functions;
|
2016-12-06 12:31:16 +01:00
|
|
|
bool isUse(const std::string& functionName) const;
|
|
|
|
bool isLeakIgnore(const std::string& functionName) const;
|
|
|
|
bool isFunctionConst(const std::string& functionName, bool pure) const;
|
2017-09-08 18:08:32 +02:00
|
|
|
bool isFunctionConst(const Token *ftok) const;
|
2013-07-02 07:18:19 +02:00
|
|
|
|
2015-01-08 19:31:41 +01:00
|
|
|
bool isboolargbad(const Token *ftok, int argnr) const {
|
|
|
|
const ArgumentChecks *arg = getarg(ftok, argnr);
|
2013-12-23 10:06:45 +01:00
|
|
|
return arg && arg->notbool;
|
|
|
|
}
|
|
|
|
|
2015-10-03 20:51:45 +02:00
|
|
|
bool isnullargbad(const Token *ftok, int argnr) const;
|
2020-06-07 20:18:54 +02:00
|
|
|
bool isuninitargbad(const Token *ftok, int argnr, int indirect = 0, bool *hasIndirect=nullptr) const;
|
2013-07-15 18:55:40 +02:00
|
|
|
|
2015-01-08 19:31:41 +01:00
|
|
|
bool isargformatstr(const Token *ftok, int argnr) const {
|
|
|
|
const ArgumentChecks *arg = getarg(ftok, argnr);
|
2013-07-22 20:21:45 +02:00
|
|
|
return arg && arg->formatstr;
|
|
|
|
}
|
|
|
|
|
2015-01-08 19:31:41 +01:00
|
|
|
bool isargstrz(const Token *ftok, int argnr) const {
|
|
|
|
const ArgumentChecks *arg = getarg(ftok, argnr);
|
2013-07-22 20:21:45 +02:00
|
|
|
return arg && arg->strz;
|
|
|
|
}
|
|
|
|
|
2018-07-15 23:05:48 +02:00
|
|
|
bool isIntArgValid(const Token *ftok, int argnr, const MathLib::bigint argvalue) const;
|
|
|
|
bool isFloatArgValid(const Token *ftok, int argnr, double argvalue) const;
|
2013-12-23 10:06:45 +01:00
|
|
|
|
2015-01-08 19:31:41 +01:00
|
|
|
const std::string& validarg(const Token *ftok, int argnr) const {
|
|
|
|
const ArgumentChecks *arg = getarg(ftok, argnr);
|
2014-06-26 11:44:19 +02:00
|
|
|
return arg ? arg->valid : emptyString;
|
2013-12-23 10:06:45 +01:00
|
|
|
}
|
|
|
|
|
2019-12-23 22:10:43 +01:00
|
|
|
struct InvalidArgValue {
|
2021-01-08 10:29:01 +01:00
|
|
|
enum class Type {le, lt, eq, ge, gt, range} type;
|
2019-12-23 22:10:43 +01:00
|
|
|
std::string op1;
|
|
|
|
std::string op2;
|
|
|
|
bool isInt() const {
|
|
|
|
return MathLib::isInt(op1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static std::vector<InvalidArgValue> getInvalidArgValues(const std::string &validExpr);
|
|
|
|
|
2016-10-25 23:07:18 +02:00
|
|
|
const ArgumentChecks::IteratorInfo *getArgIteratorInfo(const Token *ftok, int argnr) const {
|
|
|
|
const ArgumentChecks *arg = getarg(ftok, argnr);
|
|
|
|
return arg && arg->iteratorInfo.it ? &arg->iteratorInfo : nullptr;
|
|
|
|
}
|
|
|
|
|
2019-03-09 22:14:02 +01:00
|
|
|
bool hasminsize(const Token *ftok) const;
|
2014-07-05 20:31:43 +02:00
|
|
|
|
2017-03-27 17:33:26 +02:00
|
|
|
const std::vector<ArgumentChecks::MinSize> *argminsizes(const Token *ftok, int argnr) const {
|
2015-01-08 19:31:41 +01:00
|
|
|
const ArgumentChecks *arg = getarg(ftok, argnr);
|
2014-07-05 20:31:43 +02:00
|
|
|
return arg ? &arg->minsizes : nullptr;
|
|
|
|
}
|
|
|
|
|
2019-11-24 01:40:31 +01:00
|
|
|
ArgumentChecks::Direction getArgDirection(const Token* ftok, int argnr) const;
|
2019-03-01 15:47:08 +01:00
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
bool markupFile(const std::string &path) const;
|
2013-10-31 19:09:01 +01:00
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
bool processMarkupAfterCode(const std::string &path) const;
|
2014-01-02 18:18:24 +01:00
|
|
|
|
2014-11-20 14:20:09 +01:00
|
|
|
const std::set<std::string> &markupExtensions() const {
|
2018-06-17 16:39:10 +02:00
|
|
|
return mMarkupExtensions;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
bool reportErrors(const std::string &path) const;
|
2013-10-20 14:09:10 +02:00
|
|
|
|
lib: fix a bunch of warnings about differing function arguments in definition and declaration.
[lib/token.h:72] -> [lib/token.cpp:36]: (style, inconclusive) Function 'Token' argument 1 names different: declaration 'tokensBack' definition 't'.
[lib/token.h:445] -> [lib/token.cpp:497]: (style, inconclusive) Function 'multiCompare' argument 1 names different: declaration 'needle' definition 'tok'.
[lib/checkio.h:73] -> [lib/checkio.cpp:1385]: (style, inconclusive) Function 'ArgumentInfo' argument 3 names different: declaration 'isCPP' definition '_isCPP'.
[lib/checkother.h:216] -> [lib/checkother.cpp:2136]: (style, inconclusive) Function 'checkComparisonFunctionIsAlwaysTrueOrFalseError' argument 2 names different: declaration 'strFunctionName' definition 'functionName'.
[lib/errorlogger.h:214] -> [lib/errorlogger.cpp:51]: (style, inconclusive) Function 'ErrorMessage' argument 2 names different: declaration 'file0' definition 'file0_'.
[lib/errorlogger.h:215] -> [lib/errorlogger.cpp:65]: (style, inconclusive) Function 'ErrorMessage' argument 2 names different: declaration 'file0' definition 'file0_'.
[lib/library.h:327] -> [lib/library.cpp:1043]: (style, inconclusive) Function 'ignorefunction' argument 1 names different: declaration 'function' definition 'functionName'.
[lib/mathlib.h:112] -> [lib/mathlib.cpp:1275]: (style, inconclusive) Function 'isNullValue' argument 1 names different: declaration 'tok' definition 'str'.
[lib/preprocessor.h:91] -> [lib/preprocessor.cpp:122]: (style, inconclusive) Function 'setDirectives' argument 1 names different: declaration 'tokens' definition 'tokens1'.
[lib/symboldatabase.h:860] -> [lib/symboldatabase.cpp:1801]: (style, inconclusive) Function 'argsMatch' argument 1 names different: declaration 'info' definition 'scope'.
[lib/symboldatabase.h:1171] -> [lib/symboldatabase.cpp:2048]: (style, inconclusive) Function 'addClassFunction' argument 1 names different: declaration 'info' definition 'scope'.
[lib/symboldatabase.h:1174] -> [lib/symboldatabase.cpp:2208]: (style, inconclusive) Function 'addNewFunction' argument 1 names different: declaration 'info' definition 'scope'.
[lib/symboldatabase.h:1090] -> [lib/symboldatabase.cpp:3648]: (style, inconclusive) Function 'findVariableType' argument 2 names different: declaration 'type' definition 'typeTok'.
[lib/symboldatabase.h:1101] -> [lib/symboldatabase.cpp:4308]: (style, inconclusive) Function 'findType' argument 1 names different: declaration 'tok' definition 'startTok'.
[lib/symboldatabase.h:1176] -> [lib/symboldatabase.cpp:4349]: (style, inconclusive) Function 'findTypeInNested' argument 1 names different: declaration 'tok' definition 'startTok'.
[lib/symboldatabase.h:1193] -> [lib/symboldatabase.cpp:4501]: (style, inconclusive) Function 'setValueType' argument 2 names different: declaration 'enumerators' definition 'enumerator'.
[lib/path.h:159] -> [lib/path.cpp:247]: (style, inconclusive) Function 'isCPP' argument 1 names different: declaration 'extensionInLowerCase' definition 'path'.
[lib/path.h:145] -> [lib/path.cpp:266]: (style, inconclusive) Function 'acceptFile' argument 1 names different: declaration 'filename' definition 'path'.
2017-04-03 00:06:46 +02:00
|
|
|
bool ignorefunction(const std::string &functionName) const;
|
2013-10-20 14:09:10 +02:00
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
bool isexecutableblock(const std::string &file, const std::string &token) const;
|
2013-10-20 14:09:10 +02:00
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
int blockstartoffset(const std::string &file) const;
|
2013-10-20 14:09:10 +02:00
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
const std::string& blockstart(const std::string &file) const;
|
|
|
|
const std::string& blockend(const std::string &file) const;
|
2013-10-20 14:09:10 +02:00
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
bool iskeyword(const std::string &file, const std::string &keyword) const;
|
2013-10-20 14:09:10 +02:00
|
|
|
|
2014-11-20 14:20:09 +01:00
|
|
|
bool isexporter(const std::string &prefix) const {
|
2018-06-17 16:39:10 +02:00
|
|
|
return mExporters.find(prefix) != mExporters.end();
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
2014-11-20 14:20:09 +01:00
|
|
|
bool isexportedprefix(const std::string &prefix, const std::string &token) const {
|
2018-06-17 16:39:10 +02:00
|
|
|
const std::map<std::string, ExportedFunctions>::const_iterator it = mExporters.find(prefix);
|
|
|
|
return (it != mExporters.end() && it->second.isPrefix(token));
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
2014-11-20 14:20:09 +01:00
|
|
|
bool isexportedsuffix(const std::string &prefix, const std::string &token) const {
|
2018-06-17 16:39:10 +02:00
|
|
|
const std::map<std::string, ExportedFunctions>::const_iterator it = mExporters.find(prefix);
|
|
|
|
return (it != mExporters.end() && it->second.isSuffix(token));
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
2015-03-11 22:12:17 +01:00
|
|
|
bool isimporter(const std::string& file, const std::string &importer) const;
|
2013-10-20 14:09:10 +02:00
|
|
|
|
2021-08-23 09:03:48 +02:00
|
|
|
const Token* getContainerFromYield(const Token* tok, Container::Yield yield) const;
|
|
|
|
const Token* getContainerFromAction(const Token* tok, Container::Action action) const;
|
|
|
|
|
2014-11-20 14:20:09 +01:00
|
|
|
bool isreflection(const std::string &token) const {
|
2018-06-17 16:39:10 +02:00
|
|
|
return mReflection.find(token) != mReflection.end();
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
2014-11-20 14:20:09 +01:00
|
|
|
int reflectionArgument(const std::string &token) const {
|
2018-06-17 16:39:10 +02:00
|
|
|
const std::map<std::string, int>::const_iterator it = mReflection.find(token);
|
|
|
|
if (it != mReflection.end())
|
2016-12-06 14:47:45 +01:00
|
|
|
return it->second;
|
|
|
|
return -1;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
2014-02-06 09:22:07 +01:00
|
|
|
std::vector<std::string> defines; // to provide some library defines
|
2013-07-15 08:44:00 +02:00
|
|
|
|
2021-07-20 21:30:27 +02:00
|
|
|
struct SmartPointer {
|
2021-08-14 19:00:58 +02:00
|
|
|
std::string name = "";
|
2021-07-20 21:30:27 +02:00
|
|
|
bool unique = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::map<std::string, SmartPointer> smartPointers;
|
2019-04-24 13:06:58 +02:00
|
|
|
bool isSmartPointer(const Token *tok) const;
|
2021-07-20 21:30:27 +02:00
|
|
|
const SmartPointer* detectSmartPointer(const Token* tok) const;
|
2019-04-24 13:06:58 +02:00
|
|
|
|
2014-06-08 12:09:00 +02:00
|
|
|
struct PodType {
|
2021-08-07 20:51:18 +02:00
|
|
|
unsigned int size;
|
|
|
|
char sign;
|
2021-01-08 10:29:01 +01:00
|
|
|
enum class Type { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype;
|
2014-06-08 12:09:00 +02:00
|
|
|
};
|
|
|
|
const struct PodType *podtype(const std::string &name) const {
|
2021-01-16 13:52:09 +01:00
|
|
|
const std::unordered_map<std::string, struct PodType>::const_iterator it = mPodTypes.find(name);
|
2018-06-17 16:55:02 +02:00
|
|
|
return (it != mPodTypes.end()) ? &(it->second) : nullptr;
|
2014-06-08 12:09:00 +02:00
|
|
|
}
|
|
|
|
|
2014-10-19 07:34:40 +02:00
|
|
|
struct PlatformType {
|
|
|
|
PlatformType()
|
2019-11-20 15:37:09 +01:00
|
|
|
: mSigned(false)
|
|
|
|
, mUnsigned(false)
|
|
|
|
, mLong(false)
|
|
|
|
, mPointer(false)
|
|
|
|
, mPtrPtr(false)
|
2021-08-07 20:51:18 +02:00
|
|
|
, mConstPtr(false) {}
|
2014-11-20 14:20:09 +01:00
|
|
|
bool operator == (const PlatformType & type) const {
|
2019-11-20 15:37:09 +01:00
|
|
|
return (mSigned == type.mSigned &&
|
|
|
|
mUnsigned == type.mUnsigned &&
|
|
|
|
mLong == type.mLong &&
|
|
|
|
mPointer == type.mPointer &&
|
|
|
|
mPtrPtr == type.mPtrPtr &&
|
|
|
|
mConstPtr == type.mConstPtr &&
|
2018-06-16 20:25:54 +02:00
|
|
|
mType == type.mType);
|
2014-10-19 07:34:40 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
bool operator != (const PlatformType & type) const {
|
2014-10-19 07:34:40 +02:00
|
|
|
return !(*this == type);
|
|
|
|
}
|
2018-06-16 20:25:54 +02:00
|
|
|
std::string mType;
|
2019-11-20 15:37:09 +01:00
|
|
|
bool mSigned;
|
|
|
|
bool mUnsigned;
|
|
|
|
bool mLong;
|
|
|
|
bool mPointer;
|
|
|
|
bool mPtrPtr;
|
|
|
|
bool mConstPtr;
|
2014-10-19 07:34:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Platform {
|
2014-11-20 14:20:09 +01:00
|
|
|
const PlatformType *platform_type(const std::string &name) const {
|
2018-06-17 16:58:28 +02:00
|
|
|
const std::map<std::string, struct PlatformType>::const_iterator it = mPlatformTypes.find(name);
|
|
|
|
return (it != mPlatformTypes.end()) ? &(it->second) : nullptr;
|
2014-10-19 07:34:40 +02:00
|
|
|
}
|
2018-06-17 16:58:28 +02:00
|
|
|
std::map<std::string, PlatformType> mPlatformTypes;
|
2014-10-19 07:34:40 +02:00
|
|
|
};
|
|
|
|
|
2014-11-20 14:20:09 +01:00
|
|
|
const PlatformType *platform_type(const std::string &name, const std::string & platform) const {
|
2018-06-17 16:55:02 +02:00
|
|
|
const std::map<std::string, Platform>::const_iterator it = mPlatforms.find(platform);
|
|
|
|
if (it != mPlatforms.end()) {
|
2014-10-19 07:34:40 +02:00
|
|
|
const PlatformType * const type = it->second.platform_type(name);
|
|
|
|
if (type)
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2018-06-17 16:55:02 +02:00
|
|
|
const std::map<std::string, PlatformType>::const_iterator it2 = mPlatformTypes.find(name);
|
|
|
|
return (it2 != mPlatformTypes.end()) ? &(it2->second) : nullptr;
|
2014-10-19 07:34:40 +02:00
|
|
|
}
|
|
|
|
|
2017-10-05 21:50:24 +02:00
|
|
|
/**
|
|
|
|
* Get function name for function call
|
|
|
|
*/
|
|
|
|
std::string getFunctionName(const Token *ftok) const;
|
|
|
|
|
2018-03-24 07:58:37 +01:00
|
|
|
static bool isContainerYield(const Token * const cond, Library::Container::Yield y, const std::string& fallback="");
|
|
|
|
|
2019-11-17 12:08:21 +01:00
|
|
|
/** Suppress/check a type */
|
|
|
|
enum class TypeCheck { def, check, suppress };
|
|
|
|
TypeCheck getTypeCheck(const std::string &check, const std::string &typeName) const;
|
|
|
|
|
2020-12-28 19:59:51 +01:00
|
|
|
bool bugHunting;
|
|
|
|
|
2013-07-02 07:18:19 +02:00
|
|
|
private:
|
2015-08-09 21:27:57 +02:00
|
|
|
// load a <function> xml node
|
|
|
|
Error loadFunction(const tinyxml2::XMLElement * const node, const std::string &name, std::set<std::string> &unknown_elements);
|
|
|
|
|
2013-10-20 14:09:10 +02:00
|
|
|
class ExportedFunctions {
|
|
|
|
public:
|
2014-11-20 14:20:09 +01:00
|
|
|
void addPrefix(const std::string& prefix) {
|
2018-06-17 13:46:24 +02:00
|
|
|
mPrefixes.insert(prefix);
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
void addSuffix(const std::string& suffix) {
|
2018-06-17 13:47:18 +02:00
|
|
|
mSuffixes.insert(suffix);
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
bool isPrefix(const std::string& prefix) const {
|
2018-06-17 13:46:24 +02:00
|
|
|
return (mPrefixes.find(prefix) != mPrefixes.end());
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
bool isSuffix(const std::string& suffix) const {
|
2018-06-17 13:47:18 +02:00
|
|
|
return (mSuffixes.find(suffix) != mSuffixes.end());
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-06-17 13:46:24 +02:00
|
|
|
std::set<std::string> mPrefixes;
|
2018-06-17 13:47:18 +02:00
|
|
|
std::set<std::string> mSuffixes;
|
2013-10-20 14:09:10 +02:00
|
|
|
};
|
|
|
|
class CodeBlock {
|
|
|
|
public:
|
2018-06-17 13:44:56 +02:00
|
|
|
CodeBlock() : mOffset(0) {}
|
2013-10-23 15:03:31 +02:00
|
|
|
|
2016-12-06 14:47:45 +01:00
|
|
|
void setStart(const char* s) {
|
2018-06-17 13:44:10 +02:00
|
|
|
mStart = s;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2016-12-06 14:47:45 +01:00
|
|
|
void setEnd(const char* e) {
|
2018-06-17 13:44:10 +02:00
|
|
|
mEnd = e;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
void setOffset(const int o) {
|
2018-06-17 13:44:56 +02:00
|
|
|
mOffset = o;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2016-12-06 14:47:45 +01:00
|
|
|
void addBlock(const char* blockName) {
|
2018-06-17 13:45:31 +02:00
|
|
|
mBlocks.insert(blockName);
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
const std::string& start() const {
|
2018-06-17 13:44:10 +02:00
|
|
|
return mStart;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
const std::string& end() const {
|
2018-06-17 13:44:10 +02:00
|
|
|
return mEnd;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
int offset() const {
|
2018-06-17 13:44:56 +02:00
|
|
|
return mOffset;
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
2014-11-20 14:20:09 +01:00
|
|
|
bool isBlock(const std::string& blockName) const {
|
2018-06-17 13:45:31 +02:00
|
|
|
return mBlocks.find(blockName) != mBlocks.end();
|
2013-10-20 14:09:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-06-17 13:44:10 +02:00
|
|
|
std::string mStart;
|
|
|
|
std::string mEnd;
|
2018-06-17 13:44:56 +02:00
|
|
|
int mOffset;
|
2018-06-17 13:45:31 +02:00
|
|
|
std::set<std::string> mBlocks;
|
2013-10-20 14:09:10 +02:00
|
|
|
};
|
2020-12-28 19:59:51 +01:00
|
|
|
enum class FalseTrueMaybe { False, True, Maybe };
|
2018-06-17 16:55:02 +02:00
|
|
|
int mAllocId;
|
2018-06-16 16:23:55 +02:00
|
|
|
std::set<std::string> mFiles;
|
2018-06-17 16:32:08 +02:00
|
|
|
std::map<std::string, AllocFunc> mAlloc; // allocation functions
|
2018-06-17 16:39:10 +02:00
|
|
|
std::map<std::string, AllocFunc> mDealloc; // deallocation functions
|
2019-07-05 12:44:52 +02:00
|
|
|
std::map<std::string, AllocFunc> mRealloc; // reallocation functions
|
2021-01-28 22:18:17 +01:00
|
|
|
std::unordered_map<std::string, FalseTrueMaybe> mNoReturn; // is function noreturn?
|
2018-06-17 16:39:10 +02:00
|
|
|
std::map<std::string, std::string> mReturnValue;
|
|
|
|
std::map<std::string, std::string> mReturnValueType;
|
|
|
|
std::map<std::string, int> mReturnValueContainer;
|
2019-07-11 16:05:34 +02:00
|
|
|
std::map<std::string, std::vector<MathLib::bigint>> mUnknownReturnValues;
|
2018-06-17 16:39:10 +02:00
|
|
|
std::map<std::string, bool> mReportErrors;
|
|
|
|
std::map<std::string, bool> mProcessAfterCode;
|
|
|
|
std::set<std::string> mMarkupExtensions; // file extensions of markup files
|
2021-08-07 20:51:18 +02:00
|
|
|
std::map<std::string, std::set<std::string>> mKeywords; // keywords for code in the library
|
2018-06-17 16:39:10 +02:00
|
|
|
std::map<std::string, CodeBlock> mExecutableBlocks; // keywords for blocks of executable code
|
|
|
|
std::map<std::string, ExportedFunctions> mExporters; // keywords that export variables/functions to libraries (meta-code/macros)
|
2021-08-07 20:51:18 +02:00
|
|
|
std::map<std::string, std::set<std::string>> mImporters; // keywords that import variables/functions
|
2018-06-17 16:39:10 +02:00
|
|
|
std::map<std::string, int> mReflection; // invocation of reflection
|
2021-01-16 13:52:09 +01:00
|
|
|
std::unordered_map<std::string, struct PodType> mPodTypes; // pod types
|
2018-06-17 16:55:02 +02:00
|
|
|
std::map<std::string, PlatformType> mPlatformTypes; // platform independent typedefs
|
|
|
|
std::map<std::string, Platform> mPlatforms; // platform dependent typedefs
|
2019-11-17 12:08:21 +01:00
|
|
|
std::map<std::pair<std::string,std::string>, TypeCheck> mTypeChecks;
|
2021-06-12 21:16:52 +02:00
|
|
|
std::unordered_map<std::string, NonOverlappingData> mNonOverlappingData;
|
2013-07-02 07:18:19 +02:00
|
|
|
|
2015-01-08 19:31:41 +01:00
|
|
|
const ArgumentChecks * getarg(const Token *ftok, int argnr) const;
|
2013-07-15 18:55:40 +02:00
|
|
|
|
2016-09-04 14:14:21 +02:00
|
|
|
std::string getFunctionName(const Token *ftok, bool *error) const;
|
|
|
|
|
2016-05-22 17:18:50 +02:00
|
|
|
static const AllocFunc* getAllocDealloc(const std::map<std::string, AllocFunc> &data, const std::string &name) {
|
|
|
|
const std::map<std::string, AllocFunc>::const_iterator it = data.find(name);
|
|
|
|
return (it == data.end()) ? nullptr : &it->second;
|
2013-07-02 07:18:19 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-15 21:14:27 +02:00
|
|
|
CPPCHECKLIB const Library::Container * getLibraryContainer(const Token * tok);
|
|
|
|
|
2013-07-02 07:18:19 +02:00
|
|
|
/// @}
|
2013-09-04 20:59:49 +02:00
|
|
|
//---------------------------------------------------------------------------
|
2013-07-08 18:26:18 +02:00
|
|
|
#endif // libraryH
|