forked from qt-creator/qt-creator
C++: add semantic support for C++11 alias decls.
Task-number: QTCREATORBUG-9386 Change-Id: Ia68f3866c122ca5261dd73b2c740b47fb15744fc Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
c2d6081a6c
commit
e2a727c450
10
src/libs/3rdparty/cplusplus/AST.cpp
vendored
10
src/libs/3rdparty/cplusplus/AST.cpp
vendored
@@ -4419,8 +4419,9 @@ unsigned AliasDeclarationAST::firstToken() const
|
||||
{
|
||||
if (using_token)
|
||||
return using_token;
|
||||
if (identifier_token)
|
||||
return identifier_token;
|
||||
if (name)
|
||||
if (unsigned candidate = name->firstToken())
|
||||
return candidate;
|
||||
if (equal_token)
|
||||
return equal_token;
|
||||
if (typeId)
|
||||
@@ -4441,8 +4442,9 @@ unsigned AliasDeclarationAST::lastToken() const
|
||||
return candidate;
|
||||
if (equal_token)
|
||||
return equal_token + 1;
|
||||
if (identifier_token)
|
||||
return identifier_token + 1;
|
||||
if (name)
|
||||
if (unsigned candidate = name->lastToken())
|
||||
return candidate;
|
||||
if (using_token)
|
||||
return using_token + 1;
|
||||
return 1;
|
||||
|
||||
8
src/libs/3rdparty/cplusplus/AST.h
vendored
8
src/libs/3rdparty/cplusplus/AST.h
vendored
@@ -2432,18 +2432,22 @@ class CPLUSPLUS_EXPORT AliasDeclarationAST: public DeclarationAST
|
||||
{
|
||||
public:
|
||||
unsigned using_token;
|
||||
unsigned identifier_token;
|
||||
NameAST *name;
|
||||
unsigned equal_token;
|
||||
TypeIdAST *typeId;
|
||||
unsigned semicolon_token;
|
||||
|
||||
public: // annotations
|
||||
Declaration *symbol;
|
||||
|
||||
public:
|
||||
AliasDeclarationAST()
|
||||
: using_token(0)
|
||||
, identifier_token(0)
|
||||
, name(0)
|
||||
, equal_token(0)
|
||||
, typeId(0)
|
||||
, semicolon_token(0)
|
||||
, symbol(0)
|
||||
{}
|
||||
|
||||
virtual AliasDeclarationAST *asAliasDeclaration() { return this; }
|
||||
|
||||
3
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
3
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
@@ -890,7 +890,8 @@ AliasDeclarationAST *AliasDeclarationAST::clone(MemoryPool *pool) const
|
||||
{
|
||||
AliasDeclarationAST *ast = new (pool) AliasDeclarationAST;
|
||||
ast->using_token = using_token;
|
||||
ast->identifier_token = identifier_token;
|
||||
if (name)
|
||||
ast->name = name->clone(pool);
|
||||
ast->equal_token = equal_token;
|
||||
if (typeId)
|
||||
ast->typeId = typeId->clone(pool);
|
||||
|
||||
5
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
5
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
@@ -1511,7 +1511,10 @@ bool ASTMatcher::match(AliasDeclarationAST *node, AliasDeclarationAST *pattern)
|
||||
|
||||
pattern->using_token = node->using_token;
|
||||
|
||||
pattern->identifier_token = node->identifier_token;
|
||||
if (! pattern->name)
|
||||
pattern->name = node->name;
|
||||
else if (! AST::match(node->name, pattern->name, this))
|
||||
return false;
|
||||
|
||||
pattern->equal_token = node->equal_token;
|
||||
|
||||
|
||||
@@ -584,9 +584,10 @@ public:
|
||||
return __ast;
|
||||
}
|
||||
|
||||
AliasDeclarationAST *AliasDeclaration(TypeIdAST *typeId = 0)
|
||||
AliasDeclarationAST *AliasDeclaration(NameAST *name = 0, TypeIdAST *typeId = 0)
|
||||
{
|
||||
AliasDeclarationAST *__ast = new (&pool) AliasDeclarationAST;
|
||||
__ast->name = name;
|
||||
__ast->typeId = typeId;
|
||||
return __ast;
|
||||
}
|
||||
|
||||
1
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
1
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
@@ -646,6 +646,7 @@ void NamespaceAliasDefinitionAST::accept0(ASTVisitor *visitor)
|
||||
void AliasDeclarationAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
accept(name, visitor);
|
||||
accept(typeId, visitor);
|
||||
}
|
||||
visitor->endVisit(this);
|
||||
|
||||
21
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
21
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -2066,6 +2066,27 @@ bool Bind::visit(QtInterfacesDeclarationAST *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bind::visit(AliasDeclarationAST *ast)
|
||||
{
|
||||
if (!ast->name)
|
||||
return false;
|
||||
|
||||
const Name *name = this->name(ast->name);
|
||||
|
||||
FullySpecifiedType ty = expression(ast->typeId);
|
||||
ty.setTypedef(true);
|
||||
|
||||
Declaration *decl = control()->newDeclaration(ast->name->firstToken(), name);
|
||||
decl->setType(ty);
|
||||
decl->setStorage(Symbol::Typedef);
|
||||
ast->symbol = decl;
|
||||
if (_scope->isClass())
|
||||
decl->setVisibility(_visibility);
|
||||
_scope->addMember(decl);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bind::visit(AsmDefinitionAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
|
||||
1
src/libs/3rdparty/cplusplus/Bind.h
vendored
1
src/libs/3rdparty/cplusplus/Bind.h
vendored
@@ -209,6 +209,7 @@ protected:
|
||||
virtual bool visit(QtEnumDeclarationAST *ast);
|
||||
virtual bool visit(QtFlagsDeclarationAST *ast);
|
||||
virtual bool visit(QtInterfacesDeclarationAST *ast);
|
||||
virtual bool visit(AliasDeclarationAST *ast);
|
||||
virtual bool visit(AsmDefinitionAST *ast);
|
||||
virtual bool visit(ExceptionDeclarationAST *ast);
|
||||
virtual bool visit(FunctionDefinitionAST *ast);
|
||||
|
||||
4
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
4
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -868,7 +868,9 @@ bool Parser::parseAliasDeclaration(DeclarationAST *&node)
|
||||
|
||||
AliasDeclarationAST *alias = new (_pool) AliasDeclarationAST;
|
||||
alias->using_token = consumeToken();
|
||||
alias->identifier_token = consumeToken();
|
||||
SimpleNameAST *name = new (_pool) SimpleNameAST;
|
||||
name->identifier_token = consumeToken();
|
||||
alias->name = name;
|
||||
|
||||
// ### attributes!
|
||||
while (LA() != T_EQUAL)
|
||||
|
||||
Reference in New Issue
Block a user