Commit 9efa5d94 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Added __attribute__ visiting, and storing of the deprecated attr.

parent f45ff92c
......@@ -167,6 +167,8 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
symbol->setTemplateParameters(_templateParameters);
_templateParameters = 0;
}
if (ty.isDeprecated())
symbol->setDeprecated(true);
_scope->enterSymbol(symbol);
return false;
......@@ -198,6 +200,8 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
fun->setName(name);
fun->setMethodKey(semantic()->currentMethodKey());
fun->setVirtual(ty.isVirtual());
if (ty.isDeprecated())
fun->setDeprecated(true);
if (isQ_SIGNAL)
fun->setMethodKey(Function::SignalMethod);
else if (isQ_SLOT)
......@@ -215,6 +219,8 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
symbol->setEndOffset(tokenAt(ast->lastToken()).offset);
symbol->setType(declTy);
if (declTy.isDeprecated())
symbol->setDeprecated(true);
if (_templateParameters && it == ast->declarator_list) {
symbol->setTemplateParameters(_templateParameters);
......@@ -235,6 +241,8 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
symbol->setStorage(Symbol::Mutable);
else if (ty.isTypedef())
symbol->setStorage(Symbol::Typedef);
else if (ty.isDeprecated())
symbol->setDeprecated(true);
if (it->value && it->value->initializer) {
FullySpecifiedType initTy = semantic()->check(it->value->initializer, _scope);
......@@ -314,6 +322,8 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
Function *fun = funTy->asFunctionType();
fun->setVirtual(ty.isVirtual());
if (ty.isDeprecated())
fun->setDeprecated(true);
fun->setStartOffset(tokenAt(ast->firstToken()).offset);
fun->setEndOffset(tokenAt(ast->lastToken()).offset);
if (ast->declarator)
......@@ -703,6 +713,8 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
symbol->setStartOffset(tokenAt(ast->firstToken()).offset);
symbol->setEndOffset(tokenAt(ast->lastToken()).offset);
symbol->setVisibility(semantic()->currentObjCVisibility());
if (ty.isDeprecated())
symbol->setDeprecated(true);
_scope->enterSymbol(symbol);
......
......@@ -195,17 +195,9 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
}
FullySpecifiedType funTy(fun);
_fullySpecifiedType = funTy;
for (SpecifierListAST *it = ast->cv_qualifier_list; it; it = it->next) {
SimpleSpecifierAST *cv = static_cast<SimpleSpecifierAST *>(it->value);
const int k = tokenKind(cv->specifier_token);
if (k == T_CONST)
fun->setConst(true);
else if (k == T_VOLATILE)
fun->setVolatile(true);
}
funTy = semantic()->check(ast->cv_qualifier_list, _scope, funTy);
_fullySpecifiedType = funTy;
return false;
}
......@@ -289,6 +281,8 @@ bool CheckDeclarator::visit(ObjCMethodPrototypeAST *ast)
method->setVariadic(true);
_fullySpecifiedType = FullySpecifiedType(method);
_fullySpecifiedType = semantic()->check(ast->attribute_list, _scope,
_fullySpecifiedType);
return false;
}
......
......@@ -69,9 +69,11 @@ CheckSpecifier::CheckSpecifier(Semantic *semantic)
CheckSpecifier::~CheckSpecifier()
{ }
FullySpecifiedType CheckSpecifier::check(SpecifierListAST *specifier, Scope *scope)
FullySpecifiedType CheckSpecifier::check(SpecifierListAST *specifier,
Scope *scope,
const FullySpecifiedType &ty)
{
FullySpecifiedType previousType = switchFullySpecifiedType(FullySpecifiedType());
FullySpecifiedType previousType = switchFullySpecifiedType(ty);
Scope *previousScope = switchScope(scope);
SpecifierListAST *previousSpecifier = switchSpecifier(specifier);
accept(specifier);
......@@ -80,9 +82,11 @@ FullySpecifiedType CheckSpecifier::check(SpecifierListAST *specifier, Scope *sco
return switchFullySpecifiedType(previousType);
}
FullySpecifiedType CheckSpecifier::check(ObjCTypeNameAST *typeName, Scope *scope)
FullySpecifiedType CheckSpecifier::check(ObjCTypeNameAST *typeName,
Scope *scope,
const FullySpecifiedType &ty)
{
FullySpecifiedType previousType = switchFullySpecifiedType(FullySpecifiedType());
FullySpecifiedType previousType = switchFullySpecifiedType(ty);
Scope *previousScope = switchScope(scope);
accept(typeName);
......@@ -327,6 +331,9 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
klass->setVisibility(semantic()->currentVisibility());
_scope->enterSymbol(klass);
_fullySpecifiedType.setType(klass);
accept(ast->attribute_list);
if (_fullySpecifiedType.isDeprecated())
klass->setDeprecated(true);
for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
BaseSpecifierAST *base = it->value;
......@@ -377,6 +384,7 @@ bool CheckSpecifier::visit(ElaboratedTypeSpecifierAST *ast)
{
const Name *name = semantic()->check(ast->name, _scope);
_fullySpecifiedType.setType(control()->namedType(name));
accept(ast->attribute_list);
return false;
}
......@@ -414,7 +422,11 @@ bool CheckSpecifier::visit(TypeofSpecifierAST *ast)
return false;
}
bool CheckSpecifier::visit(AttributeSpecifierAST * /*ast*/)
bool CheckSpecifier::visit(AttributeAST *ast)
{
if (ast->identifier_token) {
if (identifier(ast->identifier_token) == control()->deprecatedId())
_fullySpecifiedType.setDeprecated(true);
}
return false;
}
......@@ -62,8 +62,10 @@ public:
CheckSpecifier(Semantic *semantic);
virtual ~CheckSpecifier();
FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope);
FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope);
FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope,
const FullySpecifiedType &ty = FullySpecifiedType());
FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope,
const FullySpecifiedType &ty = FullySpecifiedType());
protected:
SpecifierListAST *switchSpecifier(SpecifierListAST *specifier);
......@@ -78,7 +80,7 @@ protected:
virtual bool visit(ElaboratedTypeSpecifierAST *ast);
virtual bool visit(EnumSpecifierAST *ast);
virtual bool visit(TypeofSpecifierAST *ast);
virtual bool visit(AttributeSpecifierAST *ast);
virtual bool visit(AttributeAST *ast);
private:
SpecifierListAST *_specifier;
......
......@@ -84,6 +84,8 @@ FullySpecifiedType FullySpecifiedType::qualifiedType() const
ty.setInline(false);
ty.setVirtual(false);
ty.setExplicit(false);
ty.setDeprecated(false);
return ty;
}
......@@ -165,6 +167,12 @@ bool FullySpecifiedType::isExplicit() const
void FullySpecifiedType::setExplicit(bool isExplicit)
{ f._isExplicit = isExplicit; }
bool FullySpecifiedType::isDeprecated() const
{ return f._isDeprecated; }
void FullySpecifiedType::setDeprecated(bool isDeprecated)
{ f._isDeprecated = isDeprecated; }
bool FullySpecifiedType::isEqualTo(const FullySpecifiedType &other) const
{
if (_flags != other._flags)
......
......@@ -107,6 +107,9 @@ public:
bool isExplicit() const;
void setExplicit(bool isExplicit);
bool isDeprecated() const;
void setDeprecated(bool isDeprecated);
bool isEqualTo(const FullySpecifiedType &other) const;
Type &operator*();
......@@ -148,6 +151,9 @@ private:
unsigned _isInline: 1;
unsigned _isVirtual: 1;
unsigned _isExplicit: 1;
// speficiers from attributes
unsigned _isDeprecated: 1;
};
union {
unsigned _flags;
......
......@@ -125,8 +125,9 @@ TranslationUnit *Semantic::translationUnit() const
Control *Semantic::control() const
{ return d->control; }
FullySpecifiedType Semantic::check(SpecifierListAST *specifier, Scope *scope)
{ return d->checkSpecifier->check(specifier, scope); }
FullySpecifiedType Semantic::check(SpecifierListAST *specifier, Scope *scope,
const FullySpecifiedType &type)
{ return d->checkSpecifier->check(specifier, scope, type); }
void Semantic::check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters)
{ d->checkDeclaration->check(declaration, scope, templateParameters); }
......@@ -142,8 +143,9 @@ FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const Fully
FullySpecifiedType Semantic::check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope)
{ return d->checkDeclarator->check(methodPrototype, scope); }
FullySpecifiedType Semantic::check(ObjCTypeNameAST *typeName, Scope *scope)
{ return d->checkSpecifier->check(typeName, scope); }
FullySpecifiedType Semantic::check(ObjCTypeNameAST *typeName, Scope *scope,
const FullySpecifiedType &type)
{ return d->checkSpecifier->check(typeName, scope, type); }
void Semantic::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
{ return d->checkName->check(arg, scope); }
......
......@@ -51,7 +51,7 @@
#include "CPlusPlusForwardDeclarations.h"
#include "ASTfwd.h"
#include "FullySpecifiedType.h"
namespace CPlusPlus {
......@@ -67,7 +67,8 @@ public:
TranslationUnit *translationUnit() const;
Control *control() const;
FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope);
FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope,
const FullySpecifiedType &type = FullySpecifiedType());
FullySpecifiedType check(DeclaratorAST *declarator, const FullySpecifiedType &type,
Scope *scope, const Name **name = 0); // ### ugly
......@@ -87,7 +88,8 @@ public:
const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope);
FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope,
const FullySpecifiedType &type = FullySpecifiedType());
void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
......
......@@ -212,6 +212,12 @@ unsigned Symbol::sourceOffset() const
bool Symbol::isGenerated() const
{ return _isGenerated; }
bool Symbol::isDeprecated() const
{ return _isDeprecated; }
void Symbol::setDeprecated(bool isDeprecated)
{ _isDeprecated = isDeprecated; }
void Symbol::setSourceLocation(unsigned sourceLocation)
{
_sourceLocation = sourceLocation;
......
......@@ -291,6 +291,9 @@ public:
bool isGenerated() const;
bool isDeprecated() const;
void setDeprecated(bool isDeprecated);
Symbol *enclosingSymbol() const;
/// Returns the eclosing namespace scope.
......@@ -334,6 +337,7 @@ private:
Symbol *_next;
bool _isGenerated: 1;
bool _isDeprecated: 1;
class IdentityForName;
class HashCode;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment