[cfe-commits] r47112 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/AST/Attr.h
Chris Lattner
clattner at apple.com
Wed Feb 13 23:19:37 PST 2008
On Feb 13, 2008, at 11:14 PM, Anders Carlsson wrote:
> Author: andersca
> Log:
> Add Attr.h which is an AST-level class for GCC attributes.
nice.
> +#ifndef LLVM_CLANG_AST_EXPR_H
> +#define LLVM_CLANG_AST_EXPR_H
Plz update.
+ enum Kind {
+ AddressSpace,
+ Aligned,
+ OCUVectorType,
+ Packed,
+ VectorSize
We only need enums for things that will have classes here. VectorSize
and OCUVectorType turn into VectorType nodes, so they won't have an
Attr subclass for them. likewise AddressSpace is turned into a
property on pointertype, so it doesn't need an enum either.
> +protected:
> + Attr(Kind AK) : AttrKind(AK) {}
Plz initialize Next to null.
>
> + virtual ~Attr() {
> + if (Next)
> + delete Next;
No need to check for nonnull.
> + }
> +
> +public:
> + Kind getKind() const { return AttrKind; }
> +
> + Attr *getNext() const { return Next; }
Should return const Attr*.
>
> + void setNext(Attr *N) { Next = N; }
> +
> + void addAttr(Attr *attr) {
> + assert((attr != 0) && "addAttr(): attr is null");
> + Attr *next = this, *prev;
> + do {
> + prev = next;
> + next = next->getNext();
> + } while (next);
> + prev->setNext(attr);
> + }
It seems like it would be ok to add attrs to the start of the list?
Then we'd have Decl::addAttr which would add to the front of the decls
list, which would not require a complete traversal.
Otherwise, looks great, thanks!
-Chris
More information about the cfe-commits
mailing list