diff options
Diffstat (limited to 'include/clang/AST/DeclGroup.h')
-rw-r--r-- | include/clang/AST/DeclGroup.h | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h index 6353b26f7bf5..6d5aaadf529c 100644 --- a/include/clang/AST/DeclGroup.h +++ b/include/clang/AST/DeclGroup.h @@ -1,4 +1,4 @@ -//===--- DeclGroup.h - Classes for representing groups of Decls -*- C++ -*-===// +//===- DeclGroup.h - Classes for representing groups of Decls ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,26 +14,26 @@ #ifndef LLVM_CLANG_AST_DECLGROUP_H #define LLVM_CLANG_AST_DECLGROUP_H -#include "llvm/Support/DataTypes.h" #include "llvm/Support/TrailingObjects.h" #include <cassert> +#include <cstdint> namespace clang { class ASTContext; class Decl; -class DeclGroup; -class DeclGroupIterator; class DeclGroup final : private llvm::TrailingObjects<DeclGroup, Decl *> { // FIXME: Include a TypeSpecifier object. - unsigned NumDecls; + unsigned NumDecls = 0; private: - DeclGroup() : NumDecls(0) {} + DeclGroup() = default; DeclGroup(unsigned numdecls, Decl** decls); public: + friend TrailingObjects; + static DeclGroup *Create(ASTContext &C, Decl **Decls, unsigned NumDecls); unsigned size() const { return NumDecls; } @@ -47,23 +47,21 @@ public: assert (i < NumDecls && "Out-of-bounds access."); return getTrailingObjects<Decl *>()[i]; } - - friend TrailingObjects; }; 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 }; - Decl* D; + + Decl* D = nullptr; Kind getKind() const { return (Kind) (reinterpret_cast<uintptr_t>(D) & Mask); } public: - DeclGroupRef() : D(nullptr) {} - + DeclGroupRef() = default; explicit DeclGroupRef(Decl* d) : D(d) {} explicit DeclGroupRef(DeclGroup* dg) : D((Decl*) (reinterpret_cast<uintptr_t>(dg) | DeclGroupKind)) {} @@ -76,8 +74,8 @@ public: return DeclGroupRef(DeclGroup::Create(C, Decls, NumDecls)); } - typedef Decl** iterator; - typedef Decl* const * const_iterator; + using iterator = Decl **; + using const_iterator = Decl * const *; bool isNull() const { return D == nullptr; } bool isSingleDecl() const { return getKind() == SingleDeclKind; } @@ -133,22 +131,26 @@ public: } }; -} // end clang namespace +} // namespace clang namespace llvm { + // DeclGroupRef is "like a pointer", implement PointerLikeTypeTraits. template <typename T> - class PointerLikeTypeTraits; + struct PointerLikeTypeTraits; template <> - class PointerLikeTypeTraits<clang::DeclGroupRef> { - public: + struct PointerLikeTypeTraits<clang::DeclGroupRef> { static inline void *getAsVoidPointer(clang::DeclGroupRef P) { return P.getAsOpaquePtr(); } + static inline clang::DeclGroupRef getFromVoidPointer(void *P) { return clang::DeclGroupRef::getFromOpaquePtr(P); } + enum { NumLowBitsAvailable = 0 }; }; -} -#endif + +} // namespace llvm + +#endif // LLVM_CLANG_AST_DECLGROUP_H |