r208467 - Stop all the Decl classes poking at Redeclarable's data member directly, and make getNextRedeclaration follow the pattern of its friends getPreviousDecl and getMostRecentDecl.
Richard Smith
richard-llvm at metafoo.co.uk
Fri May 9 18:17:36 PDT 2014
Author: rsmith
Date: Fri May 9 20:17:36 2014
New Revision: 208467
URL: http://llvm.org/viewvc/llvm-project?rev=208467&view=rev
Log:
Stop all the Decl classes poking at Redeclarable's data member directly, and make getNextRedeclaration follow the pattern of its friends getPreviousDecl and getMostRecentDecl.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/AST/Redeclarable.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri May 9 20:17:36 2014
@@ -359,7 +359,7 @@ class NamespaceDecl : public NamedDecl,
NamespaceDecl *PrevDecl);
typedef Redeclarable<NamespaceDecl> redeclarable_base;
- NamespaceDecl *getNextRedeclaration() override;
+ NamespaceDecl *getNextRedeclarationImpl() override;
NamespaceDecl *getPreviousDeclImpl() override;
NamespaceDecl *getMostRecentDeclImpl() override;
@@ -773,7 +773,9 @@ protected:
TypeSourceInfo *TInfo, StorageClass SC);
typedef Redeclarable<VarDecl> redeclarable_base;
- VarDecl *getNextRedeclaration() override { return RedeclLink.getNext(); }
+ VarDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
+ }
VarDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
}
@@ -1553,7 +1555,9 @@ protected:
DNLoc(NameInfo.getInfo()) {}
typedef Redeclarable<FunctionDecl> redeclarable_base;
- FunctionDecl *getNextRedeclaration() override { return RedeclLink.getNext(); }
+ FunctionDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
+ }
FunctionDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
}
@@ -2406,8 +2410,8 @@ protected:
: TypeDecl(DK, DC, IdLoc, Id, StartLoc), MaybeModedTInfo(TInfo) {}
typedef Redeclarable<TypedefNameDecl> redeclarable_base;
- TypedefNameDecl *getNextRedeclaration() override {
- return RedeclLink.getNext();
+ TypedefNameDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
}
TypedefNameDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
@@ -2590,7 +2594,9 @@ protected:
}
typedef Redeclarable<TagDecl> redeclarable_base;
- TagDecl *getNextRedeclaration() override { return RedeclLink.getNext(); }
+ TagDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
+ }
TagDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
}
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri May 9 20:17:36 2014
@@ -713,16 +713,16 @@ protected:
///
/// Decl subclasses that can be redeclared should override this method so that
/// Decl::redecl_iterator can iterate over them.
- virtual Decl *getNextRedeclaration() { return this; }
+ virtual Decl *getNextRedeclarationImpl() { return this; }
/// \brief Implementation of getPreviousDecl(), to be overridden by any
/// subclass that has a redeclaration chain.
virtual Decl *getPreviousDeclImpl() { return nullptr; }
-
+
/// \brief Implementation of getMostRecentDecl(), to be overridden by any
- /// subclass that has a redeclaration chain.
+ /// subclass that has a redeclaration chain.
virtual Decl *getMostRecentDeclImpl() { return this; }
-
+
public:
/// \brief Iterates through all the redeclarations of the same decl.
class redecl_iterator {
@@ -746,7 +746,7 @@ public:
redecl_iterator& operator++() {
assert(Current && "Advancing while iterator has reached end");
// Get either previous decl or latest decl.
- Decl *Next = Current->getNextRedeclaration();
+ Decl *Next = Current->getNextRedeclarationImpl();
assert(Next && "Should return next redeclaration or itself, never null!");
Current = (Next != Starter) ? Next : nullptr;
return *this;
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 9 20:17:36 2014
@@ -2721,8 +2721,8 @@ class UsingShadowDecl : public NamedDecl
}
typedef Redeclarable<UsingShadowDecl> redeclarable_base;
- UsingShadowDecl *getNextRedeclaration() override {
- return RedeclLink.getNext();
+ UsingShadowDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
}
UsingShadowDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri May 9 20:17:36 2014
@@ -247,7 +247,7 @@ private:
/// \brief A definition will return its interface declaration.
/// An interface declaration will return its definition.
/// Otherwise it will return itself.
- ObjCMethodDecl *getNextRedeclaration() override;
+ ObjCMethodDecl *getNextRedeclarationImpl() override;
public:
static ObjCMethodDecl *
@@ -756,8 +756,8 @@ class ObjCInterfaceDecl : public ObjCCon
void allocateDefinitionData();
typedef Redeclarable<ObjCInterfaceDecl> redeclarable_base;
- ObjCInterfaceDecl *getNextRedeclaration() override {
- return RedeclLink.getNext();
+ ObjCInterfaceDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
}
ObjCInterfaceDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
@@ -1531,8 +1531,8 @@ class ObjCProtocolDecl : public ObjCCont
void allocateDefinitionData();
typedef Redeclarable<ObjCProtocolDecl> redeclarable_base;
- ObjCProtocolDecl *getNextRedeclaration() override {
- return RedeclLink.getNext();
+ ObjCProtocolDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
}
ObjCProtocolDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Fri May 9 20:17:36 2014
@@ -532,8 +532,8 @@ class RedeclarableTemplateDecl : public
public Redeclarable<RedeclarableTemplateDecl>
{
typedef Redeclarable<RedeclarableTemplateDecl> redeclarable_base;
- RedeclarableTemplateDecl *getNextRedeclaration() override {
- return RedeclLink.getNext();
+ RedeclarableTemplateDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
}
RedeclarableTemplateDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
Modified: cfe/trunk/include/clang/AST/Redeclarable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Redeclarable.h?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Redeclarable.h (original)
+++ cfe/trunk/include/clang/AST/Redeclarable.h Fri May 9 20:17:36 2014
@@ -23,7 +23,6 @@ namespace clang {
/// \brief Provides common interface for the Decls that can be redeclared.
template<typename decl_type>
class Redeclarable {
-
protected:
class DeclLink {
llvm::PointerIntPair<decl_type *, 1, bool> NextAndIsPrevious;
@@ -58,6 +57,10 @@ protected:
/// If there is only one declaration, it is <pointer to self, true>
DeclLink RedeclLink;
+ decl_type *getNextRedeclaration() const {
+ return RedeclLink.getNext();
+ }
+
public:
Redeclarable() : RedeclLink(LatestDeclLink(static_cast<decl_type*>(this))) { }
@@ -65,7 +68,7 @@ public:
/// is the first declaration.
decl_type *getPreviousDecl() {
if (RedeclLink.NextIsPrevious())
- return RedeclLink.getNext();
+ return getNextRedeclaration();
return nullptr;
}
const decl_type *getPreviousDecl() const {
@@ -96,12 +99,12 @@ public:
/// \brief Returns the most recent (re)declaration of this declaration.
decl_type *getMostRecentDecl() {
- return getFirstDecl()->RedeclLink.getNext();
+ return getFirstDecl()->getNextRedeclaration();
}
/// \brief Returns the most recent (re)declaration of this declaration.
const decl_type *getMostRecentDecl() const {
- return getFirstDecl()->RedeclLink.getNext();
+ return getFirstDecl()->getNextRedeclaration();
}
/// \brief Set the previous declaration. If PrevDecl is NULL, set this as the
@@ -142,7 +145,7 @@ public:
}
// Get either previous decl or latest decl.
- decl_type *Next = Current->RedeclLink.getNext();
+ decl_type *Next = Current->getNextRedeclaration();
Current = (Next != Starter) ? Next : nullptr;
return *this;
}
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri May 9 20:17:36 2014
@@ -1946,8 +1946,8 @@ NamespaceDecl *NamespaceDecl::CreateDese
0, 0);
}
-NamespaceDecl *NamespaceDecl::getNextRedeclaration() {
- return RedeclLink.getNext();
+NamespaceDecl *NamespaceDecl::getNextRedeclarationImpl() {
+ return getNextRedeclaration();
}
NamespaceDecl *NamespaceDecl::getPreviousDeclImpl() {
return getPreviousDecl();
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=208467&r1=208466&r2=208467&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri May 9 20:17:36 2014
@@ -721,7 +721,7 @@ void ObjCMethodDecl::setMethodParams(AST
/// \brief A definition will return its interface declaration.
/// An interface declaration will return its definition.
/// Otherwise it will return itself.
-ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() {
+ObjCMethodDecl *ObjCMethodDecl::getNextRedeclarationImpl() {
ASTContext &Ctx = getASTContext();
ObjCMethodDecl *Redecl = 0;
if (HasRedeclaration)
More information about the cfe-commits
mailing list