forked from qt-creator/qt-creator
C++: remove reserved names.
See [global.names] (17.6.4.3.2 in the C++11 spec.) Change-Id: I8434496dbe392b52d339d5f17cfaeee8dbd88995 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
12642cc49a
commit
703f36a4b8
22
src/libs/3rdparty/cplusplus/AST.h
vendored
22
src/libs/3rdparty/cplusplus/AST.h
vendored
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
|
|
||||||
template <typename _Tp>
|
template <typename Tptr>
|
||||||
class CPLUSPLUS_EXPORT List: public Managed
|
class CPLUSPLUS_EXPORT List: public Managed
|
||||||
{
|
{
|
||||||
List(const List &other);
|
List(const List &other);
|
||||||
@@ -35,10 +35,10 @@ class CPLUSPLUS_EXPORT List: public Managed
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
List()
|
List()
|
||||||
: value(_Tp()), next(0)
|
: value(Tptr()), next(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
List(const _Tp &value)
|
List(const Tptr &value)
|
||||||
: value(value), next(0)
|
: value(value), next(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
unsigned lastToken() const
|
unsigned lastToken() const
|
||||||
{
|
{
|
||||||
_Tp lv = lastValue();
|
Tptr lv = lastValue();
|
||||||
|
|
||||||
if (lv)
|
if (lv)
|
||||||
return lv->lastToken();
|
return lv->lastToken();
|
||||||
@@ -62,9 +62,9 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Tp lastValue() const
|
Tptr lastValue() const
|
||||||
{
|
{
|
||||||
_Tp lastValue = 0;
|
Tptr lastValue = 0;
|
||||||
|
|
||||||
for (const List *it = this; it; it = it->next) {
|
for (const List *it = this; it; it = it->next) {
|
||||||
if (it->value)
|
if (it->value)
|
||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_Tp value;
|
Tptr value;
|
||||||
List *next;
|
List *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ public:
|
|||||||
static void accept(AST *ast, ASTVisitor *visitor)
|
static void accept(AST *ast, ASTVisitor *visitor)
|
||||||
{ if (ast) ast->accept(visitor); }
|
{ if (ast) ast->accept(visitor); }
|
||||||
|
|
||||||
template <typename _Tp>
|
template <typename Tptr>
|
||||||
static void accept(List<_Tp> *it, ASTVisitor *visitor)
|
static void accept(List<Tptr> *it, ASTVisitor *visitor)
|
||||||
{
|
{
|
||||||
for (; it; it = it->next)
|
for (; it; it = it->next)
|
||||||
accept(it->value, visitor);
|
accept(it->value, visitor);
|
||||||
@@ -102,8 +102,8 @@ public:
|
|||||||
static bool match(AST *ast, AST *pattern, ASTMatcher *matcher);
|
static bool match(AST *ast, AST *pattern, ASTMatcher *matcher);
|
||||||
bool match(AST *pattern, ASTMatcher *matcher);
|
bool match(AST *pattern, ASTMatcher *matcher);
|
||||||
|
|
||||||
template <typename _Tp>
|
template <typename Tptr>
|
||||||
static bool match(List<_Tp> *it, List<_Tp> *patternIt, ASTMatcher *matcher)
|
static bool match(List<Tptr> *it, List<Tptr> *patternIt, ASTMatcher *matcher)
|
||||||
{
|
{
|
||||||
while (it && patternIt) {
|
while (it && patternIt) {
|
||||||
if (! match(it->value, patternIt->value, matcher))
|
if (! match(it->value, patternIt->value, matcher))
|
||||||
|
|||||||
4
src/libs/3rdparty/cplusplus/ASTVisitor.h
vendored
4
src/libs/3rdparty/cplusplus/ASTVisitor.h
vendored
@@ -63,8 +63,8 @@ public:
|
|||||||
|
|
||||||
void accept(AST *ast);
|
void accept(AST *ast);
|
||||||
|
|
||||||
template <typename _Tp>
|
template <typename Tptr>
|
||||||
void accept(List<_Tp> *it)
|
void accept(List<Tptr> *it)
|
||||||
{
|
{
|
||||||
for (; it; it = it->next)
|
for (; it; it = it->next)
|
||||||
accept(it->value);
|
accept(it->value);
|
||||||
|
|||||||
2
src/libs/3rdparty/cplusplus/ASTfwd.h
vendored
2
src/libs/3rdparty/cplusplus/ASTfwd.h
vendored
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
|
|
||||||
template <typename _Tp> class List;
|
template <typename Tptr> class List;
|
||||||
|
|
||||||
class AST;
|
class AST;
|
||||||
class ASTVisitor;
|
class ASTVisitor;
|
||||||
|
|||||||
28
src/libs/3rdparty/cplusplus/Control.cpp
vendored
28
src/libs/3rdparty/cplusplus/Control.cpp
vendored
@@ -33,7 +33,7 @@ using namespace CPlusPlus;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename _Tp>
|
template <typename T>
|
||||||
struct Compare;
|
struct Compare;
|
||||||
|
|
||||||
template <> struct Compare<IntegerType>
|
template <> struct Compare<IntegerType>
|
||||||
@@ -178,26 +178,26 @@ template <> struct Compare<SelectorNameId>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename _Tp>
|
template <typename T>
|
||||||
class Table: public std::set<_Tp, Compare<_Tp> >
|
class Table: public std::set<T, Compare<T> >
|
||||||
{
|
{
|
||||||
typedef std::set<_Tp, Compare<_Tp> > _Base;
|
typedef std::set<T, Compare<T> > _Base;
|
||||||
public:
|
public:
|
||||||
_Tp *intern(const _Tp &element)
|
T *intern(const T &element)
|
||||||
{ return const_cast<_Tp *>(&*_Base::insert(element).first); }
|
{ return const_cast<T *>(&*_Base::insert(element).first); }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
|
||||||
template <typename _Iterator>
|
template <typename Iterator>
|
||||||
static void delete_array_entries(_Iterator first, _Iterator last)
|
static void delete_array_entries(Iterator first, Iterator last)
|
||||||
{
|
{
|
||||||
for (; first != last; ++first)
|
for (; first != last; ++first)
|
||||||
delete *first;
|
delete *first;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename _Array>
|
template <typename Array>
|
||||||
static void delete_array_entries(const _Array &a)
|
static void delete_array_entries(const Array &a)
|
||||||
{ delete_array_entries(a.begin(), a.end()); }
|
{ delete_array_entries(a.begin(), a.end()); }
|
||||||
|
|
||||||
class Control::Data
|
class Control::Data
|
||||||
@@ -233,9 +233,9 @@ public:
|
|||||||
return anonymousNameIds.intern(AnonymousNameId(classTokenIndex));
|
return anonymousNameIds.intern(AnonymousNameId(classTokenIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename _Iterator>
|
template <typename Iterator>
|
||||||
const TemplateNameId *findOrInsertTemplateNameId(const Identifier *id, bool isSpecialization,
|
const TemplateNameId *findOrInsertTemplateNameId(const Identifier *id, bool isSpecialization,
|
||||||
_Iterator first, _Iterator last)
|
Iterator first, Iterator last)
|
||||||
{
|
{
|
||||||
return templateNameIds.intern(TemplateNameId(id, isSpecialization, first, last));
|
return templateNameIds.intern(TemplateNameId(id, isSpecialization, first, last));
|
||||||
}
|
}
|
||||||
@@ -260,8 +260,8 @@ public:
|
|||||||
return qualifiedNameIds.intern(QualifiedNameId(base, name));
|
return qualifiedNameIds.intern(QualifiedNameId(base, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename _Iterator>
|
template <typename Iterator>
|
||||||
const SelectorNameId *findOrInsertSelectorNameId(_Iterator first, _Iterator last, bool hasArguments)
|
const SelectorNameId *findOrInsertSelectorNameId(Iterator first, Iterator last, bool hasArguments)
|
||||||
{
|
{
|
||||||
return selectorNameIds.intern(SelectorNameId(first, last, hasArguments));
|
return selectorNameIds.intern(SelectorNameId(first, last, hasArguments));
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
14
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
@@ -137,7 +137,7 @@ void Lexer::scan(Token *tok)
|
|||||||
|
|
||||||
void Lexer::scan_helper(Token *tok)
|
void Lexer::scan_helper(Token *tok)
|
||||||
{
|
{
|
||||||
_Lagain:
|
again:
|
||||||
while (_yychar && std::isspace(_yychar)) {
|
while (_yychar && std::isspace(_yychar)) {
|
||||||
if (_yychar == '\n') {
|
if (_yychar == '\n') {
|
||||||
tok->f.joined = s._newlineExpected;
|
tok->f.joined = s._newlineExpected;
|
||||||
@@ -198,7 +198,7 @@ void Lexer::scan_helper(Token *tok)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! f._scanCommentTokens)
|
if (! f._scanCommentTokens)
|
||||||
goto _Lagain;
|
goto again;
|
||||||
|
|
||||||
tok->f.kind = originalKind;
|
tok->f.kind = originalKind;
|
||||||
return; // done
|
return; // done
|
||||||
@@ -232,7 +232,7 @@ void Lexer::scan_helper(Token *tok)
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '\\':
|
case '\\':
|
||||||
s._newlineExpected = true;
|
s._newlineExpected = true;
|
||||||
goto _Lagain;
|
goto again;
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
scanStringLiteral(tok);
|
scanStringLiteral(tok);
|
||||||
@@ -404,7 +404,7 @@ void Lexer::scan_helper(Token *tok)
|
|||||||
scanCppComment(commentType);
|
scanCppComment(commentType);
|
||||||
|
|
||||||
if (! f._scanCommentTokens)
|
if (! f._scanCommentTokens)
|
||||||
goto _Lagain;
|
goto again;
|
||||||
|
|
||||||
tok->f.kind = commentType;
|
tok->f.kind = commentType;
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ void Lexer::scan_helper(Token *tok)
|
|||||||
yyinp();
|
yyinp();
|
||||||
|
|
||||||
if (ch == '*' && _yychar == '/')
|
if (ch == '*' && _yychar == '/')
|
||||||
goto _Ldone;
|
goto done;
|
||||||
|
|
||||||
if (_yychar == '<')
|
if (_yychar == '<')
|
||||||
yyinp();
|
yyinp();
|
||||||
@@ -438,14 +438,14 @@ void Lexer::scan_helper(Token *tok)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_Ldone:
|
done:
|
||||||
if (_yychar)
|
if (_yychar)
|
||||||
yyinp();
|
yyinp();
|
||||||
else
|
else
|
||||||
s._tokenKind = commentKind;
|
s._tokenKind = commentKind;
|
||||||
|
|
||||||
if (! f._scanCommentTokens)
|
if (! f._scanCommentTokens)
|
||||||
goto _Lagain;
|
goto again;
|
||||||
|
|
||||||
tok->f.kind = commentKind;
|
tok->f.kind = commentKind;
|
||||||
|
|
||||||
|
|||||||
42
src/libs/3rdparty/cplusplus/LiteralTable.h
vendored
42
src/libs/3rdparty/cplusplus/LiteralTable.h
vendored
@@ -26,14 +26,14 @@
|
|||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
|
|
||||||
template <typename _Literal>
|
template <typename Literal>
|
||||||
class LiteralTable
|
class LiteralTable
|
||||||
{
|
{
|
||||||
LiteralTable(const LiteralTable &other);
|
LiteralTable(const LiteralTable &other);
|
||||||
void operator =(const LiteralTable &other);
|
void operator =(const LiteralTable &other);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef _Literal *const *iterator;
|
typedef Literal *const *iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LiteralTable()
|
LiteralTable()
|
||||||
@@ -52,8 +52,8 @@ public:
|
|||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
if (_literals) {
|
if (_literals) {
|
||||||
_Literal **lastLiteral = _literals + _literalCount + 1;
|
Literal **lastLiteral = _literals + _literalCount + 1;
|
||||||
for (_Literal **it = _literals; it != lastLiteral; ++it)
|
for (Literal **it = _literals; it != lastLiteral; ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
std::free(_literals);
|
std::free(_literals);
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
unsigned size() const
|
unsigned size() const
|
||||||
{ return _literalCount + 1; }
|
{ return _literalCount + 1; }
|
||||||
|
|
||||||
const _Literal *at(unsigned index) const
|
const Literal *at(unsigned index) const
|
||||||
{ return _literals[index]; }
|
{ return _literals[index]; }
|
||||||
|
|
||||||
iterator begin() const
|
iterator begin() const
|
||||||
@@ -82,12 +82,12 @@ public:
|
|||||||
iterator end() const
|
iterator end() const
|
||||||
{ return _literals + _literalCount + 1; }
|
{ return _literals + _literalCount + 1; }
|
||||||
|
|
||||||
const _Literal *findLiteral(const char *chars, unsigned size) const
|
const Literal *findLiteral(const char *chars, unsigned size) const
|
||||||
{
|
{
|
||||||
if (_buckets) {
|
if (_buckets) {
|
||||||
unsigned h = _Literal::hashCode(chars, size);
|
unsigned h = Literal::hashCode(chars, size);
|
||||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
Literal *literal = _buckets[h % _allocatedBuckets];
|
||||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
for (; literal; literal = static_cast<Literal *>(literal->_next)) {
|
||||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||||
return literal;
|
return literal;
|
||||||
}
|
}
|
||||||
@@ -96,18 +96,18 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const _Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
const Literal *findOrInsertLiteral(const char *chars, unsigned size)
|
||||||
{
|
{
|
||||||
if (_buckets) {
|
if (_buckets) {
|
||||||
unsigned h = _Literal::hashCode(chars, size);
|
unsigned h = Literal::hashCode(chars, size);
|
||||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
Literal *literal = _buckets[h % _allocatedBuckets];
|
||||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
for (; literal; literal = static_cast<Literal *>(literal->_next)) {
|
||||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||||
return literal;
|
return literal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_Literal *literal = new _Literal(chars, size);
|
Literal *literal = new Literal(chars, size);
|
||||||
|
|
||||||
if (++_literalCount == _allocatedLiterals) {
|
if (++_literalCount == _allocatedLiterals) {
|
||||||
if (! _allocatedLiterals)
|
if (! _allocatedLiterals)
|
||||||
@@ -115,7 +115,7 @@ public:
|
|||||||
else
|
else
|
||||||
_allocatedLiterals <<= 1;
|
_allocatedLiterals <<= 1;
|
||||||
|
|
||||||
_literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
_literals = (Literal **) std::realloc(_literals, sizeof(Literal *) * _allocatedLiterals);
|
||||||
}
|
}
|
||||||
|
|
||||||
_literals[_literalCount] = literal;
|
_literals[_literalCount] = literal;
|
||||||
@@ -142,12 +142,12 @@ protected:
|
|||||||
else
|
else
|
||||||
_allocatedBuckets <<= 1;
|
_allocatedBuckets <<= 1;
|
||||||
|
|
||||||
_buckets = (_Literal **) std::calloc(_allocatedBuckets, sizeof(_Literal *));
|
_buckets = (Literal **) std::calloc(_allocatedBuckets, sizeof(Literal *));
|
||||||
|
|
||||||
_Literal **lastLiteral = _literals + (_literalCount + 1);
|
Literal **lastLiteral = _literals + (_literalCount + 1);
|
||||||
|
|
||||||
for (_Literal **it = _literals; it != lastLiteral; ++it) {
|
for (Literal **it = _literals; it != lastLiteral; ++it) {
|
||||||
_Literal *literal = *it;
|
Literal *literal = *it;
|
||||||
unsigned h = literal->hashCode() % _allocatedBuckets;
|
unsigned h = literal->hashCode() % _allocatedBuckets;
|
||||||
|
|
||||||
literal->_next = _buckets[h];
|
literal->_next = _buckets[h];
|
||||||
@@ -156,8 +156,8 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
_Literal **_literals;
|
Literal **_literals;
|
||||||
_Literal **_buckets;
|
Literal **_buckets;
|
||||||
int _allocatedLiterals;
|
int _allocatedLiterals;
|
||||||
int _literalCount;
|
int _literalCount;
|
||||||
int _allocatedBuckets;
|
int _allocatedBuckets;
|
||||||
|
|||||||
10
src/libs/3rdparty/cplusplus/Names.h
vendored
10
src/libs/3rdparty/cplusplus/Names.h
vendored
@@ -77,9 +77,9 @@ private:
|
|||||||
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <typename _Iterator>
|
template <typename Iterator>
|
||||||
TemplateNameId(const Identifier *identifier, bool isSpecialization, _Iterator first,
|
TemplateNameId(const Identifier *identifier, bool isSpecialization, Iterator first,
|
||||||
_Iterator last)
|
Iterator last)
|
||||||
: _identifier(identifier)
|
: _identifier(identifier)
|
||||||
, _templateArguments(first, last)
|
, _templateArguments(first, last)
|
||||||
, _isSpecialization(isSpecialization) {}
|
, _isSpecialization(isSpecialization) {}
|
||||||
@@ -220,8 +220,8 @@ private:
|
|||||||
class CPLUSPLUS_EXPORT SelectorNameId: public Name
|
class CPLUSPLUS_EXPORT SelectorNameId: public Name
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <typename _Iterator>
|
template <typename Iterator>
|
||||||
SelectorNameId(_Iterator first, _Iterator last, bool hasArguments)
|
SelectorNameId(Iterator first, Iterator last, bool hasArguments)
|
||||||
: _names(first, last), _hasArguments(hasArguments) {}
|
: _names(first, last), _hasArguments(hasArguments) {}
|
||||||
|
|
||||||
virtual ~SelectorNameId();
|
virtual ~SelectorNameId();
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ void TranslationUnit::tokenize()
|
|||||||
do {
|
do {
|
||||||
lex(&tk);
|
lex(&tk);
|
||||||
|
|
||||||
_Lrecognize:
|
recognize:
|
||||||
if (tk.is(T_POUND) && tk.newline()) {
|
if (tk.is(T_POUND) && tk.newline()) {
|
||||||
const unsigned utf16CharOffset = tk.utf16charOffset;
|
const unsigned utf16CharOffset = tk.utf16charOffset;
|
||||||
lex(&tk);
|
lex(&tk);
|
||||||
@@ -244,7 +244,7 @@ void TranslationUnit::tokenize()
|
|||||||
while (tk.isNot(T_EOF_SYMBOL) && ! tk.newline())
|
while (tk.isNot(T_EOF_SYMBOL) && ! tk.newline())
|
||||||
lex(&tk);
|
lex(&tk);
|
||||||
}
|
}
|
||||||
goto _Lrecognize;
|
goto recognize;
|
||||||
} else if (tk.kind() == T_LBRACE) {
|
} else if (tk.kind() == T_LBRACE) {
|
||||||
braces.push(unsigned(_tokens->size()));
|
braces.push(unsigned(_tokens->size()));
|
||||||
} else if (tk.kind() == T_RBRACE && ! braces.empty()) {
|
} else if (tk.kind() == T_RBRACE && ! braces.empty()) {
|
||||||
|
|||||||
@@ -391,14 +391,14 @@ private:
|
|||||||
|
|
||||||
class CPLUSPLUS_EXPORT Snapshot
|
class CPLUSPLUS_EXPORT Snapshot
|
||||||
{
|
{
|
||||||
typedef QHash<QString, Document::Ptr> _Base;
|
typedef QHash<QString, Document::Ptr> Base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Snapshot();
|
Snapshot();
|
||||||
~Snapshot();
|
~Snapshot();
|
||||||
|
|
||||||
typedef _Base::const_iterator iterator;
|
typedef Base::const_iterator iterator;
|
||||||
typedef _Base::const_iterator const_iterator;
|
typedef Base::const_iterator const_iterator;
|
||||||
|
|
||||||
int size() const; // ### remove
|
int size() const; // ### remove
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
@@ -428,7 +428,7 @@ private:
|
|||||||
void allIncludesForDocument_helper(const QString &fileName, QSet<QString> &result) const;
|
void allIncludesForDocument_helper(const QString &fileName, QSet<QString> &result) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_Base _documents;
|
Base _documents;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CPlusPlus
|
} // namespace CPlusPlus
|
||||||
|
|||||||
@@ -99,11 +99,11 @@ Macro *Environment::macroAt(unsigned index) const
|
|||||||
return _macros[index];
|
return _macros[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *Environment::bind(const Macro &__macro)
|
Macro *Environment::bind(const Macro ¯o)
|
||||||
{
|
{
|
||||||
Q_ASSERT(! __macro.name().isEmpty());
|
Q_ASSERT(! macro.name().isEmpty());
|
||||||
|
|
||||||
Macro *m = new Macro (__macro);
|
Macro *m = new Macro (macro);
|
||||||
const QByteArray &name = m->name();
|
const QByteArray &name = m->name();
|
||||||
m->_hashcode = hashCode(name.begin(), name.size());
|
m->_hashcode = hashCode(name.begin(), name.size());
|
||||||
|
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ static const bool debug = ! qgetenv("QTC_LOOKUPCONTEXT_DEBUG").isEmpty();
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <typename _Tp>
|
template <typename T>
|
||||||
static QList<_Tp> removeDuplicates(const QList<_Tp> &results)
|
static QList<T> removeDuplicates(const QList<T> &results)
|
||||||
{
|
{
|
||||||
QList<_Tp> uniqueList;
|
QList<T> uniqueList;
|
||||||
QSet<_Tp> processed;
|
QSet<T> processed;
|
||||||
foreach (const _Tp &r, results) {
|
foreach (const T &r, results) {
|
||||||
if (processed.contains(r))
|
if (processed.contains(r))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -55,17 +55,17 @@
|
|||||||
|
|
||||||
namespace CPlusPlus {
|
namespace CPlusPlus {
|
||||||
|
|
||||||
inline bool CPLUSPLUS_EXPORT pp_isalpha (int __ch)
|
inline bool CPLUSPLUS_EXPORT pp_isalpha (int ch)
|
||||||
{ return std::isalpha ((unsigned char) __ch) != 0; }
|
{ return std::isalpha ((unsigned char) ch) != 0; }
|
||||||
|
|
||||||
inline bool CPLUSPLUS_EXPORT pp_isalnum (int __ch)
|
inline bool CPLUSPLUS_EXPORT pp_isalnum (int ch)
|
||||||
{ return std::isalnum ((unsigned char) __ch) != 0; }
|
{ return std::isalnum ((unsigned char) ch) != 0; }
|
||||||
|
|
||||||
inline bool CPLUSPLUS_EXPORT pp_isdigit (int __ch)
|
inline bool CPLUSPLUS_EXPORT pp_isdigit (int ch)
|
||||||
{ return std::isdigit ((unsigned char) __ch) != 0; }
|
{ return std::isdigit ((unsigned char) ch) != 0; }
|
||||||
|
|
||||||
inline bool CPLUSPLUS_EXPORT pp_isspace (int __ch)
|
inline bool CPLUSPLUS_EXPORT pp_isspace (int ch)
|
||||||
{ return std::isspace ((unsigned char) __ch) != 0; }
|
{ return std::isspace ((unsigned char) ch) != 0; }
|
||||||
|
|
||||||
} // namespace CPlusPlus
|
} // namespace CPlusPlus
|
||||||
|
|
||||||
|
|||||||
@@ -834,13 +834,13 @@ void Preprocessor::pushToken(Preprocessor::PPToken *tk)
|
|||||||
|
|
||||||
void Preprocessor::lex(PPToken *tk)
|
void Preprocessor::lex(PPToken *tk)
|
||||||
{
|
{
|
||||||
_Lagain:
|
again:
|
||||||
if (m_state.m_tokenBuffer) {
|
if (m_state.m_tokenBuffer) {
|
||||||
// There is a token buffer, so read from there.
|
// There is a token buffer, so read from there.
|
||||||
if (m_state.m_tokenBuffer->tokens.empty()) {
|
if (m_state.m_tokenBuffer->tokens.empty()) {
|
||||||
// The token buffer is empty, so pop it, and start over.
|
// The token buffer is empty, so pop it, and start over.
|
||||||
m_state.popTokenBuffer();
|
m_state.popTokenBuffer();
|
||||||
goto _Lagain;
|
goto again;
|
||||||
}
|
}
|
||||||
*tk = m_state.m_tokenBuffer->tokens.front();
|
*tk = m_state.m_tokenBuffer->tokens.front();
|
||||||
m_state.m_tokenBuffer->tokens.pop_front();
|
m_state.m_tokenBuffer->tokens.pop_front();
|
||||||
@@ -859,17 +859,17 @@ _Lagain:
|
|||||||
// Adjust token's line number in order to take into account the environment reference.
|
// Adjust token's line number in order to take into account the environment reference.
|
||||||
tk->lineno += m_state.m_lineRef - 1;
|
tk->lineno += m_state.m_lineRef - 1;
|
||||||
|
|
||||||
_Lclassify:
|
reclassify:
|
||||||
if (! m_state.m_inPreprocessorDirective) {
|
if (! m_state.m_inPreprocessorDirective) {
|
||||||
if (tk->newline() && tk->is(T_POUND)) {
|
if (tk->newline() && tk->is(T_POUND)) {
|
||||||
handlePreprocessorDirective(tk);
|
handlePreprocessorDirective(tk);
|
||||||
goto _Lclassify;
|
goto reclassify;
|
||||||
} else if (tk->newline() && skipping()) {
|
} else if (tk->newline() && skipping()) {
|
||||||
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
|
ScopedBoolSwap s(m_state.m_inPreprocessorDirective, true);
|
||||||
do {
|
do {
|
||||||
lex(tk);
|
lex(tk);
|
||||||
} while (isContinuationToken(*tk));
|
} while (isContinuationToken(*tk));
|
||||||
goto _Lclassify;
|
goto reclassify;
|
||||||
} else if (tk->is(T_IDENTIFIER) && !isQtReservedWord(tk->tokenStart(), tk->bytes())) {
|
} else if (tk->is(T_IDENTIFIER) && !isQtReservedWord(tk->tokenStart(), tk->bytes())) {
|
||||||
m_state.updateIncludeGuardState(State::IncludeGuardStateHint_OtherToken);
|
m_state.updateIncludeGuardState(State::IncludeGuardStateHint_OtherToken);
|
||||||
if (m_state.m_inCondition && tk->asByteArrayRef() == "defined") {
|
if (m_state.m_inCondition && tk->asByteArrayRef() == "defined") {
|
||||||
@@ -877,7 +877,7 @@ _Lclassify:
|
|||||||
} else {
|
} else {
|
||||||
synchronizeOutputLines(*tk);
|
synchronizeOutputLines(*tk);
|
||||||
if (handleIdentifier(tk))
|
if (handleIdentifier(tk))
|
||||||
goto _Lagain;
|
goto again;
|
||||||
}
|
}
|
||||||
} else if (tk->isNot(T_COMMENT) && tk->isNot(T_EOF_SYMBOL)) {
|
} else if (tk->isNot(T_COMMENT) && tk->isNot(T_EOF_SYMBOL)) {
|
||||||
m_state.updateIncludeGuardState(State::IncludeGuardStateHint_OtherToken);
|
m_state.updateIncludeGuardState(State::IncludeGuardStateHint_OtherToken);
|
||||||
|
|||||||
@@ -51,39 +51,39 @@
|
|||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
|
||||||
const char *pp_skip_blanks::operator () (const char *__first, const char *__last)
|
const char *pp_skip_blanks::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
|
for (; first != last; lines += (*first != '\n' ? 0 : 1), ++first) {
|
||||||
if (*__first == '\\') {
|
if (*first == '\\') {
|
||||||
const char *__begin = __first;
|
const char *begin = first;
|
||||||
++__begin;
|
++begin;
|
||||||
|
|
||||||
if (__begin != __last && *__begin == '\n')
|
if (begin != last && *begin == '\n')
|
||||||
++__first;
|
++first;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
} else if (*__first == '\n' || !pp_isspace (*__first))
|
} else if (*first == '\n' || !pp_isspace (*first))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pp_skip_whitespaces::operator () (const char *__first, const char *__last)
|
const char *pp_skip_whitespaces::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
|
for (; first != last; lines += (*first != '\n' ? 0 : 1), ++first) {
|
||||||
if (! pp_isspace (*__first))
|
if (! pp_isspace (*first))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pp_skip_comment_or_divop::operator () (const char *__first, const char *__last)
|
const char *pp_skip_comment_or_divop::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
MAYBE_BEGIN,
|
MAYBE_BEGIN,
|
||||||
@@ -96,77 +96,77 @@ const char *pp_skip_comment_or_divop::operator () (const char *__first, const ch
|
|||||||
|
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
|
for (; first != last; lines += (*first != '\n' ? 0 : 1), ++first) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAYBE_BEGIN:
|
case MAYBE_BEGIN:
|
||||||
if (*__first != '/')
|
if (*first != '/')
|
||||||
return __first;
|
return first;
|
||||||
|
|
||||||
state = BEGIN;
|
state = BEGIN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEGIN:
|
case BEGIN:
|
||||||
if (*__first == '*')
|
if (*first == '*')
|
||||||
state = IN_COMMENT;
|
state = IN_COMMENT;
|
||||||
else if (*__first == '/')
|
else if (*first == '/')
|
||||||
state = IN_CXX_COMMENT;
|
state = IN_CXX_COMMENT;
|
||||||
else
|
else
|
||||||
return __first;
|
return first;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IN_COMMENT:
|
case IN_COMMENT:
|
||||||
if (*__first == '*')
|
if (*first == '*')
|
||||||
state = MAYBE_END;
|
state = MAYBE_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IN_CXX_COMMENT:
|
case IN_CXX_COMMENT:
|
||||||
if (*__first == '\n')
|
if (*first == '\n')
|
||||||
return __first;
|
return first;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAYBE_END:
|
case MAYBE_END:
|
||||||
if (*__first == '/')
|
if (*first == '/')
|
||||||
state = END;
|
state = END;
|
||||||
else if (*__first != '*')
|
else if (*first != '*')
|
||||||
state = IN_COMMENT;
|
state = IN_COMMENT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case END:
|
case END:
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pp_skip_identifier::operator () (const char *__first, const char *__last)
|
const char *pp_skip_identifier::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
|
for (; first != last; lines += (*first != '\n' ? 0 : 1), ++first) {
|
||||||
if (! pp_isalnum (*__first) && *__first != '_')
|
if (! pp_isalnum (*first) && *first != '_')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pp_skip_number::operator () (const char *__first, const char *__last)
|
const char *pp_skip_number::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
|
for (; first != last; lines += (*first != '\n' ? 0 : 1), ++first) {
|
||||||
if (! pp_isalnum (*__first) && *__first != '.')
|
if (! pp_isalnum (*first) && *first != '.')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pp_skip_string_literal::operator () (const char *__first, const char *__last)
|
const char *pp_skip_string_literal::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
BEGIN,
|
BEGIN,
|
||||||
@@ -177,25 +177,25 @@ const char *pp_skip_string_literal::operator () (const char *__first, const char
|
|||||||
|
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
for (; __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
|
for (; first != last; lines += (*first != '\n' ? 0 : 1), ++first) {
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEGIN:
|
case BEGIN:
|
||||||
if (*__first != '\"')
|
if (*first != '\"')
|
||||||
return __first;
|
return first;
|
||||||
state = IN_STRING;
|
state = IN_STRING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IN_STRING:
|
case IN_STRING:
|
||||||
if (! (*__first != '\n'))
|
if (! (*first != '\n'))
|
||||||
return __last;
|
return last;
|
||||||
|
|
||||||
if (*__first == '\"')
|
if (*first == '\"')
|
||||||
state = END;
|
state = END;
|
||||||
else if (*__first == '\\')
|
else if (*first == '\\')
|
||||||
state = QUOTE;
|
state = QUOTE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -204,14 +204,14 @@ const char *pp_skip_string_literal::operator () (const char *__first, const char
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case END:
|
case END:
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pp_skip_char_literal::operator () (const char *__first, const char *__last)
|
const char *pp_skip_char_literal::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
BEGIN,
|
BEGIN,
|
||||||
@@ -222,25 +222,25 @@ const char *pp_skip_char_literal::operator () (const char *__first, const char *
|
|||||||
|
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
for (; state != END && __first != __last; lines += (*__first != '\n' ? 0 : 1), ++__first) {
|
for (; state != END && first != last; lines += (*first != '\n' ? 0 : 1), ++first) {
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEGIN:
|
case BEGIN:
|
||||||
if (*__first != '\'')
|
if (*first != '\'')
|
||||||
return __first;
|
return first;
|
||||||
state = IN_STRING;
|
state = IN_STRING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IN_STRING:
|
case IN_STRING:
|
||||||
if (! (*__first != '\n'))
|
if (! (*first != '\n'))
|
||||||
return __last;
|
return last;
|
||||||
|
|
||||||
if (*__first == '\'')
|
if (*first == '\'')
|
||||||
state = END;
|
state = END;
|
||||||
else if (*__first == '\\')
|
else if (*first == '\\')
|
||||||
state = QUOTE;
|
state = QUOTE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -250,44 +250,44 @@ const char *pp_skip_char_literal::operator () (const char *__first, const char *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *pp_skip_argument::operator () (const char *__first, const char *__last)
|
const char *pp_skip_argument::operator () (const char *first, const char *last)
|
||||||
{
|
{
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
lines = 0;
|
lines = 0;
|
||||||
|
|
||||||
while (__first != __last) {
|
while (first != last) {
|
||||||
if (!depth && (*__first == ')' || *__first == ',')) {
|
if (!depth && (*first == ')' || *first == ',')) {
|
||||||
break;
|
break;
|
||||||
} else if (*__first == '(') {
|
} else if (*first == '(') {
|
||||||
++depth, ++__first;
|
++depth, ++first;
|
||||||
} else if (*__first == ')') {
|
} else if (*first == ')') {
|
||||||
--depth, ++__first;
|
--depth, ++first;
|
||||||
} else if (*__first == '\"') {
|
} else if (*first == '\"') {
|
||||||
__first = skip_string_literal (__first, __last);
|
first = skip_string_literal (first, last);
|
||||||
lines += skip_string_literal.lines;
|
lines += skip_string_literal.lines;
|
||||||
} else if (*__first == '\'') {
|
} else if (*first == '\'') {
|
||||||
__first = skip_char_literal (__first, __last);
|
first = skip_char_literal (first, last);
|
||||||
lines += skip_char_literal.lines;
|
lines += skip_char_literal.lines;
|
||||||
} else if (*__first == '/') {
|
} else if (*first == '/') {
|
||||||
__first = skip_comment_or_divop (__first, __last);
|
first = skip_comment_or_divop (first, last);
|
||||||
lines += skip_comment_or_divop.lines;
|
lines += skip_comment_or_divop.lines;
|
||||||
} else if (pp_isalpha (*__first) || *__first == '_') {
|
} else if (pp_isalpha (*first) || *first == '_') {
|
||||||
__first = skip_identifier (__first, __last);
|
first = skip_identifier (first, last);
|
||||||
lines += skip_identifier.lines;
|
lines += skip_identifier.lines;
|
||||||
} else if (pp_isdigit (*__first)) {
|
} else if (pp_isdigit (*first)) {
|
||||||
__first = skip_number (__first, __last);
|
first = skip_number (first, last);
|
||||||
lines += skip_number.lines;
|
lines += skip_number.lines;
|
||||||
} else if (*__first == '\n') {
|
} else if (*first == '\n') {
|
||||||
++__first;
|
++first;
|
||||||
++lines;
|
++lines;
|
||||||
} else {
|
} else {
|
||||||
++__first;
|
++first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return __first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,20 +72,20 @@ private:
|
|||||||
int _line;
|
int _line;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename _Type>
|
template <typename Type>
|
||||||
class TypeTable
|
class TypeTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Compare: std::binary_function<_Type, _Type, bool> {
|
struct Compare: std::binary_function<Type, Type, bool> {
|
||||||
bool operator()(const _Type &value, const _Type &other) const {
|
bool operator()(const Type &value, const Type &other) const {
|
||||||
return value.isLessThan(&other);
|
return value.isLessThan(&other);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const _Type *intern(const _Type &ty) { return &*_entries.insert(ty).first; }
|
const Type *intern(const Type &ty) { return &*_entries.insert(ty).first; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<_Type, Compare> _entries;
|
std::set<Type, Compare> _entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GLSL_EXPORT Engine
|
class GLSL_EXPORT Engine
|
||||||
|
|||||||
Reference in New Issue
Block a user