forked from qt-creator/qt-creator
C++: handle destructor names with template parameters.
Change-Id: I74b4fd5e043db935abc18345b303d294b71e8fc2 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
This commit is contained in:
10
src/libs/3rdparty/cplusplus/AST.cpp
vendored
10
src/libs/3rdparty/cplusplus/AST.cpp
vendored
@@ -963,16 +963,18 @@ unsigned DestructorNameAST::firstToken() const
|
||||
{
|
||||
if (tilde_token)
|
||||
return tilde_token;
|
||||
if (identifier_token)
|
||||
return identifier_token;
|
||||
if (unqualified_name)
|
||||
if (unsigned candidate = unqualified_name->firstToken())
|
||||
return candidate;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** \generated */
|
||||
unsigned DestructorNameAST::lastToken() const
|
||||
{
|
||||
if (identifier_token)
|
||||
return identifier_token + 1;
|
||||
if (unqualified_name)
|
||||
if (unsigned candidate = unqualified_name->lastToken())
|
||||
return candidate;
|
||||
if (tilde_token)
|
||||
return tilde_token + 1;
|
||||
return 1;
|
||||
|
||||
4
src/libs/3rdparty/cplusplus/AST.h
vendored
4
src/libs/3rdparty/cplusplus/AST.h
vendored
@@ -2286,12 +2286,12 @@ class CPLUSPLUS_EXPORT DestructorNameAST: public NameAST
|
||||
{
|
||||
public:
|
||||
unsigned tilde_token;
|
||||
unsigned identifier_token;
|
||||
NameAST *unqualified_name;
|
||||
|
||||
public:
|
||||
DestructorNameAST()
|
||||
: tilde_token(0)
|
||||
, identifier_token(0)
|
||||
, unqualified_name(0)
|
||||
{}
|
||||
|
||||
virtual DestructorNameAST *asDestructorName() { return this; }
|
||||
|
||||
3
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
3
src/libs/3rdparty/cplusplus/ASTClone.cpp
vendored
@@ -833,7 +833,8 @@ DestructorNameAST *DestructorNameAST::clone(MemoryPool *pool) const
|
||||
{
|
||||
DestructorNameAST *ast = new (pool) DestructorNameAST;
|
||||
ast->tilde_token = tilde_token;
|
||||
ast->identifier_token = identifier_token;
|
||||
if (unqualified_name)
|
||||
ast->unqualified_name = unqualified_name->clone(pool);
|
||||
return ast;
|
||||
}
|
||||
|
||||
|
||||
5
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
5
src/libs/3rdparty/cplusplus/ASTMatcher.cpp
vendored
@@ -1416,7 +1416,10 @@ bool ASTMatcher::match(DestructorNameAST *node, DestructorNameAST *pattern)
|
||||
|
||||
pattern->tilde_token = node->tilde_token;
|
||||
|
||||
pattern->identifier_token = node->identifier_token;
|
||||
if (! pattern->unqualified_name)
|
||||
pattern->unqualified_name = node->unqualified_name;
|
||||
else if (! AST::match(node->unqualified_name, pattern->unqualified_name, this))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -549,9 +549,10 @@ public:
|
||||
return __ast;
|
||||
}
|
||||
|
||||
DestructorNameAST *DestructorName()
|
||||
DestructorNameAST *DestructorName(NameAST *unqualified_name = 0)
|
||||
{
|
||||
DestructorNameAST *__ast = new (&pool) DestructorNameAST;
|
||||
__ast->unqualified_name = unqualified_name;
|
||||
return __ast;
|
||||
}
|
||||
|
||||
|
||||
1
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
1
src/libs/3rdparty/cplusplus/ASTVisit.cpp
vendored
@@ -606,6 +606,7 @@ void SimpleNameAST::accept0(ASTVisitor *visitor)
|
||||
void DestructorNameAST::accept0(ASTVisitor *visitor)
|
||||
{
|
||||
if (visitor->visit(this)) {
|
||||
accept(unqualified_name, visitor);
|
||||
}
|
||||
visitor->endVisit(this);
|
||||
}
|
||||
|
||||
5
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
5
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -91,7 +91,7 @@ unsigned Bind::location(NameAST *name, unsigned defaultLocation) const
|
||||
return defaultLocation;
|
||||
|
||||
else if (DestructorNameAST *dtor = name->asDestructorName())
|
||||
return dtor->identifier_token;
|
||||
return location(dtor->unqualified_name, defaultLocation);
|
||||
|
||||
else if (TemplateIdAST *templId = name->asTemplateId())
|
||||
return templId->identifier_token;
|
||||
@@ -2624,8 +2624,7 @@ bool Bind::visit(SimpleNameAST *ast)
|
||||
|
||||
bool Bind::visit(DestructorNameAST *ast)
|
||||
{
|
||||
const Identifier *id = identifier(ast->identifier_token);
|
||||
_name = control()->destructorNameId(id);
|
||||
_name = control()->destructorNameId(name(ast->unqualified_name));
|
||||
ast->name = _name;
|
||||
return false;
|
||||
}
|
||||
|
||||
8
src/libs/3rdparty/cplusplus/Control.cpp
vendored
8
src/libs/3rdparty/cplusplus/Control.cpp
vendored
@@ -227,9 +227,9 @@ public:
|
||||
return templateNameIds.intern(TemplateNameId(id, first, last));
|
||||
}
|
||||
|
||||
const DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
|
||||
const DestructorNameId *findOrInsertDestructorNameId(const Name *name)
|
||||
{
|
||||
return destructorNameIds.intern(DestructorNameId(id));
|
||||
return destructorNameIds.intern(DestructorNameId(name));
|
||||
}
|
||||
|
||||
const OperatorNameId *findOrInsertOperatorNameId(OperatorNameId::Kind kind)
|
||||
@@ -610,8 +610,8 @@ const TemplateNameId *Control::templateNameId(const Identifier *id,
|
||||
return d->findOrInsertTemplateNameId(id, args, args + argv);
|
||||
}
|
||||
|
||||
const DestructorNameId *Control::destructorNameId(const Identifier *id)
|
||||
{ return d->findOrInsertDestructorNameId(id); }
|
||||
const DestructorNameId *Control::destructorNameId(const Name *name)
|
||||
{ return d->findOrInsertDestructorNameId(name); }
|
||||
|
||||
const OperatorNameId *Control::operatorNameId(OperatorNameId::Kind kind)
|
||||
{ return d->findOrInsertOperatorNameId(kind); }
|
||||
|
||||
2
src/libs/3rdparty/cplusplus/Control.h
vendored
2
src/libs/3rdparty/cplusplus/Control.h
vendored
@@ -55,7 +55,7 @@ public:
|
||||
unsigned argc = 0);
|
||||
|
||||
/// Returns the canonical destructor name id.
|
||||
const DestructorNameId *destructorNameId(const Identifier *id);
|
||||
const DestructorNameId *destructorNameId(const Name *name);
|
||||
|
||||
/// Returns the canonical operator name id.
|
||||
const OperatorNameId *operatorNameId(OperatorNameId::Kind operatorId);
|
||||
|
||||
13
src/libs/3rdparty/cplusplus/Names.cpp
vendored
13
src/libs/3rdparty/cplusplus/Names.cpp
vendored
@@ -62,8 +62,8 @@ bool QualifiedNameId::isEqualTo(const Name *other) const
|
||||
return false;
|
||||
}
|
||||
|
||||
DestructorNameId::DestructorNameId(const Identifier *identifier)
|
||||
: _identifier(identifier)
|
||||
DestructorNameId::DestructorNameId(const Name *name)
|
||||
: _name(name)
|
||||
{ }
|
||||
|
||||
DestructorNameId::~DestructorNameId()
|
||||
@@ -72,8 +72,11 @@ DestructorNameId::~DestructorNameId()
|
||||
void DestructorNameId::accept0(NameVisitor *visitor) const
|
||||
{ visitor->visit(this); }
|
||||
|
||||
const Name *DestructorNameId::name() const
|
||||
{ return _name; }
|
||||
|
||||
const Identifier *DestructorNameId::identifier() const
|
||||
{ return _identifier; }
|
||||
{ return _name->identifier(); }
|
||||
|
||||
bool DestructorNameId::isEqualTo(const Name *other) const
|
||||
{
|
||||
@@ -81,8 +84,8 @@ bool DestructorNameId::isEqualTo(const Name *other) const
|
||||
const DestructorNameId *d = other->asDestructorNameId();
|
||||
if (! d)
|
||||
return false;
|
||||
const Identifier *l = identifier();
|
||||
const Identifier *r = d->identifier();
|
||||
const Name *l = name();
|
||||
const Name *r = d->name();
|
||||
return l->isEqualTo(r);
|
||||
}
|
||||
return false;
|
||||
|
||||
6
src/libs/3rdparty/cplusplus/Names.h
vendored
6
src/libs/3rdparty/cplusplus/Names.h
vendored
@@ -57,9 +57,11 @@ private:
|
||||
class CPLUSPLUS_EXPORT DestructorNameId: public Name
|
||||
{
|
||||
public:
|
||||
DestructorNameId(const Identifier *identifier);
|
||||
DestructorNameId(const Name *name);
|
||||
virtual ~DestructorNameId();
|
||||
|
||||
virtual const Name *name() const;
|
||||
|
||||
virtual const Identifier *identifier() const;
|
||||
|
||||
virtual bool isEqualTo(const Name *other) const;
|
||||
@@ -71,7 +73,7 @@ protected:
|
||||
virtual void accept0(NameVisitor *visitor) const;
|
||||
|
||||
private:
|
||||
const Identifier *_identifier;
|
||||
const Name *_name;
|
||||
};
|
||||
|
||||
class CPLUSPLUS_EXPORT TemplateNameId: public Name
|
||||
|
||||
2
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
2
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -2740,7 +2740,7 @@ bool Parser::parseUnqualifiedName(NameAST *&node, bool acceptTemplateId)
|
||||
if (LA() == T_TILDE && LA(2) == T_IDENTIFIER) {
|
||||
DestructorNameAST *ast = new (_pool) DestructorNameAST;
|
||||
ast->tilde_token = consumeToken();
|
||||
ast->identifier_token = consumeToken();
|
||||
parseUnqualifiedName(ast->unqualified_name);
|
||||
node = ast;
|
||||
return true;
|
||||
} else if (LA() == T_OPERATOR) {
|
||||
|
||||
Reference in New Issue
Block a user