Merge remote-tracking branch 'gerrit/3.2'

Change-Id: I2567b8f19e502777f6566ce573a6970fb62a7521
This commit is contained in:
Eike Ziller
2014-07-07 17:57:23 +02:00
212 changed files with 2738 additions and 1478 deletions

View File

@@ -4455,6 +4455,9 @@ public:
ExceptionSpecificationAST *exception_specification;
TrailingReturnTypeAST *trailing_return_type;
public: // annotations
Function *symbol;
public:
LambdaDeclaratorAST()
: lparen_token(0)

View File

@@ -1087,11 +1087,10 @@ bool Bind::visit(LambdaDeclaratorAST *ast)
return false;
}
void Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
Function *Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
{
if (! ast)
return;
return 0;
Function *fun = control()->newFunction(0, 0);
fun->setStartOffset(tokenAt(ast->firstToken()).utf16charsBegin());
@@ -1099,6 +1098,7 @@ void Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
if (ast->trailing_return_type)
_type = this->trailingReturnType(ast->trailing_return_type, _type);
fun->setReturnType(_type);
ast->symbol = fun;
// unsigned lparen_token = ast->lparen_token;
FullySpecifiedType type;
@@ -1108,7 +1108,8 @@ void Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
type = this->specifier(it->value, type);
}
// unsigned mutable_token = ast->mutable_token;
type = this->exceptionSpecification(ast->exception_specification, type);
_type = this->exceptionSpecification(ast->exception_specification, type);
return fun;
}
bool Bind::visit(TrailingReturnTypeAST *ast)
@@ -1780,8 +1781,15 @@ bool Bind::visit(ObjCSelectorExpressionAST *ast)
bool Bind::visit(LambdaExpressionAST *ast)
{
this->lambdaIntroducer(ast->lambda_introducer);
this->lambdaDeclarator(ast->lambda_declarator);
this->statement(ast->statement);
if (Function *function = this->lambdaDeclarator(ast->lambda_declarator)) {
_scope->addMember(function);
Scope *previousScope = switchScope(function);
this->statement(ast->statement);
(void) switchScope(previousScope);
} else {
this->statement(ast->statement);
}
return false;
}

View File

@@ -103,7 +103,7 @@ protected:
void lambdaIntroducer(LambdaIntroducerAST *ast);
void lambdaCapture(LambdaCaptureAST *ast);
void capture(CaptureAST *ast);
void lambdaDeclarator(LambdaDeclaratorAST *ast);
Function *lambdaDeclarator(LambdaDeclaratorAST *ast);
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
const StringLiteral *asStringLiteral(unsigned firstToken, unsigned lastToken);

View File

@@ -164,7 +164,7 @@ void TranslationUnit::tokenize()
_Lrecognize:
if (tk.is(T_POUND) && tk.newline()) {
unsigned offset = tk.byteOffset;
const unsigned utf16CharOffset = tk.utf16charOffset;
lex(&tk);
if (! tk.newline() && tk.is(T_IDENTIFIER) && tk.identifier == expansionId) {
@@ -237,7 +237,7 @@ void TranslationUnit::tokenize()
if (! tk.newline() && tk.is(T_STRING_LITERAL)) {
const StringLiteral *fileName =
control()->stringLiteral(tk.string->chars(), tk.string->size());
pushPreprocessorLine(offset, line, fileName);
pushPreprocessorLine(utf16CharOffset, line, fileName);
lex(&tk);
}
}
@@ -343,10 +343,10 @@ bool TranslationUnit::parse(ParseMode mode)
void TranslationUnit::pushLineOffset(unsigned offset)
{ _lineOffsets.push_back(offset); }
void TranslationUnit::pushPreprocessorLine(unsigned offset,
void TranslationUnit::pushPreprocessorLine(unsigned utf16charOffset,
unsigned line,
const StringLiteral *fileName)
{ _ppLines.push_back(PPLine(offset, line, fileName)); }
{ _ppLines.push_back(PPLine(utf16charOffset, line, fileName)); }
unsigned TranslationUnit::findLineNumber(unsigned utf16charOffset) const
{
@@ -359,10 +359,10 @@ unsigned TranslationUnit::findLineNumber(unsigned utf16charOffset) const
return it - _lineOffsets.begin();
}
TranslationUnit::PPLine TranslationUnit::findPreprocessorLine(unsigned offset) const
TranslationUnit::PPLine TranslationUnit::findPreprocessorLine(unsigned utf16charOffset) const
{
std::vector<PPLine>::const_iterator it =
std::lower_bound(_ppLines.begin(), _ppLines.end(), PPLine(offset));
std::lower_bound(_ppLines.begin(), _ppLines.end(), PPLine(utf16charOffset));
if (it != _ppLines.begin())
--it;
@@ -419,7 +419,7 @@ void TranslationUnit::getPosition(unsigned utf16charOffset,
// Adjust the line in regards to the preprocessing markers.
const PPLine ppLine = findPreprocessorLine(utf16charOffset);
lineNumber -= findLineNumber(ppLine.offset) + 1;
lineNumber -= findLineNumber(ppLine.utf16charOffset) + 1;
lineNumber += ppLine.line;
file = ppLine.fileName;

View File

@@ -138,7 +138,7 @@ public:
const StringLiteral **fileName = 0) const;
void pushLineOffset(unsigned offset);
void pushPreprocessorLine(unsigned offset,
void pushPreprocessorLine(unsigned utf16charOffset,
unsigned line,
const StringLiteral *fileName);
@@ -151,30 +151,30 @@ public:
private:
struct PPLine {
unsigned offset;
unsigned utf16charOffset;
unsigned line;
const StringLiteral *fileName;
PPLine(unsigned offset = 0,
PPLine(unsigned utf16charOffset = 0,
unsigned line = 0,
const StringLiteral *fileName = 0)
: offset(offset), line(line), fileName(fileName)
: utf16charOffset(utf16charOffset), line(line), fileName(fileName)
{ }
bool operator == (const PPLine &other) const
{ return offset == other.offset; }
{ return utf16charOffset == other.utf16charOffset; }
bool operator != (const PPLine &other) const
{ return offset != other.offset; }
{ return utf16charOffset != other.utf16charOffset; }
bool operator < (const PPLine &other) const
{ return offset < other.offset; }
{ return utf16charOffset < other.utf16charOffset; }
};
void releaseTokensAndComments();
unsigned findLineNumber(unsigned utf16charOffset) const;
unsigned findColumnNumber(unsigned utf16CharOffset, unsigned lineNumber) const;
PPLine findPreprocessorLine(unsigned offset) const;
PPLine findPreprocessorLine(unsigned utf16charOffset) const;
void showErrorLine(unsigned index, unsigned column, FILE *out);
static const Token nullToken;