diff options
Diffstat (limited to 'include/clang/AST/DeclGroup.h')
-rw-r--r-- | include/clang/AST/DeclGroup.h | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h index 15a8adef8e57b..790ea3ca06624 100644 --- a/include/clang/AST/DeclGroup.h +++ b/include/clang/AST/DeclGroup.h @@ -18,7 +18,7 @@ #include <cassert> namespace clang { - + class ASTContext; class Decl; class DeclGroup; @@ -27,7 +27,7 @@ class DeclGroupIterator; class DeclGroup { // FIXME: Include a TypeSpecifier object. unsigned NumDecls; - + private: DeclGroup() : NumDecls(0) {} DeclGroup(unsigned numdecls, Decl** decls); @@ -38,34 +38,34 @@ public: unsigned size() const { return NumDecls; } - Decl*& operator[](unsigned i) { + Decl*& operator[](unsigned i) { assert (i < NumDecls && "Out-of-bounds access."); return *((Decl**) (this+1)); } - - Decl* const& operator[](unsigned i) const { + + Decl* const& operator[](unsigned i) const { assert (i < NumDecls && "Out-of-bounds access."); return *((Decl* const*) (this+1)); } }; - + class DeclGroupRef { // Note this is not a PointerIntPair because we need the address of the // non-group case to be valid as a Decl** for iteration. - enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 }; + enum Kind { SingleDeclKind=0x0, DeclGroupKind=0x1, Mask=0x1 }; Decl* D; Kind getKind() const { return (Kind) (reinterpret_cast<uintptr_t>(D) & Mask); - } - -public: + } + +public: DeclGroupRef() : D(0) {} - + explicit DeclGroupRef(Decl* d) : D(d) {} explicit DeclGroupRef(DeclGroup* dg) : D((Decl*) (reinterpret_cast<uintptr_t>(dg) | DeclGroupKind)) {} - + static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls) { if (NumDecls == 0) return DeclGroupRef(); @@ -73,10 +73,10 @@ public: return DeclGroupRef(Decls[0]); return DeclGroupRef(DeclGroup::Create(C, Decls, NumDecls)); } - + typedef Decl** iterator; typedef Decl* const * const_iterator; - + bool isNull() const { return D == 0; } bool isSingleDecl() const { return getKind() == SingleDeclKind; } bool isDeclGroup() const { return getKind() == DeclGroupKind; } @@ -88,7 +88,7 @@ public: const Decl *getSingleDecl() const { return const_cast<DeclGroupRef*>(this)->getSingleDecl(); } - + DeclGroup &getDeclGroup() { assert(isDeclGroup() && "Isn't a declgroup"); return *((DeclGroup*)(reinterpret_cast<uintptr_t>(D) & ~Mask)); @@ -96,7 +96,7 @@ public: const DeclGroup &getDeclGroup() const { return const_cast<DeclGroupRef*>(this)->getDeclGroup(); } - + iterator begin() { if (isSingleDecl()) return D ? &D : 0; @@ -109,13 +109,13 @@ public: DeclGroup &G = getDeclGroup(); return &G[0] + G.size(); } - + const_iterator begin() const { if (isSingleDecl()) return D ? &D : 0; return &getDeclGroup()[0]; } - + const_iterator end() const { if (isSingleDecl()) return D ? &D+1 : 0; @@ -130,7 +130,7 @@ public: return X; } }; - + } // end clang namespace namespace llvm { |