summaryrefslogtreecommitdiffstats
path: root/include/clang/Sema/AttributeList.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-12-24 02:08:15 +0000
committerJohn McCall <rjmccall@apple.com>2010-12-24 02:08:15 +0000
commit7f040a9d817cd1c72b565e92abff473510bf9e1d (patch)
tree4f168629b32435bb24409a5f6ee03a82ede2de23 /include/clang/Sema/AttributeList.h
parent6e4e17de3df88ead7eaf51b3503a6be1718438c0 (diff)
Refactor how we collect attributes during parsing, and add slots for attributes
on array and function declarators. This is pretty far from complete, and I'll revisit it later if someone doesn't beat me to it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/AttributeList.h')
-rw-r--r--include/clang/Sema/AttributeList.h48
1 files changed, 44 insertions, 4 deletions
diff --git a/include/clang/Sema/AttributeList.h b/include/clang/Sema/AttributeList.h
index 69170fa23c..0dab666979 100644
--- a/include/clang/Sema/AttributeList.h
+++ b/include/clang/Sema/AttributeList.h
@@ -56,7 +56,7 @@ private:
IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
IdentifierInfo *ParmName, SourceLocation ParmLoc,
Expr **args, unsigned numargs,
- AttributeList *Next, bool declspec, bool cxx0x);
+ bool declspec, bool cxx0x);
public:
class Factory {
llvm::BumpPtrAllocator Alloc;
@@ -66,12 +66,11 @@ public:
AttributeList *Create(IdentifierInfo *AttrName, SourceLocation AttrLoc,
IdentifierInfo *ScopeName, SourceLocation ScopeLoc,
IdentifierInfo *ParmName, SourceLocation ParmLoc,
- Expr **args, unsigned numargs,
- AttributeList *Next, bool declspec = false, bool cxx0x = false) {
+ Expr **args, unsigned numargs, bool declspec = false, bool cxx0x = false) {
AttributeList *Mem = Alloc.Allocate<AttributeList>();
new (Mem) AttributeList(Alloc, AttrName, AttrLoc, ScopeName, ScopeLoc,
ParmName, ParmLoc, args, numargs,
- Next, declspec, cxx0x);
+ declspec, cxx0x);
return Mem;
}
};
@@ -266,6 +265,47 @@ struct CXX0XAttributeList {
}
};
+/// ParsedAttributes - A collection of parsed attributes. Currently
+/// we don't differentiate between the various attribute syntaxes,
+/// which is basically silly.
+///
+/// Right now this is a very lightweight container, but the expectation
+/// is that this will become significantly more serious.
+class ParsedAttributes {
+public:
+ ParsedAttributes() : list(0) {}
+
+ bool empty() const { return list == 0; }
+
+ void add(AttributeList *newAttr) {
+ assert(newAttr);
+ assert(newAttr->getNext() == 0);
+ newAttr->setNext(list);
+ list = newAttr;
+ }
+
+ void append(AttributeList *newList) {
+ if (!newList) return;
+
+ AttributeList *lastInNewList = newList;
+ while (AttributeList *next = lastInNewList->getNext())
+ lastInNewList = next;
+
+ lastInNewList->setNext(list);
+ list = newList;
+ }
+
+ void set(AttributeList *newList) {
+ list = newList;
+ }
+
+ void clear() { list = 0; }
+ AttributeList *getList() const { return list; }
+
+private:
+ AttributeList *list;
+};
+
} // end namespace clang
#endif