aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/Redeclarable.h
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-05-28 19:38:42 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-05-28 19:38:42 +0000
commitdec17760923a23c5a185944d14d7455df6b09d86 (patch)
tree0b7b89eecd907dff567cc0dfd4184428008b15ed /include/clang/AST/Redeclarable.h
parentc1fd52b4b08384697428206a758125cb4a62d83f (diff)
downloadclang-dec17760923a23c5a185944d14d7455df6b09d86.tar.gz
Address minor FIXME in RedeclLink to contain a PointerIntPair instead of derive from it.
Use actual factory functions rather than derived classes acting as named constructors/factories. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/Redeclarable.h')
-rw-r--r--include/clang/AST/Redeclarable.h29
1 files changed, 14 insertions, 15 deletions
diff --git a/include/clang/AST/Redeclarable.h b/include/clang/AST/Redeclarable.h
index 88abadb26a..e3b340a5a1 100644
--- a/include/clang/AST/Redeclarable.h
+++ b/include/clang/AST/Redeclarable.h
@@ -25,26 +25,25 @@ template<typename decl_type>
class Redeclarable {
protected:
- // FIXME: PointerIntPair is a value class that should not be inherited from.
- // This should change to using containment.
- struct DeclLink : public llvm::PointerIntPair<decl_type *, 1, bool> {
+ class DeclLink {
+ llvm::PointerIntPair<decl_type *, 1, bool> NextAndIsPrevious;
+ public:
DeclLink(decl_type *D, bool isLatest)
- : llvm::PointerIntPair<decl_type *, 1, bool>(D, isLatest) { }
-
- typedef llvm::PointerIntPair<decl_type *, 1, bool> base_type;
+ : NextAndIsPrevious(D, isLatest) { }
- bool NextIsPrevious() const { return base_type::getInt() == false; }
- bool NextIsLatest() const { return base_type::getInt() == true; }
- decl_type *getNext() const { return base_type::getPointer(); }
+ bool NextIsPrevious() const { return !NextAndIsPrevious.getInt(); }
+ bool NextIsLatest() const { return NextAndIsPrevious.getInt(); }
+ decl_type *getNext() const { return NextAndIsPrevious.getPointer(); }
+ void setNext(decl_type *D) { NextAndIsPrevious.setPointer(D); }
};
- struct PreviousDeclLink : public DeclLink {
- PreviousDeclLink(decl_type *D) : DeclLink(D, false) { }
- };
+ static DeclLink PreviousDeclLink(decl_type *D) {
+ return DeclLink(D, false);
+ }
- struct LatestDeclLink : public DeclLink {
- LatestDeclLink(decl_type *D) : DeclLink(D, true) { }
- };
+ static DeclLink LatestDeclLink(decl_type *D) {
+ return DeclLink(D, true);
+ }
/// \brief Points to the next redeclaration in the chain.
///