forked from qt-creator/qt-creator
Compile the C++ parser library with Sun CC 5.9.
Things you mustn't do: 1) end an enum with a comma 2) #include <cxxxx> and not use std:: 3) use anonymous structures All three things are invalid C++. Anonymous structures inside anonymous unions are allowed by GCC, but that doesn't mean it's valid.
This commit is contained in:
@@ -60,12 +60,12 @@ Macro::Macro()
|
||||
QString Macro::toString() const
|
||||
{
|
||||
QString text;
|
||||
if (_hidden)
|
||||
if (f._hidden)
|
||||
text += QLatin1String("#undef ");
|
||||
else
|
||||
text += QLatin1String("#define ");
|
||||
text += QString::fromUtf8(_name.constData(), _name.size());
|
||||
if (_functionLike) {
|
||||
if (f._functionLike) {
|
||||
text += QLatin1Char('(');
|
||||
bool first = true;
|
||||
foreach (const QByteArray formal, _formals) {
|
||||
@@ -75,7 +75,7 @@ QString Macro::toString() const
|
||||
first = false;
|
||||
text += QString::fromUtf8(formal.constData(), formal.size());
|
||||
}
|
||||
if (_variadic)
|
||||
if (f._variadic)
|
||||
text += QLatin1String("...");
|
||||
text += QLatin1Char(')');
|
||||
}
|
||||
|
@@ -93,22 +93,22 @@ public:
|
||||
{ _line = line; }
|
||||
|
||||
bool isHidden() const
|
||||
{ return _hidden; }
|
||||
{ return f._hidden; }
|
||||
|
||||
void setHidden(bool isHidden)
|
||||
{ _hidden = isHidden; }
|
||||
{ f._hidden = isHidden; }
|
||||
|
||||
bool isFunctionLike() const
|
||||
{ return _functionLike; }
|
||||
{ return f._functionLike; }
|
||||
|
||||
void setFunctionLike(bool isFunctionLike)
|
||||
{ _functionLike = isFunctionLike; }
|
||||
{ f._functionLike = isFunctionLike; }
|
||||
|
||||
bool isVariadic() const
|
||||
{ return _variadic; }
|
||||
{ return f._variadic; }
|
||||
|
||||
void setVariadic(bool isVariadic)
|
||||
{ _variadic = isVariadic; }
|
||||
{ f._variadic = isVariadic; }
|
||||
|
||||
QString toString() const;
|
||||
|
||||
@@ -117,6 +117,13 @@ public:
|
||||
unsigned _hashcode;
|
||||
|
||||
private:
|
||||
struct Flags
|
||||
{
|
||||
unsigned _hidden: 1;
|
||||
unsigned _functionLike: 1;
|
||||
unsigned _variadic: 1;
|
||||
};
|
||||
|
||||
QByteArray _name;
|
||||
QByteArray _definition;
|
||||
QVector<QByteArray> _formals;
|
||||
@@ -126,13 +133,7 @@ private:
|
||||
union
|
||||
{
|
||||
unsigned _state;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned _hidden: 1;
|
||||
unsigned _functionLike: 1;
|
||||
unsigned _variadic: 1;
|
||||
};
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -129,14 +129,14 @@ QList<SimpleToken> SimpleLexer::operator()(const QString &text, int state)
|
||||
break;
|
||||
|
||||
SimpleToken simpleTk;
|
||||
simpleTk._kind = int(tk.kind);
|
||||
simpleTk._kind = int(tk.f.kind);
|
||||
simpleTk._position = int(lex.tokenOffset());
|
||||
simpleTk._length = int(lex.tokenLength());
|
||||
simpleTk._text = text.midRef(simpleTk._position, simpleTk._length);
|
||||
|
||||
lex.setScanAngleStringLiteralTokens(false);
|
||||
|
||||
if (tk.newline && tk.is(T_POUND))
|
||||
if (tk.f.newline && tk.is(T_POUND))
|
||||
inPreproc = true;
|
||||
else if (inPreproc && tokens.size() == 1 && simpleTk.is(T_IDENTIFIER) &&
|
||||
simpleTk.text() == QLatin1String("include"))
|
||||
|
@@ -64,7 +64,7 @@ struct Value
|
||||
{
|
||||
enum Kind {
|
||||
Kind_Long,
|
||||
Kind_ULong,
|
||||
Kind_ULong
|
||||
};
|
||||
|
||||
Kind kind;
|
||||
@@ -231,7 +231,7 @@ protected:
|
||||
QByteArray tokenSpell() const
|
||||
{
|
||||
const QByteArray text = QByteArray::fromRawData(source.constData() + (*_lex)->offset,
|
||||
(*_lex)->length);
|
||||
(*_lex)->f.length);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ void Preprocessor::processSkippingBlocks(bool skippingBlocks,
|
||||
unsigned offset = start->offset;
|
||||
|
||||
if (_skipping[iflevel]) {
|
||||
if (_dot->newline)
|
||||
if (_dot->f.newline)
|
||||
++offset;
|
||||
|
||||
client->startSkippingBlocks(offset);
|
||||
@@ -751,7 +751,7 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
|
||||
|
||||
while (true) {
|
||||
|
||||
if (_dot->joined)
|
||||
if (_dot->f.joined)
|
||||
out("\\");
|
||||
|
||||
processNewline();
|
||||
@@ -759,13 +759,13 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
|
||||
if (_dot->is(T_EOF_SYMBOL)) {
|
||||
break;
|
||||
|
||||
} else if (_dot->is(T_POUND) && (! _dot->joined && _dot->newline)) {
|
||||
} else if (_dot->is(T_POUND) && (! _dot->f.joined && _dot->f.newline)) {
|
||||
// handle the preprocessor directive
|
||||
|
||||
TokenIterator start = _dot;
|
||||
do {
|
||||
++_dot;
|
||||
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->joined || ! _dot->newline));
|
||||
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->f.joined || ! _dot->f.newline));
|
||||
|
||||
const bool skippingBlocks = _skipping[iflevel];
|
||||
|
||||
@@ -777,11 +777,11 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
|
||||
|
||||
do {
|
||||
++_dot;
|
||||
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->joined || ! _dot->newline));
|
||||
} while (_dot->isNot(T_EOF_SYMBOL) && (_dot->f.joined || ! _dot->f.newline));
|
||||
|
||||
} else {
|
||||
|
||||
if (_dot->whitespace) {
|
||||
if (_dot->f.whitespace) {
|
||||
unsigned endOfPreviousToken = 0;
|
||||
|
||||
if (_dot != _tokens.constBegin())
|
||||
@@ -1027,14 +1027,14 @@ const char *Preprocessor::endOfToken(const Token &token) const
|
||||
QByteArray Preprocessor::tokenSpell(const Token &token) const
|
||||
{
|
||||
const QByteArray text = QByteArray::fromRawData(_source.constBegin() + token.offset,
|
||||
token.length);
|
||||
token.f.length);
|
||||
return text;
|
||||
}
|
||||
|
||||
QByteArray Preprocessor::tokenText(const Token &token) const
|
||||
{
|
||||
const QByteArray text(_source.constBegin() + token.offset,
|
||||
token.length);
|
||||
token.f.length);
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -1179,7 +1179,7 @@ void Preprocessor::processDefine(TokenIterator firstToken, TokenIterator lastTok
|
||||
macro.setName(tokenText(*tk));
|
||||
++tk; // skip T_IDENTIFIER
|
||||
|
||||
if (tk->is(T_LPAREN) && ! tk->whitespace) {
|
||||
if (tk->is(T_LPAREN) && ! tk->f.whitespace) {
|
||||
// a function-like macro definition
|
||||
macro.setFunctionLike(true);
|
||||
|
||||
|
@@ -211,7 +211,7 @@ protected:
|
||||
unsigned line, col;
|
||||
getTokenStartPosition(index, &line, &col);
|
||||
QTextCursor tc = _textCursor;
|
||||
tc.setPosition(tc.document()->findBlockByNumber(line - 1).position() + col + tk.length - 1);
|
||||
tc.setPosition(tc.document()->findBlockByNumber(line - 1).position() + col + tk.f.length - 1);
|
||||
return tc;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ QTextCursor QuickFixOperation::cursor(unsigned index) const
|
||||
getTokenStartPosition(index, &line, &col);
|
||||
QTextCursor tc = _textCursor;
|
||||
tc.setPosition(tc.document()->findBlockByNumber(line - 1).position() + col - 1);
|
||||
tc.setPosition(tc.position() + tk.length, QTextCursor::KeepAnchor);
|
||||
tc.setPosition(tc.position() + tk.f.length, QTextCursor::KeepAnchor);
|
||||
return tc;
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ QTextCursor QuickFixOperation::moveAtEndOfToken(unsigned index) const
|
||||
unsigned line, col;
|
||||
getTokenStartPosition(index, &line, &col);
|
||||
QTextCursor tc = _textCursor;
|
||||
tc.setPosition(tc.document()->findBlockByNumber(line - 1).position() + col + tk.length - 1);
|
||||
tc.setPosition(tc.document()->findBlockByNumber(line - 1).position() + col + tk.f.length - 1);
|
||||
return tc;
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ public:
|
||||
for (int index = 0; index <= _segmentCount; ++index) {
|
||||
delete[] (_segments[index] + (index << SEGMENT_SHIFT));
|
||||
}
|
||||
free(_segments);
|
||||
std::free(_segments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
if (++_count == _allocatedElements) {
|
||||
if (++_segmentCount == _allocatedSegments) {
|
||||
_allocatedSegments += 4;
|
||||
_segments = (_Tp **) realloc(_segments, _allocatedSegments * sizeof(_Tp *));
|
||||
_segments = (_Tp **) std::realloc(_segments, _allocatedSegments * sizeof(_Tp *));
|
||||
}
|
||||
|
||||
_Tp *segment = new _Tp[SEGMENT_SIZE];
|
||||
|
@@ -50,7 +50,7 @@
|
||||
#define CPLUSPLUS_DIAGNOSTICCLIENT_H
|
||||
|
||||
#include "CPlusPlusForwardDeclarations.h"
|
||||
#include <cstdarg>
|
||||
#include "stdarg.h"
|
||||
|
||||
CPLUSPLUS_BEGIN_HEADER
|
||||
CPLUSPLUS_BEGIN_NAMESPACE
|
||||
|
@@ -84,82 +84,82 @@ FullySpecifiedType FullySpecifiedType::qualifiedType() const
|
||||
}
|
||||
|
||||
bool FullySpecifiedType::isConst() const
|
||||
{ return _isConst; }
|
||||
{ return f._isConst; }
|
||||
|
||||
void FullySpecifiedType::setConst(bool isConst)
|
||||
{ _isConst = isConst; }
|
||||
{ f._isConst = isConst; }
|
||||
|
||||
bool FullySpecifiedType::isVolatile() const
|
||||
{ return _isVolatile; }
|
||||
{ return f._isVolatile; }
|
||||
|
||||
void FullySpecifiedType::setVolatile(bool isVolatile)
|
||||
{ _isVolatile = isVolatile; }
|
||||
{ f._isVolatile = isVolatile; }
|
||||
|
||||
bool FullySpecifiedType::isSigned() const
|
||||
{ return _isSigned; }
|
||||
{ return f._isSigned; }
|
||||
|
||||
void FullySpecifiedType::setSigned(bool isSigned)
|
||||
{ _isSigned = isSigned; }
|
||||
{ f._isSigned = isSigned; }
|
||||
|
||||
bool FullySpecifiedType::isUnsigned() const
|
||||
{ return _isUnsigned; }
|
||||
{ return f._isUnsigned; }
|
||||
|
||||
void FullySpecifiedType::setUnsigned(bool isUnsigned)
|
||||
{ _isUnsigned = isUnsigned; }
|
||||
{ f._isUnsigned = isUnsigned; }
|
||||
|
||||
bool FullySpecifiedType::isFriend() const
|
||||
{ return _isFriend; }
|
||||
{ return f._isFriend; }
|
||||
|
||||
void FullySpecifiedType::setFriend(bool isFriend)
|
||||
{ _isFriend = isFriend; }
|
||||
{ f._isFriend = isFriend; }
|
||||
|
||||
bool FullySpecifiedType::isRegister() const
|
||||
{ return _isRegister; }
|
||||
{ return f._isRegister; }
|
||||
|
||||
void FullySpecifiedType::setRegister(bool isRegister)
|
||||
{ _isRegister = isRegister; }
|
||||
{ f._isRegister = isRegister; }
|
||||
|
||||
bool FullySpecifiedType::isStatic() const
|
||||
{ return _isStatic; }
|
||||
{ return f._isStatic; }
|
||||
|
||||
void FullySpecifiedType::setStatic(bool isStatic)
|
||||
{ _isStatic = isStatic; }
|
||||
{ f._isStatic = isStatic; }
|
||||
|
||||
bool FullySpecifiedType::isExtern() const
|
||||
{ return _isExtern; }
|
||||
{ return f._isExtern; }
|
||||
|
||||
void FullySpecifiedType::setExtern(bool isExtern)
|
||||
{ _isExtern = isExtern; }
|
||||
{ f._isExtern = isExtern; }
|
||||
|
||||
bool FullySpecifiedType::isMutable() const
|
||||
{ return _isMutable; }
|
||||
{ return f._isMutable; }
|
||||
|
||||
void FullySpecifiedType::setMutable(bool isMutable)
|
||||
{ _isMutable = isMutable; }
|
||||
{ f._isMutable = isMutable; }
|
||||
|
||||
bool FullySpecifiedType::isTypedef() const
|
||||
{ return _isTypedef; }
|
||||
{ return f._isTypedef; }
|
||||
|
||||
void FullySpecifiedType::setTypedef(bool isTypedef)
|
||||
{ _isTypedef = isTypedef; }
|
||||
{ f._isTypedef = isTypedef; }
|
||||
|
||||
bool FullySpecifiedType::isInline() const
|
||||
{ return _isInline; }
|
||||
{ return f._isInline; }
|
||||
|
||||
void FullySpecifiedType::setInline(bool isInline)
|
||||
{ _isInline = isInline; }
|
||||
{ f._isInline = isInline; }
|
||||
|
||||
bool FullySpecifiedType::isVirtual() const
|
||||
{ return _isVirtual; }
|
||||
{ return f._isVirtual; }
|
||||
|
||||
void FullySpecifiedType::setVirtual(bool isVirtual)
|
||||
{ _isVirtual = isVirtual; }
|
||||
{ f._isVirtual = isVirtual; }
|
||||
|
||||
bool FullySpecifiedType::isExplicit() const
|
||||
{ return _isExplicit; }
|
||||
{ return f._isExplicit; }
|
||||
|
||||
void FullySpecifiedType::setExplicit(bool isExplicit)
|
||||
{ _isExplicit = isExplicit; }
|
||||
{ f._isExplicit = isExplicit; }
|
||||
|
||||
bool FullySpecifiedType::isEqualTo(const FullySpecifiedType &other) const
|
||||
{
|
||||
|
@@ -121,30 +121,31 @@ public:
|
||||
|
||||
private:
|
||||
Type *_type;
|
||||
struct Flags {
|
||||
// cv qualifiers
|
||||
unsigned _isConst: 1;
|
||||
unsigned _isVolatile: 1;
|
||||
|
||||
// sign
|
||||
unsigned _isSigned: 1;
|
||||
unsigned _isUnsigned: 1;
|
||||
|
||||
// storage class specifiers
|
||||
unsigned _isFriend: 1;
|
||||
unsigned _isRegister: 1;
|
||||
unsigned _isStatic: 1;
|
||||
unsigned _isExtern: 1;
|
||||
unsigned _isMutable: 1;
|
||||
unsigned _isTypedef: 1;
|
||||
|
||||
// function specifiers
|
||||
unsigned _isInline: 1;
|
||||
unsigned _isVirtual: 1;
|
||||
unsigned _isExplicit: 1;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
struct {
|
||||
// cv qualifiers
|
||||
unsigned _isConst: 1;
|
||||
unsigned _isVolatile: 1;
|
||||
|
||||
// sign
|
||||
unsigned _isSigned: 1;
|
||||
unsigned _isUnsigned: 1;
|
||||
|
||||
// storage class specifiers
|
||||
unsigned _isFriend: 1;
|
||||
unsigned _isRegister: 1;
|
||||
unsigned _isStatic: 1;
|
||||
unsigned _isExtern: 1;
|
||||
unsigned _isMutable: 1;
|
||||
unsigned _isTypedef: 1;
|
||||
|
||||
// function specifiers
|
||||
unsigned _isInline: 1;
|
||||
unsigned _isVirtual: 1;
|
||||
unsigned _isExplicit: 1;
|
||||
};
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -52,6 +52,8 @@
|
||||
#include <cctype>
|
||||
#include <cassert>
|
||||
|
||||
using namespace std;
|
||||
|
||||
CPLUSPLUS_BEGIN_NAMESPACE
|
||||
|
||||
Lexer::Lexer(TranslationUnit *unit)
|
||||
@@ -60,7 +62,7 @@ Lexer::Lexer(TranslationUnit *unit)
|
||||
_flags(0),
|
||||
_currentLine(1)
|
||||
{
|
||||
_scanKeywords = true;
|
||||
f._scanKeywords = true;
|
||||
setSource(_translationUnit->firstSourceChar(),
|
||||
_translationUnit->lastSourceChar());
|
||||
}
|
||||
@@ -71,7 +73,7 @@ Lexer::Lexer(const char *firstChar, const char *lastChar)
|
||||
_flags(0),
|
||||
_currentLine(1)
|
||||
{
|
||||
_scanKeywords = true;
|
||||
f._scanKeywords = true;
|
||||
setSource(firstChar, lastChar);
|
||||
}
|
||||
|
||||
@@ -113,37 +115,37 @@ void Lexer::setState(int state)
|
||||
{ _state = state; }
|
||||
|
||||
bool Lexer::qtMocRunEnabled() const
|
||||
{ return _qtMocRunEnabled; }
|
||||
{ return f._qtMocRunEnabled; }
|
||||
|
||||
void Lexer::setQtMocRunEnabled(bool onoff)
|
||||
{ _qtMocRunEnabled = onoff; }
|
||||
{ f._qtMocRunEnabled = onoff; }
|
||||
|
||||
bool Lexer::objCEnabled() const
|
||||
{ return _objCEnabled; }
|
||||
{ return f._objCEnabled; }
|
||||
|
||||
void Lexer::setObjCEnabled(bool onoff)
|
||||
{ _objCEnabled = onoff; }
|
||||
{ f._objCEnabled = onoff; }
|
||||
|
||||
bool Lexer::isIncremental() const
|
||||
{ return _isIncremental; }
|
||||
{ return f._isIncremental; }
|
||||
|
||||
void Lexer::setIncremental(bool isIncremental)
|
||||
{ _isIncremental = isIncremental; }
|
||||
{ f._isIncremental = isIncremental; }
|
||||
|
||||
bool Lexer::scanCommentTokens() const
|
||||
{ return _scanCommentTokens; }
|
||||
{ return f._scanCommentTokens; }
|
||||
|
||||
void Lexer::setScanCommentTokens(bool onoff)
|
||||
{ _scanCommentTokens = onoff; }
|
||||
{ f._scanCommentTokens = onoff; }
|
||||
|
||||
bool Lexer::scanKeywords() const
|
||||
{ return _scanKeywords; }
|
||||
{ return f._scanKeywords; }
|
||||
|
||||
void Lexer::setScanKeywords(bool onoff)
|
||||
{ _scanKeywords = onoff; }
|
||||
{ f._scanKeywords = onoff; }
|
||||
|
||||
void Lexer::setScanAngleStringLiteralTokens(bool onoff)
|
||||
{ _scanAngleStringLiteralTokens = onoff; }
|
||||
{ f._scanAngleStringLiteralTokens = onoff; }
|
||||
|
||||
void Lexer::pushLineStartOffset()
|
||||
{
|
||||
@@ -172,7 +174,7 @@ void Lexer::scan(Token *tok)
|
||||
{
|
||||
tok->reset();
|
||||
scan_helper(tok);
|
||||
tok->length = _currentChar - _tokenStart;
|
||||
tok->f.length = _currentChar - _tokenStart;
|
||||
}
|
||||
|
||||
void Lexer::scan_helper(Token *tok)
|
||||
@@ -180,9 +182,9 @@ void Lexer::scan_helper(Token *tok)
|
||||
_Lagain:
|
||||
while (_yychar && std::isspace(_yychar)) {
|
||||
if (_yychar == '\n')
|
||||
tok->newline = true;
|
||||
tok->f.newline = true;
|
||||
else
|
||||
tok->whitespace = true;
|
||||
tok->f.whitespace = true;
|
||||
yyinp();
|
||||
}
|
||||
|
||||
@@ -196,7 +198,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
const int originalState = _state;
|
||||
|
||||
if (! _yychar) {
|
||||
tok->kind = T_EOF_SYMBOL;
|
||||
tok->f.kind = T_EOF_SYMBOL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -213,18 +215,18 @@ void Lexer::scan_helper(Token *tok)
|
||||
}
|
||||
}
|
||||
|
||||
if (! _scanCommentTokens)
|
||||
if (! f._scanCommentTokens)
|
||||
goto _Lagain;
|
||||
|
||||
else if (originalState == State_MultiLineComment)
|
||||
tok->kind = T_COMMENT;
|
||||
tok->f.kind = T_COMMENT;
|
||||
else
|
||||
tok->kind = T_DOXY_COMMENT;
|
||||
tok->f.kind = T_DOXY_COMMENT;
|
||||
return; // done
|
||||
}
|
||||
|
||||
if (! _yychar) {
|
||||
tok->kind = T_EOF_SYMBOL;
|
||||
tok->f.kind = T_EOF_SYMBOL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -237,8 +239,8 @@ void Lexer::scan_helper(Token *tok)
|
||||
yyinp();
|
||||
// ### assert(! _yychar || _yychar == '\n');
|
||||
if (_yychar == '\n') {
|
||||
tok->joined = true;
|
||||
tok->newline = false;
|
||||
tok->f.joined = true;
|
||||
tok->f.newline = false;
|
||||
yyinp();
|
||||
}
|
||||
goto _Lagain;
|
||||
@@ -246,7 +248,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
case '"': case '\'': {
|
||||
const char quote = ch;
|
||||
|
||||
tok->kind = quote == '"'
|
||||
tok->f.kind = quote == '"'
|
||||
? T_STRING_LITERAL
|
||||
: T_CHAR_LITERAL;
|
||||
|
||||
@@ -274,63 +276,63 @@ void Lexer::scan_helper(Token *tok)
|
||||
} break;
|
||||
|
||||
case '{':
|
||||
tok->kind = T_LBRACE;
|
||||
tok->f.kind = T_LBRACE;
|
||||
break;
|
||||
|
||||
case '}':
|
||||
tok->kind = T_RBRACE;
|
||||
tok->f.kind = T_RBRACE;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
tok->kind = T_LBRACKET;
|
||||
tok->f.kind = T_LBRACKET;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
tok->kind = T_RBRACKET;
|
||||
tok->f.kind = T_RBRACKET;
|
||||
break;
|
||||
|
||||
case '#':
|
||||
if (_yychar == '#') {
|
||||
tok->kind = T_POUND_POUND;
|
||||
tok->f.kind = T_POUND_POUND;
|
||||
yyinp();
|
||||
} else {
|
||||
tok->kind = T_POUND;
|
||||
tok->f.kind = T_POUND;
|
||||
}
|
||||
break;
|
||||
|
||||
case '(':
|
||||
tok->kind = T_LPAREN;
|
||||
tok->f.kind = T_LPAREN;
|
||||
break;
|
||||
|
||||
case ')':
|
||||
tok->kind = T_RPAREN;
|
||||
tok->f.kind = T_RPAREN;
|
||||
break;
|
||||
|
||||
case ';':
|
||||
tok->kind = T_SEMICOLON;
|
||||
tok->f.kind = T_SEMICOLON;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
if (_yychar == ':') {
|
||||
yyinp();
|
||||
tok->kind = T_COLON_COLON;
|
||||
tok->f.kind = T_COLON_COLON;
|
||||
} else {
|
||||
tok->kind = T_COLON;
|
||||
tok->f.kind = T_COLON;
|
||||
}
|
||||
break;
|
||||
|
||||
case '.':
|
||||
if (_yychar == '*') {
|
||||
yyinp();
|
||||
tok->kind = T_DOT_STAR;
|
||||
tok->f.kind = T_DOT_STAR;
|
||||
} else if (_yychar == '.') {
|
||||
yyinp();
|
||||
// ### assert(_yychar);
|
||||
if (_yychar == '.') {
|
||||
yyinp();
|
||||
tok->kind = T_DOT_DOT_DOT;
|
||||
tok->f.kind = T_DOT_DOT_DOT;
|
||||
} else {
|
||||
tok->kind = T_ERROR;
|
||||
tok->f.kind = T_ERROR;
|
||||
}
|
||||
} else if (std::isdigit(_yychar)) {
|
||||
const char *yytext = _currentChar - 2;
|
||||
@@ -348,56 +350,56 @@ void Lexer::scan_helper(Token *tok)
|
||||
}
|
||||
} while (_yychar);
|
||||
int yylen = _currentChar - yytext;
|
||||
tok->kind = T_NUMERIC_LITERAL;
|
||||
tok->f.kind = T_NUMERIC_LITERAL;
|
||||
if (control())
|
||||
tok->number = control()->findOrInsertNumericLiteral(yytext, yylen);
|
||||
} else {
|
||||
tok->kind = T_DOT;
|
||||
tok->f.kind = T_DOT;
|
||||
}
|
||||
break;
|
||||
|
||||
case '?':
|
||||
tok->kind = T_QUESTION;
|
||||
tok->f.kind = T_QUESTION;
|
||||
break;
|
||||
|
||||
case '+':
|
||||
if (_yychar == '+') {
|
||||
yyinp();
|
||||
tok->kind = T_PLUS_PLUS;
|
||||
tok->f.kind = T_PLUS_PLUS;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_PLUS_EQUAL;
|
||||
tok->f.kind = T_PLUS_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_PLUS;
|
||||
tok->f.kind = T_PLUS;
|
||||
}
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (_yychar == '-') {
|
||||
yyinp();
|
||||
tok->kind = T_MINUS_MINUS;
|
||||
tok->f.kind = T_MINUS_MINUS;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_MINUS_EQUAL;
|
||||
tok->f.kind = T_MINUS_EQUAL;
|
||||
} else if (_yychar == '>') {
|
||||
yyinp();
|
||||
if (_yychar == '*') {
|
||||
yyinp();
|
||||
tok->kind = T_ARROW_STAR;
|
||||
tok->f.kind = T_ARROW_STAR;
|
||||
} else {
|
||||
tok->kind = T_ARROW;
|
||||
tok->f.kind = T_ARROW;
|
||||
}
|
||||
} else {
|
||||
tok->kind = T_MINUS;
|
||||
tok->f.kind = T_MINUS;
|
||||
}
|
||||
break;
|
||||
|
||||
case '*':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_STAR_EQUAL;
|
||||
tok->f.kind = T_STAR_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_STAR;
|
||||
tok->f.kind = T_STAR;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -420,10 +422,10 @@ void Lexer::scan_helper(Token *tok)
|
||||
while (_yychar && _yychar != '\n')
|
||||
yyinp();
|
||||
|
||||
if (! _scanCommentTokens)
|
||||
if (! f._scanCommentTokens)
|
||||
goto _Lagain;
|
||||
|
||||
tok->kind = doxy ? T_DOXY_COMMENT : T_COMMENT;
|
||||
tok->f.kind = doxy ? T_DOXY_COMMENT : T_COMMENT;
|
||||
|
||||
} else if (_yychar == '*') {
|
||||
yyinp();
|
||||
@@ -461,90 +463,90 @@ void Lexer::scan_helper(Token *tok)
|
||||
else
|
||||
_state = doxy ? State_MultiLineDoxyComment : State_MultiLineComment;
|
||||
|
||||
if (! _scanCommentTokens)
|
||||
if (! f._scanCommentTokens)
|
||||
goto _Lagain;
|
||||
|
||||
tok->kind = doxy ? T_DOXY_COMMENT : T_COMMENT;
|
||||
tok->f.kind = doxy ? T_DOXY_COMMENT : T_COMMENT;
|
||||
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_SLASH_EQUAL;
|
||||
tok->f.kind = T_SLASH_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_SLASH;
|
||||
tok->f.kind = T_SLASH;
|
||||
}
|
||||
break;
|
||||
|
||||
case '%':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_PERCENT_EQUAL;
|
||||
tok->f.kind = T_PERCENT_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_PERCENT;
|
||||
tok->f.kind = T_PERCENT;
|
||||
}
|
||||
break;
|
||||
|
||||
case '^':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_CARET_EQUAL;
|
||||
tok->f.kind = T_CARET_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_CARET;
|
||||
tok->f.kind = T_CARET;
|
||||
}
|
||||
break;
|
||||
|
||||
case '&':
|
||||
if (_yychar == '&') {
|
||||
yyinp();
|
||||
tok->kind = T_AMPER_AMPER;
|
||||
tok->f.kind = T_AMPER_AMPER;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_AMPER_EQUAL;
|
||||
tok->f.kind = T_AMPER_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_AMPER;
|
||||
tok->f.kind = T_AMPER;
|
||||
}
|
||||
break;
|
||||
|
||||
case '|':
|
||||
if (_yychar == '|') {
|
||||
yyinp();
|
||||
tok->kind = T_PIPE_PIPE;
|
||||
tok->f.kind = T_PIPE_PIPE;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_PIPE_EQUAL;
|
||||
tok->f.kind = T_PIPE_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_PIPE;
|
||||
tok->f.kind = T_PIPE;
|
||||
}
|
||||
break;
|
||||
|
||||
case '~':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_TILDE_EQUAL;
|
||||
tok->f.kind = T_TILDE_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_TILDE;
|
||||
tok->f.kind = T_TILDE;
|
||||
}
|
||||
break;
|
||||
|
||||
case '!':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_EXCLAIM_EQUAL;
|
||||
tok->f.kind = T_EXCLAIM_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_EXCLAIM;
|
||||
tok->f.kind = T_EXCLAIM;
|
||||
}
|
||||
break;
|
||||
|
||||
case '=':
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_EQUAL_EQUAL;
|
||||
tok->f.kind = T_EQUAL_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_EQUAL;
|
||||
tok->f.kind = T_EQUAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case '<':
|
||||
if (_scanAngleStringLiteralTokens) {
|
||||
if (f._scanAngleStringLiteralTokens) {
|
||||
const char *yytext = _currentChar;
|
||||
while (_yychar && _yychar != '>')
|
||||
yyinp();
|
||||
@@ -554,19 +556,19 @@ void Lexer::scan_helper(Token *tok)
|
||||
yyinp();
|
||||
if (control())
|
||||
tok->string = control()->findOrInsertStringLiteral(yytext, yylen);
|
||||
tok->kind = T_ANGLE_STRING_LITERAL;
|
||||
tok->f.kind = T_ANGLE_STRING_LITERAL;
|
||||
} else if (_yychar == '<') {
|
||||
yyinp();
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_LESS_LESS_EQUAL;
|
||||
tok->f.kind = T_LESS_LESS_EQUAL;
|
||||
} else
|
||||
tok->kind = T_LESS_LESS;
|
||||
tok->f.kind = T_LESS_LESS;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_LESS_EQUAL;
|
||||
tok->f.kind = T_LESS_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_LESS;
|
||||
tok->f.kind = T_LESS;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -575,24 +577,24 @@ void Lexer::scan_helper(Token *tok)
|
||||
yyinp();
|
||||
if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_GREATER_GREATER_EQUAL;
|
||||
tok->f.kind = T_GREATER_GREATER_EQUAL;
|
||||
} else
|
||||
tok->kind = T_LESS_LESS;
|
||||
tok->kind = T_GREATER_GREATER;
|
||||
tok->f.kind = T_LESS_LESS;
|
||||
tok->f.kind = T_GREATER_GREATER;
|
||||
} else if (_yychar == '=') {
|
||||
yyinp();
|
||||
tok->kind = T_GREATER_EQUAL;
|
||||
tok->f.kind = T_GREATER_EQUAL;
|
||||
} else {
|
||||
tok->kind = T_GREATER;
|
||||
tok->f.kind = T_GREATER;
|
||||
}
|
||||
break;
|
||||
|
||||
case ',':
|
||||
tok->kind = T_COMMA;
|
||||
tok->f.kind = T_COMMA;
|
||||
break;
|
||||
|
||||
default: {
|
||||
if (_objCEnabled) {
|
||||
if (f._objCEnabled) {
|
||||
if (ch == '@' && _yychar >= 'a' && _yychar <= 'z') {
|
||||
const char *yytext = _currentChar;
|
||||
|
||||
@@ -603,13 +605,13 @@ void Lexer::scan_helper(Token *tok)
|
||||
} while (_yychar);
|
||||
|
||||
const int yylen = _currentChar - yytext;
|
||||
tok->kind = classifyObjCAtKeyword(yytext, yylen);
|
||||
tok->f.kind = classifyObjCAtKeyword(yytext, yylen);
|
||||
break;
|
||||
} else if (ch == '@' && _yychar == '"') {
|
||||
// objc @string literals
|
||||
ch = _yychar;
|
||||
yyinp();
|
||||
tok->kind = T_AT_STRING_LITERAL;
|
||||
tok->f.kind = T_AT_STRING_LITERAL;
|
||||
|
||||
const char *yytext = _currentChar;
|
||||
|
||||
@@ -644,7 +646,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
|
||||
const char quote = ch;
|
||||
|
||||
tok->kind = quote == '"'
|
||||
tok->f.kind = quote == '"'
|
||||
? T_WIDE_STRING_LITERAL
|
||||
: T_WIDE_CHAR_LITERAL;
|
||||
|
||||
@@ -674,13 +676,13 @@ void Lexer::scan_helper(Token *tok)
|
||||
while (std::isalnum(_yychar) || _yychar == '_')
|
||||
yyinp();
|
||||
int yylen = _currentChar - yytext;
|
||||
if (_scanKeywords)
|
||||
tok->kind = classify(yytext, yylen, _qtMocRunEnabled);
|
||||
if (f._scanKeywords)
|
||||
tok->f.kind = classify(yytext, yylen, f._qtMocRunEnabled);
|
||||
else
|
||||
tok->kind = T_IDENTIFIER;
|
||||
tok->f.kind = T_IDENTIFIER;
|
||||
|
||||
if (tok->kind == T_IDENTIFIER) {
|
||||
tok->kind = classifyOperator(yytext, yylen);
|
||||
if (tok->f.kind == T_IDENTIFIER) {
|
||||
tok->f.kind = classifyOperator(yytext, yylen);
|
||||
|
||||
if (control())
|
||||
tok->identifier = control()->findOrInsertIdentifier(yytext, yylen);
|
||||
@@ -702,12 +704,12 @@ void Lexer::scan_helper(Token *tok)
|
||||
}
|
||||
}
|
||||
int yylen = _currentChar - yytext;
|
||||
tok->kind = T_NUMERIC_LITERAL;
|
||||
tok->f.kind = T_NUMERIC_LITERAL;
|
||||
if (control())
|
||||
tok->number = control()->findOrInsertNumericLiteral(yytext, yylen);
|
||||
break;
|
||||
} else {
|
||||
tok->kind = T_ERROR;
|
||||
tok->f.kind = T_ERROR;
|
||||
break;
|
||||
}
|
||||
} // default
|
||||
|
@@ -129,6 +129,15 @@ private:
|
||||
void pushLineStartOffset();
|
||||
|
||||
private:
|
||||
struct Flags {
|
||||
unsigned _isIncremental: 1;
|
||||
unsigned _scanCommentTokens: 1;
|
||||
unsigned _scanKeywords: 1;
|
||||
unsigned _scanAngleStringLiteralTokens: 1;
|
||||
unsigned _qtMocRunEnabled: 1;
|
||||
unsigned _objCEnabled: 1;
|
||||
};
|
||||
|
||||
TranslationUnit *_translationUnit;
|
||||
const char *_firstChar;
|
||||
const char *_currentChar;
|
||||
@@ -138,14 +147,7 @@ private:
|
||||
int _state;
|
||||
union {
|
||||
unsigned _flags;
|
||||
struct {
|
||||
unsigned _isIncremental: 1;
|
||||
unsigned _scanCommentTokens: 1;
|
||||
unsigned _scanKeywords: 1;
|
||||
unsigned _scanAngleStringLiteralTokens: 1;
|
||||
unsigned _qtMocRunEnabled: 1;
|
||||
unsigned _objCEnabled: 1;
|
||||
};
|
||||
Flags f;
|
||||
};
|
||||
unsigned _currentLine;
|
||||
};
|
||||
|
@@ -80,10 +80,10 @@ public:
|
||||
_Literal **lastLiteral = _literals + _literalCount + 1;
|
||||
for (_Literal **it = _literals; it != lastLiteral; ++it)
|
||||
delete *it;
|
||||
free(_literals);
|
||||
std::free(_literals);
|
||||
}
|
||||
if (_buckets)
|
||||
free(_buckets);
|
||||
std::free(_buckets);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
unsigned h = _Literal::hashCode(chars, size);
|
||||
_Literal *literal = _buckets[h % _allocatedBuckets];
|
||||
for (; literal; literal = static_cast<_Literal *>(literal->_next)) {
|
||||
if (literal->size() == size && ! strncmp(literal->chars(), chars, size))
|
||||
if (literal->size() == size && ! std::strncmp(literal->chars(), chars, size))
|
||||
return literal;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
if (! _allocatedLiterals)
|
||||
_allocatedLiterals = 256;
|
||||
|
||||
_literals = (_Literal **) realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
||||
_literals = (_Literal **) std::realloc(_literals, sizeof(_Literal *) * _allocatedLiterals);
|
||||
}
|
||||
|
||||
_literals[_literalCount] = literal;
|
||||
@@ -140,14 +140,14 @@ protected:
|
||||
void rehash()
|
||||
{
|
||||
if (_buckets)
|
||||
free(_buckets);
|
||||
std::free(_buckets);
|
||||
|
||||
_allocatedBuckets <<= 1;
|
||||
|
||||
if (! _allocatedBuckets)
|
||||
_allocatedBuckets = 256;
|
||||
|
||||
_buckets = (_Literal **) calloc(_allocatedBuckets, sizeof(_Literal *));
|
||||
_buckets = (_Literal **) std::calloc(_allocatedBuckets, sizeof(_Literal *));
|
||||
|
||||
_Literal **lastLiteral = _literals + (_literalCount + 1);
|
||||
|
||||
|
@@ -51,6 +51,8 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
CPLUSPLUS_BEGIN_NAMESPACE
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -113,20 +115,20 @@ enum {
|
||||
NumericLiteralIsDouble,
|
||||
NumericLiteralIsLongDouble,
|
||||
NumericLiteralIsLong,
|
||||
NumericLiteralIsLongLong,
|
||||
NumericLiteralIsLongLong
|
||||
};
|
||||
|
||||
NumericLiteral::NumericLiteral(const char *chars, unsigned size)
|
||||
: Literal(chars, size), _flags(0)
|
||||
{
|
||||
_type = NumericLiteralIsInt;
|
||||
f._type = NumericLiteralIsInt;
|
||||
|
||||
if (chars[0] == '\'') {
|
||||
_type = NumericLiteralIsChar;
|
||||
f._type = NumericLiteralIsChar;
|
||||
} else if (size > 1 && chars[0] == 'L' && chars[1] == '\'') {
|
||||
_type = NumericLiteralIsWideChar;
|
||||
f._type = NumericLiteralIsWideChar;
|
||||
} else if (size > 1 && chars[0] == '0' && (chars[1] == 'x' || chars[1] == 'X')) {
|
||||
_isHex = true;
|
||||
f._isHex = true;
|
||||
} else {
|
||||
const char *begin = chars;
|
||||
const char *end = begin + size;
|
||||
@@ -149,23 +151,23 @@ NumericLiteral::NumericLiteral(const char *chars, unsigned size)
|
||||
|
||||
for (const char *dot = it; it != begin - 1; --it) {
|
||||
if (*dot == '.')
|
||||
_type = NumericLiteralIsDouble;
|
||||
f._type = NumericLiteralIsDouble;
|
||||
}
|
||||
|
||||
for (++it; it != end; ++it) {
|
||||
if (*it == 'l' || *it == 'L') {
|
||||
if (_type == NumericLiteralIsDouble) {
|
||||
_type = NumericLiteralIsLongDouble;
|
||||
if (f._type == NumericLiteralIsDouble) {
|
||||
f._type = NumericLiteralIsLongDouble;
|
||||
} else if (it + 1 != end && (it[1] == 'l' || it[1] == 'L')) {
|
||||
++it;
|
||||
_type = NumericLiteralIsLongLong;
|
||||
f._type = NumericLiteralIsLongLong;
|
||||
} else {
|
||||
_type = NumericLiteralIsLong;
|
||||
f._type = NumericLiteralIsLong;
|
||||
}
|
||||
} else if (*it == 'f' || *it == 'F') {
|
||||
_type = NumericLiteralIsFloat;
|
||||
f._type = NumericLiteralIsFloat;
|
||||
} else if (*it == 'u' || *it == 'U') {
|
||||
_isUnsigned = true;
|
||||
f._isUnsigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,34 +177,34 @@ NumericLiteral::~NumericLiteral()
|
||||
{ }
|
||||
|
||||
bool NumericLiteral::isHex() const
|
||||
{ return _isHex; }
|
||||
{ return f._isHex; }
|
||||
|
||||
bool NumericLiteral::isUnsigned() const
|
||||
{ return _isUnsigned; }
|
||||
{ return f._isUnsigned; }
|
||||
|
||||
bool NumericLiteral::isChar() const
|
||||
{ return _type == NumericLiteralIsChar; }
|
||||
{ return f._type == NumericLiteralIsChar; }
|
||||
|
||||
bool NumericLiteral::isWideChar() const
|
||||
{ return _type == NumericLiteralIsWideChar; }
|
||||
{ return f._type == NumericLiteralIsWideChar; }
|
||||
|
||||
bool NumericLiteral::isInt() const
|
||||
{ return _type == NumericLiteralIsInt; }
|
||||
{ return f._type == NumericLiteralIsInt; }
|
||||
|
||||
bool NumericLiteral::isFloat() const
|
||||
{ return _type == NumericLiteralIsFloat; }
|
||||
{ return f._type == NumericLiteralIsFloat; }
|
||||
|
||||
bool NumericLiteral::isDouble() const
|
||||
{ return _type == NumericLiteralIsDouble; }
|
||||
{ return f._type == NumericLiteralIsDouble; }
|
||||
|
||||
bool NumericLiteral::isLongDouble() const
|
||||
{ return _type == NumericLiteralIsLongDouble; }
|
||||
{ return f._type == NumericLiteralIsLongDouble; }
|
||||
|
||||
bool NumericLiteral::isLong() const
|
||||
{ return _type == NumericLiteralIsLong; }
|
||||
{ return f._type == NumericLiteralIsLong; }
|
||||
|
||||
bool NumericLiteral::isLongLong() const
|
||||
{ return _type == NumericLiteralIsLongLong; }
|
||||
{ return f._type == NumericLiteralIsLongLong; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Identifier::Identifier(const char *chars, unsigned size)
|
||||
|
@@ -115,14 +115,14 @@ public:
|
||||
bool isHex() const;
|
||||
|
||||
private:
|
||||
struct Flags {
|
||||
unsigned _type : 8;
|
||||
unsigned _isHex : 1;
|
||||
unsigned _isUnsigned: 1;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
|
||||
struct {
|
||||
unsigned _type : 8;
|
||||
unsigned _isHex : 1;
|
||||
unsigned _isUnsigned: 1;
|
||||
};
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -53,6 +53,8 @@
|
||||
|
||||
CPLUSPLUS_BEGIN_NAMESPACE
|
||||
|
||||
using namespace std;
|
||||
|
||||
MemoryPool::MemoryPool()
|
||||
: _initializeAllocatedMemory(true),
|
||||
_blocks(0),
|
||||
|
@@ -84,7 +84,7 @@ void PrettyPrinter::outToken(unsigned token)
|
||||
oss << ba.constData();
|
||||
|
||||
// Print the token itself
|
||||
QByteArray tt(_contents.constData() + t.begin(), t.length);
|
||||
QByteArray tt(_contents.constData() + t.begin(), t.f.length);
|
||||
oss << tt.constData();
|
||||
|
||||
QString stuff = QString::fromUtf8(oss.str().c_str());
|
||||
|
@@ -55,6 +55,8 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
CPLUSPLUS_BEGIN_NAMESPACE
|
||||
|
||||
Scope::Scope(ScopedSymbol *owner)
|
||||
|
@@ -219,7 +219,7 @@ void Symbol::setSourceLocation(unsigned sourceLocation)
|
||||
|
||||
const Token &tk = unit->tokenAt(sourceLocation);
|
||||
|
||||
_isGenerated = tk.generated;
|
||||
_isGenerated = tk.f.generated;
|
||||
_sourceOffset = tk.offset;
|
||||
}
|
||||
}
|
||||
|
@@ -152,19 +152,19 @@ Function::~Function()
|
||||
}
|
||||
|
||||
bool Function::isNormal() const
|
||||
{ return _methodKey == NormalMethod; }
|
||||
{ return f._methodKey == NormalMethod; }
|
||||
|
||||
bool Function::isSignal() const
|
||||
{ return _methodKey == SignalMethod; }
|
||||
{ return f._methodKey == SignalMethod; }
|
||||
|
||||
bool Function::isSlot() const
|
||||
{ return _methodKey == SlotMethod; }
|
||||
{ return f._methodKey == SlotMethod; }
|
||||
|
||||
int Function::methodKey() const
|
||||
{ return _methodKey; }
|
||||
{ return f._methodKey; }
|
||||
|
||||
void Function::setMethodKey(int key)
|
||||
{ _methodKey = key; }
|
||||
{ f._methodKey = key; }
|
||||
|
||||
unsigned Function::templateParameterCount() const
|
||||
{
|
||||
@@ -249,34 +249,34 @@ bool Function::hasArguments() const
|
||||
}
|
||||
|
||||
bool Function::isVariadic() const
|
||||
{ return _isVariadic; }
|
||||
{ return f._isVariadic; }
|
||||
|
||||
void Function::setVariadic(bool isVariadic)
|
||||
{ _isVariadic = isVariadic; }
|
||||
{ f._isVariadic = isVariadic; }
|
||||
|
||||
bool Function::isConst() const
|
||||
{ return _isConst; }
|
||||
{ return f._isConst; }
|
||||
|
||||
void Function::setConst(bool isConst)
|
||||
{ _isConst = isConst; }
|
||||
{ f._isConst = isConst; }
|
||||
|
||||
bool Function::isVolatile() const
|
||||
{ return _isVolatile; }
|
||||
{ return f._isVolatile; }
|
||||
|
||||
void Function::setVolatile(bool isVolatile)
|
||||
{ _isVolatile = isVolatile; }
|
||||
{ f._isVolatile = isVolatile; }
|
||||
|
||||
bool Function::isPureVirtual() const
|
||||
{ return _isPureVirtual; }
|
||||
{ return f._isPureVirtual; }
|
||||
|
||||
void Function::setPureVirtual(bool isPureVirtual)
|
||||
{ _isPureVirtual = isPureVirtual; }
|
||||
{ f._isPureVirtual = isPureVirtual; }
|
||||
|
||||
bool Function::isAmbiguous() const
|
||||
{ return _isAmbiguous; }
|
||||
{ return f._isAmbiguous; }
|
||||
|
||||
void Function::setAmbiguous(bool isAmbiguous)
|
||||
{ _isAmbiguous = isAmbiguous; }
|
||||
{ f._isAmbiguous = isAmbiguous; }
|
||||
|
||||
void Function::visitSymbol0(SymbolVisitor *visitor)
|
||||
{
|
||||
|
@@ -338,17 +338,17 @@ protected:
|
||||
private:
|
||||
Scope *_templateParameters;
|
||||
FullySpecifiedType _returnType;
|
||||
struct Flags {
|
||||
unsigned _isVariadic: 1;
|
||||
unsigned _isPureVirtual: 1;
|
||||
unsigned _isConst: 1;
|
||||
unsigned _isVolatile: 1;
|
||||
unsigned _isAmbiguous: 1;
|
||||
unsigned _methodKey: 3;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
|
||||
struct {
|
||||
unsigned _isVariadic: 1;
|
||||
unsigned _isPureVirtual: 1;
|
||||
unsigned _isConst: 1;
|
||||
unsigned _isVolatile: 1;
|
||||
unsigned _isAmbiguous: 1;
|
||||
unsigned _methodKey: 3;
|
||||
};
|
||||
Flags f;
|
||||
};
|
||||
Scope *_arguments;
|
||||
};
|
||||
|
@@ -114,7 +114,7 @@ const char *Token::name(int kind)
|
||||
|
||||
const char *Token::spell() const
|
||||
{
|
||||
switch (kind) {
|
||||
switch (f.kind) {
|
||||
case T_IDENTIFIER:
|
||||
return identifier->chars();
|
||||
|
||||
@@ -128,7 +128,7 @@ const char *Token::spell() const
|
||||
return literal->chars();
|
||||
|
||||
default:
|
||||
return token_names[kind];
|
||||
return token_names[f.kind];
|
||||
} // switch
|
||||
}
|
||||
|
||||
|
@@ -276,8 +276,8 @@ public:
|
||||
Token();
|
||||
~Token();
|
||||
|
||||
inline bool is(unsigned k) const { return kind == k; }
|
||||
inline bool isNot(unsigned k) const { return kind != k; }
|
||||
inline bool is(unsigned k) const { return f.kind == k; }
|
||||
inline bool isNot(unsigned k) const { return f.kind != k; }
|
||||
const char *spell() const;
|
||||
void reset();
|
||||
|
||||
@@ -285,39 +285,39 @@ public:
|
||||
{ return offset; }
|
||||
|
||||
inline unsigned end() const
|
||||
{ return offset + length; }
|
||||
{ return offset + f.length; }
|
||||
|
||||
inline bool isLiteral() const
|
||||
{ return kind >= T_FIRST_LITERAL && kind <= T_LAST_LITERAL; }
|
||||
{ return f.kind >= T_FIRST_LITERAL && f.kind <= T_LAST_LITERAL; }
|
||||
|
||||
inline bool isOperator() const
|
||||
{ return kind >= T_FIRST_OPERATOR && kind <= T_LAST_OPERATOR; }
|
||||
{ return f.kind >= T_FIRST_OPERATOR && f.kind <= T_LAST_OPERATOR; }
|
||||
|
||||
inline bool isKeyword() const
|
||||
{ return kind >= T_FIRST_KEYWORD && kind < T_FIRST_QT_KEYWORD; }
|
||||
{ return f.kind >= T_FIRST_KEYWORD && f.kind < T_FIRST_QT_KEYWORD; }
|
||||
|
||||
inline bool isComment() const
|
||||
{ return kind == T_COMMENT || kind == T_DOXY_COMMENT; }
|
||||
{ return f.kind == T_COMMENT || f.kind == T_DOXY_COMMENT; }
|
||||
|
||||
inline bool isObjCAtKeyword() const
|
||||
{ return kind >= T_FIRST_OBJC_AT_KEYWORD && kind <= T_LAST_OBJC_AT_KEYWORD; }
|
||||
{ return f.kind >= T_FIRST_OBJC_AT_KEYWORD && f.kind <= T_LAST_OBJC_AT_KEYWORD; }
|
||||
|
||||
static const char *name(int kind);
|
||||
|
||||
public:
|
||||
struct Flags {
|
||||
unsigned kind : 8;
|
||||
unsigned newline : 1;
|
||||
unsigned whitespace : 1;
|
||||
unsigned joined : 1;
|
||||
unsigned expanded : 1;
|
||||
unsigned generated : 1;
|
||||
unsigned pad : 3;
|
||||
unsigned length : 16;
|
||||
};
|
||||
union {
|
||||
unsigned flags;
|
||||
|
||||
struct {
|
||||
unsigned kind : 8;
|
||||
unsigned newline : 1;
|
||||
unsigned whitespace : 1;
|
||||
unsigned joined : 1;
|
||||
unsigned expanded : 1;
|
||||
unsigned generated : 1;
|
||||
unsigned pad : 3;
|
||||
unsigned length : 16;
|
||||
};
|
||||
Flags f;
|
||||
};
|
||||
|
||||
unsigned offset;
|
||||
|
@@ -59,6 +59,8 @@
|
||||
#include <cstdarg>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
CPLUSPLUS_BEGIN_NAMESPACE
|
||||
|
||||
TranslationUnit::TranslationUnit(Control *control, StringLiteral *fileId)
|
||||
@@ -83,16 +85,16 @@ TranslationUnit::~TranslationUnit()
|
||||
}
|
||||
|
||||
bool TranslationUnit::qtMocRunEnabled() const
|
||||
{ return _qtMocRunEnabled; }
|
||||
{ return f._qtMocRunEnabled; }
|
||||
|
||||
void TranslationUnit::setQtMocRunEnabled(bool onoff)
|
||||
{ _qtMocRunEnabled = onoff; }
|
||||
{ f._qtMocRunEnabled = onoff; }
|
||||
|
||||
bool TranslationUnit::objCEnabled() const
|
||||
{ return _objCEnabled; }
|
||||
{ return f._objCEnabled; }
|
||||
|
||||
void TranslationUnit::setObjCEnabled(bool onoff)
|
||||
{ _objCEnabled = onoff; }
|
||||
{ f._objCEnabled = onoff; }
|
||||
|
||||
Control *TranslationUnit::control() const
|
||||
{ return _control; }
|
||||
@@ -128,7 +130,7 @@ const Token &TranslationUnit::tokenAt(unsigned index) const
|
||||
{ return _tokens->at(index); }
|
||||
|
||||
int TranslationUnit::tokenKind(unsigned index) const
|
||||
{ return _tokens->at(index).kind; }
|
||||
{ return _tokens->at(index).f.kind; }
|
||||
|
||||
const char *TranslationUnit::spell(unsigned index) const
|
||||
{
|
||||
@@ -160,21 +162,21 @@ AST *TranslationUnit::ast() const
|
||||
{ return _ast; }
|
||||
|
||||
bool TranslationUnit::isTokenized() const
|
||||
{ return _tokenized; }
|
||||
{ return f._tokenized; }
|
||||
|
||||
bool TranslationUnit::isParsed() const
|
||||
{ return _parsed; }
|
||||
{ return f._parsed; }
|
||||
|
||||
void TranslationUnit::tokenize()
|
||||
{
|
||||
if (isTokenized())
|
||||
return;
|
||||
|
||||
_tokenized = true;
|
||||
f._tokenized = true;
|
||||
|
||||
Lexer lex(this);
|
||||
lex.setQtMocRunEnabled(_qtMocRunEnabled);
|
||||
lex.setObjCEnabled(_objCEnabled);
|
||||
lex.setQtMocRunEnabled(f._qtMocRunEnabled);
|
||||
lex.setObjCEnabled(f._objCEnabled);
|
||||
|
||||
std::stack<unsigned> braces;
|
||||
_tokens->push_back(Token()); // the first token needs to be invalid!
|
||||
@@ -195,23 +197,23 @@ void TranslationUnit::tokenize()
|
||||
unsigned offset = tk.offset;
|
||||
lex(&tk);
|
||||
|
||||
if (! tk.newline && tk.is(T_IDENTIFIER) && tk.identifier == genId) {
|
||||
if (! tk.f.newline && tk.is(T_IDENTIFIER) && tk.identifier == genId) {
|
||||
// it's a gen directive.
|
||||
lex(&tk);
|
||||
|
||||
if (! tk.newline && tk.is(T_TRUE)) {
|
||||
if (! tk.f.newline && tk.is(T_TRUE)) {
|
||||
lex(&tk);
|
||||
generated = true;
|
||||
} else {
|
||||
generated = false;
|
||||
}
|
||||
} else {
|
||||
if (! tk.newline && tk.is(T_IDENTIFIER) && tk.identifier == lineId)
|
||||
if (! tk.f.newline && tk.is(T_IDENTIFIER) && tk.identifier == lineId)
|
||||
lex(&tk);
|
||||
if (! tk.newline && tk.is(T_NUMERIC_LITERAL)) {
|
||||
if (! tk.f.newline && tk.is(T_NUMERIC_LITERAL)) {
|
||||
unsigned line = (unsigned) strtoul(tk.spell(), 0, 0);
|
||||
lex(&tk);
|
||||
if (! tk.newline && tk.is(T_STRING_LITERAL)) {
|
||||
if (! tk.f.newline && tk.is(T_STRING_LITERAL)) {
|
||||
StringLiteral *fileName = control()->findOrInsertStringLiteral(tk.string->chars(),
|
||||
tk.string->size());
|
||||
pushPreprocessorLine(offset, line, fileName);
|
||||
@@ -219,19 +221,19 @@ void TranslationUnit::tokenize()
|
||||
}
|
||||
}
|
||||
}
|
||||
while (tk.isNot(T_EOF_SYMBOL) && ! tk.newline)
|
||||
while (tk.isNot(T_EOF_SYMBOL) && ! tk.f.newline)
|
||||
lex(&tk);
|
||||
goto _Lrecognize;
|
||||
} else if (tk.kind == T_LBRACE) {
|
||||
} else if (tk.f.kind == T_LBRACE) {
|
||||
braces.push(_tokens->size());
|
||||
} else if (tk.kind == T_RBRACE && ! braces.empty()) {
|
||||
} else if (tk.f.kind == T_RBRACE && ! braces.empty()) {
|
||||
const unsigned open_brace_index = braces.top();
|
||||
braces.pop();
|
||||
(*_tokens)[open_brace_index].close_brace = _tokens->size();
|
||||
}
|
||||
tk.generated = generated;
|
||||
tk.f.generated = generated;
|
||||
_tokens->push_back(tk);
|
||||
} while (tk.kind);
|
||||
} while (tk.f.kind);
|
||||
|
||||
for (; ! braces.empty(); braces.pop()) {
|
||||
unsigned open_brace_index = braces.top();
|
||||
@@ -240,10 +242,10 @@ void TranslationUnit::tokenize()
|
||||
}
|
||||
|
||||
bool TranslationUnit::skipFunctionBody() const
|
||||
{ return _skipFunctionBody; }
|
||||
{ return f._skipFunctionBody; }
|
||||
|
||||
void TranslationUnit::setSkipFunctionBody(bool skipFunctionBody)
|
||||
{ _skipFunctionBody = skipFunctionBody; }
|
||||
{ f._skipFunctionBody = skipFunctionBody; }
|
||||
|
||||
bool TranslationUnit::parse(ParseMode mode)
|
||||
{
|
||||
@@ -254,8 +256,8 @@ bool TranslationUnit::parse(ParseMode mode)
|
||||
tokenize();
|
||||
|
||||
Parser parser(this);
|
||||
parser.setQtMocRunEnabled(_qtMocRunEnabled);
|
||||
parser.setObjCEnabled(_objCEnabled);
|
||||
parser.setQtMocRunEnabled(f._qtMocRunEnabled);
|
||||
parser.setObjCEnabled(f._objCEnabled);
|
||||
|
||||
bool parsed = false;
|
||||
|
||||
@@ -375,14 +377,14 @@ void TranslationUnit::getPosition(unsigned tokenOffset,
|
||||
|
||||
bool TranslationUnit::blockErrors(bool block)
|
||||
{
|
||||
bool previous = _blockErrors;
|
||||
_blockErrors = block;
|
||||
bool previous = f._blockErrors;
|
||||
f._blockErrors = block;
|
||||
return previous;
|
||||
}
|
||||
|
||||
void TranslationUnit::warning(unsigned index, const char *format, ...)
|
||||
{
|
||||
if (_blockErrors)
|
||||
if (f._blockErrors)
|
||||
return;
|
||||
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
@@ -413,7 +415,7 @@ void TranslationUnit::warning(unsigned index, const char *format, ...)
|
||||
|
||||
void TranslationUnit::error(unsigned index, const char *format, ...)
|
||||
{
|
||||
if (_blockErrors)
|
||||
if (f._blockErrors)
|
||||
return;
|
||||
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
@@ -444,7 +446,7 @@ void TranslationUnit::error(unsigned index, const char *format, ...)
|
||||
|
||||
void TranslationUnit::fatal(unsigned index, const char *format, ...)
|
||||
{
|
||||
if (_blockErrors)
|
||||
if (f._blockErrors)
|
||||
return;
|
||||
|
||||
index = std::min(index, tokenCount() - 1);
|
||||
|
@@ -53,7 +53,7 @@
|
||||
#include "ASTfwd.h"
|
||||
#include "Token.h"
|
||||
#include "Array.h"
|
||||
#include <cstdio>
|
||||
#include <stdio.h> // for FILE*
|
||||
#include <vector> // ### remove me
|
||||
|
||||
CPLUSPLUS_BEGIN_HEADER
|
||||
@@ -190,16 +190,17 @@ private:
|
||||
MemoryPool *_pool;
|
||||
AST *_ast;
|
||||
TranslationUnit *_previousTranslationUnit;
|
||||
struct Flags {
|
||||
unsigned _tokenized: 1;
|
||||
unsigned _parsed: 1;
|
||||
unsigned _blockErrors: 1;
|
||||
unsigned _skipFunctionBody: 1;
|
||||
unsigned _qtMocRunEnabled: 1;
|
||||
unsigned _objCEnabled: 1;
|
||||
};
|
||||
union {
|
||||
unsigned _flags;
|
||||
struct {
|
||||
unsigned _tokenized: 1;
|
||||
unsigned _parsed: 1;
|
||||
unsigned _blockErrors: 1;
|
||||
unsigned _skipFunctionBody: 1;
|
||||
unsigned _qtMocRunEnabled: 1;
|
||||
unsigned _objCEnabled: 1;
|
||||
};
|
||||
Flags f;
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user