Small refactoring: use a single complete set for reserved for each C/C++. Replace NULL by nullptr

This commit is contained in:
Alexander Mai 2015-11-29 13:23:13 +01:00
parent fe8cedade5
commit 53dbcb956f
3 changed files with 28 additions and 13 deletions

View File

@ -3642,6 +3642,7 @@ namespace {
"static" << "struct" << "switch" << "typedef" << "union" << "unsigned" << "void" << "volatile" <<
"while";
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" <<
"break" << "case" << "catch" << "char" << "char16_t" << "char32_t" << "class" << "compl" <<
"concept" << "const" << "constexpr" << "const_cast" << "continue" << "decltype" << "default" <<
@ -3654,9 +3655,13 @@ namespace {
"true" << "try" << "typedef" << "typeid" << "typename" << "union" << "unsigned" << "using" <<
"virtual" << "void" << "volatile" << "wchar_t" << "while" << "xor" << "xor_eq";
}
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);

View File

@ -49,7 +49,7 @@ enum AccessControl { Public, Protected, Private, Global, Namespace, Argument, Lo
* @brief Array dimension information.
*/
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 *end; // size end token
@ -70,7 +70,7 @@ public:
class BaseInfo {
public:
BaseInfo() :
type(NULL), nameTok(NULL), access(Public), isVirtual(false) {
type(nullptr), nameTok(nullptr), access(Public), isVirtual(false) {
}
std::string name;
@ -86,7 +86,7 @@ public:
struct FriendInfo {
FriendInfo() :
nameStart(NULL), nameEnd(NULL), type(NULL) {
nameStart(nullptr), nameEnd(nullptr), type(nullptr) {
}
const Token* nameStart;
@ -632,14 +632,14 @@ public:
enum Type { eConstructor, eCopyConstructor, eMoveConstructor, eOperatorEqual, eDestructor, eFunction };
Function()
: tokenDef(NULL),
argDef(NULL),
token(NULL),
arg(NULL),
retDef(NULL),
retType(NULL),
functionScope(NULL),
nestedIn(NULL),
: tokenDef(nullptr),
argDef(nullptr),
token(nullptr),
arg(nullptr),
retDef(nullptr),
retType(nullptr),
functionScope(nullptr),
nestedIn(nullptr),
initArgCount(0),
type(eFunction),
access(Public),
@ -1001,7 +1001,7 @@ public:
*/
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 printXml(std::ostream &out) const;

View File

@ -21,15 +21,25 @@
#define utilsH
//---------------------------------------------------------------------------
#include <algorithm>
/*! Helper class to aid in the initializing global const data */
template < typename Cont >
class make_container {
public:
typedef make_container< Cont > my_type;
typedef typename Cont::value_type T;
my_type& operator<< (const T& val) {
data_.insert(data_.end(), val);
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) {
data_.insert(data_.end(), val);
return *this;