Small refactoring: use a single complete set for reserved for each C/C++. Replace NULL by nullptr
This commit is contained in:
parent
fe8cedade5
commit
53dbcb956f
|
@ -3642,6 +3642,7 @@ namespace {
|
||||||
"static" << "struct" << "switch" << "typedef" << "union" << "unsigned" << "void" << "volatile" <<
|
"static" << "struct" << "switch" << "typedef" << "union" << "unsigned" << "void" << "volatile" <<
|
||||||
"while";
|
"while";
|
||||||
const std::set<std::string> cpp_keywords = make_container< std::set<std::string> >() <<
|
const std::set<std::string> cpp_keywords = make_container< std::set<std::string> >() <<
|
||||||
|
c_keywords <<
|
||||||
"alignas" << "alignof" << "and" << "and_eq" << "asm" << "auto" << "bitand" << "bitor" << "bool" <<
|
"alignas" << "alignof" << "and" << "and_eq" << "asm" << "auto" << "bitand" << "bitor" << "bool" <<
|
||||||
"break" << "case" << "catch" << "char" << "char16_t" << "char32_t" << "class" << "compl" <<
|
"break" << "case" << "catch" << "char" << "char16_t" << "char32_t" << "class" << "compl" <<
|
||||||
"concept" << "const" << "constexpr" << "const_cast" << "continue" << "decltype" << "default" <<
|
"concept" << "const" << "constexpr" << "const_cast" << "continue" << "decltype" << "default" <<
|
||||||
|
@ -3654,9 +3655,13 @@ namespace {
|
||||||
"true" << "try" << "typedef" << "typeid" << "typename" << "union" << "unsigned" << "using" <<
|
"true" << "try" << "typedef" << "typeid" << "typename" << "union" << "unsigned" << "using" <<
|
||||||
"virtual" << "void" << "volatile" << "wchar_t" << "while" << "xor" << "xor_eq";
|
"virtual" << "void" << "volatile" << "wchar_t" << "while" << "xor" << "xor_eq";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SymbolDatabase::isReservedName(const std::string& iName) const
|
bool SymbolDatabase::isReservedName(const std::string& iName) const
|
||||||
{
|
{
|
||||||
return (c_keywords.find(iName) != c_keywords.cend()) || (isCPP() && (cpp_keywords.find(iName) != cpp_keywords.cend()));
|
if (isCPP())
|
||||||
|
return cpp_keywords.find(iName) != cpp_keywords.cend();
|
||||||
|
else
|
||||||
|
return c_keywords.find(iName) != c_keywords.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Token * parsedecl(const Token *type, ValueType * const valuetype);
|
static const Token * parsedecl(const Token *type, ValueType * const valuetype);
|
||||||
|
|
|
@ -49,7 +49,7 @@ enum AccessControl { Public, Protected, Private, Global, Namespace, Argument, Lo
|
||||||
* @brief Array dimension information.
|
* @brief Array dimension information.
|
||||||
*/
|
*/
|
||||||
struct Dimension {
|
struct Dimension {
|
||||||
Dimension() : start(NULL), end(NULL), num(0), known(true) { }
|
Dimension() : start(nullptr), end(nullptr), num(0), known(true) { }
|
||||||
|
|
||||||
const Token *start; // size start token
|
const Token *start; // size start token
|
||||||
const Token *end; // size end token
|
const Token *end; // size end token
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
class BaseInfo {
|
class BaseInfo {
|
||||||
public:
|
public:
|
||||||
BaseInfo() :
|
BaseInfo() :
|
||||||
type(NULL), nameTok(NULL), access(Public), isVirtual(false) {
|
type(nullptr), nameTok(nullptr), access(Public), isVirtual(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
|
|
||||||
struct FriendInfo {
|
struct FriendInfo {
|
||||||
FriendInfo() :
|
FriendInfo() :
|
||||||
nameStart(NULL), nameEnd(NULL), type(NULL) {
|
nameStart(nullptr), nameEnd(nullptr), type(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Token* nameStart;
|
const Token* nameStart;
|
||||||
|
@ -632,14 +632,14 @@ public:
|
||||||
enum Type { eConstructor, eCopyConstructor, eMoveConstructor, eOperatorEqual, eDestructor, eFunction };
|
enum Type { eConstructor, eCopyConstructor, eMoveConstructor, eOperatorEqual, eDestructor, eFunction };
|
||||||
|
|
||||||
Function()
|
Function()
|
||||||
: tokenDef(NULL),
|
: tokenDef(nullptr),
|
||||||
argDef(NULL),
|
argDef(nullptr),
|
||||||
token(NULL),
|
token(nullptr),
|
||||||
arg(NULL),
|
arg(nullptr),
|
||||||
retDef(NULL),
|
retDef(nullptr),
|
||||||
retType(NULL),
|
retType(nullptr),
|
||||||
functionScope(NULL),
|
functionScope(nullptr),
|
||||||
nestedIn(NULL),
|
nestedIn(nullptr),
|
||||||
initArgCount(0),
|
initArgCount(0),
|
||||||
type(eFunction),
|
type(eFunction),
|
||||||
access(Public),
|
access(Public),
|
||||||
|
@ -1001,7 +1001,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void debugMessage(const Token *tok, const std::string &msg) const;
|
void debugMessage(const Token *tok, const std::string &msg) const;
|
||||||
|
|
||||||
void printOut(const char * title = NULL) const;
|
void printOut(const char * title = nullptr) const;
|
||||||
void printVariable(const Variable *var, const char *indent) const;
|
void printVariable(const Variable *var, const char *indent) const;
|
||||||
void printXml(std::ostream &out) const;
|
void printXml(std::ostream &out) const;
|
||||||
|
|
||||||
|
|
10
lib/utils.h
10
lib/utils.h
|
@ -21,15 +21,25 @@
|
||||||
#define utilsH
|
#define utilsH
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
/*! Helper class to aid in the initializing global const data */
|
||||||
template < typename Cont >
|
template < typename Cont >
|
||||||
class make_container {
|
class make_container {
|
||||||
public:
|
public:
|
||||||
typedef make_container< Cont > my_type;
|
typedef make_container< Cont > my_type;
|
||||||
typedef typename Cont::value_type T;
|
typedef typename Cont::value_type T;
|
||||||
|
|
||||||
my_type& operator<< (const T& val) {
|
my_type& operator<< (const T& val) {
|
||||||
data_.insert(data_.end(), val);
|
data_.insert(data_.end(), val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
my_type& operator<< (const Cont& other_container) {
|
||||||
|
for (typename Cont::const_iterator it=other_container.begin(); it!=other_container.end(); ++it) {
|
||||||
|
data_.insert(data_.end(), *it);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
my_type& operator<< (T&& val) {
|
my_type& operator<< (T&& val) {
|
||||||
data_.insert(data_.end(), val);
|
data_.insert(data_.end(), val);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
Loading…
Reference in New Issue