diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2011-01-21 02:08:36 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-01-21 02:08:36 +0000 |
| commit | ab8bc063738542bbc0defbfa924b40aa9544af6d (patch) | |
| tree | 69a2c3de4af7f374a3ab58a1e8b0726a05041e12 /clang/lib/Sema/SemaDecl.cpp | |
| parent | 4fbd74ba02257fe9e24ae659d836251c43faff87 (diff) | |
| download | bcm5719-llvm-ab8bc063738542bbc0defbfa924b40aa9544af6d.tar.gz bcm5719-llvm-ab8bc063738542bbc0defbfa924b40aa9544af6d.zip | |
Generalise support for non-inheritable attributes
Inheritable attributes on declarations may be inherited by any later
redeclaration at merge time. By contrast, a non-inheritable attribute
will not be inherited by later redeclarations. Non-inheritable
attributes may be semantically analysed early, allowing them to
influence the redeclaration/overloading process.
Before this change, the "overloadable" attribute received special
handling to be treated as non-inheritable, while all other attributes
were treated as inheritable. This patch generalises the concept,
while removing a FIXME. Some CUDA location attributes are also marked
as non-inheritable in order to support special overloading semantics
(to be introduced in a later patch).
The patch introduces a new Attr subclass, InheritableAttr, from
which all inheritable attributes derive. Non-inheritable attributes
simply derive from Attr.
N.B. I did not review every attribute to determine whether it should
be marked non-inheritable. This can be done later on an incremental
basis, as this change does not affect default functionality.
llvm-svn: 123959
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a3c3242a4e4..8c78c0dd764 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1019,11 +1019,11 @@ static void MergeDeclAttributes(Decl *New, Decl *Old, ASTContext &C) { // we process them. if (!New->hasAttrs()) New->setAttrs(AttrVec()); - for (Decl::attr_iterator i = Old->attr_begin(), e = Old->attr_end(); i != e; - ++i) { - // FIXME: Make this more general than just checking for Overloadable. - if (!DeclHasAttr(New, *i) && (*i)->getKind() != attr::Overloadable) { - Attr *NewAttr = (*i)->clone(C); + for (specific_attr_iterator<InheritableAttr> + i = Old->specific_attr_begin<InheritableAttr>(), + e = Old->specific_attr_end<InheritableAttr>(); i != e; ++i) { + if (!DeclHasAttr(New, *i)) { + InheritableAttr *NewAttr = cast<InheritableAttr>((*i)->clone(C)); NewAttr->setInherited(true); New->addAttr(NewAttr); } |

