C++11: Correct scoping for scoped enums.

Fixes completion, highlighting and find usages.

Change-Id: I1ea12c6a9c7a4f8ba0f9d55e31d6b7986233e7d8
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Christian Kamm
2012-10-25 07:56:01 +02:00
committed by hjk
parent c55620000c
commit 19e03b186a
6 changed files with 52 additions and 25 deletions

View File

@@ -2965,6 +2965,8 @@ bool Bind::visit(EnumSpecifierAST *ast)
Enum *e = control()->newEnum(sourceLocation, enumName);
e->setStartOffset(tokenAt(sourceLocation).end()); // at the end of the enum or identifier token.
e->setEndOffset(tokenAt(ast->lastToken() - 1).end());
if (ast->key_token)
e->setScoped(true);
ast->symbol = e;
_scope->addMember(e);

View File

@@ -421,10 +421,12 @@ void Block::visitSymbol0(SymbolVisitor *visitor)
Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Scope(translationUnit, sourceLocation, name)
, _isScoped(false)
{ }
Enum::Enum(Clone *clone, Subst *subst, Enum *original)
: Scope(clone, subst, original)
, _isScoped(original->isScoped())
{ }
Enum::~Enum()
@@ -447,6 +449,16 @@ bool Enum::isEqualTo(const Type *other) const
return l->isEqualTo(r);
}
bool Enum::isScoped() const
{
return _isScoped;
}
void Enum::setScoped(bool scoped)
{
_isScoped = scoped;
}
void Enum::accept0(TypeVisitor *visitor)
{ visitor->visit(this); }

View File

@@ -279,10 +279,16 @@ public:
virtual Enum *asEnumType()
{ return this; }
bool isScoped() const;
void setScoped(bool scoped);
protected:
virtual void visitSymbol0(SymbolVisitor *visitor);
virtual void accept0(TypeVisitor *visitor);
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
private:
bool _isScoped;
};
class CPLUSPLUS_EXPORT Function: public Scope, public Type