[cfe-commits] r76275 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Fri Jul 17 17:34:35 PDT 2009


Author: akirtzidis
Date: Fri Jul 17 19:34:35 2009
New Revision: 76275

URL: http://llvm.org/viewvc/llvm-project?rev=76275&view=rev
Log:
Remove getFirstDeclaration/getLatestDeclaration from FunctionDecl and VarDecl.

Their usefulness is questionable since redecl_iterator was introduced.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=76275&r1=76274&r2=76275&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Jul 17 19:34:35 2009
@@ -422,21 +422,6 @@
 
   void setPreviousDeclaration(VarDecl *PrevDecl);
 
-  /// \brief For multiple redeclarations returns the first one, otherwise
-  /// returns itself.
-  VarDecl *getFirstDeclaration();
-  const VarDecl *getFirstDeclaration() const {
-    return const_cast<VarDecl *>(this)->getFirstDeclaration();
-  }
-
-  /// \brief For multiple redeclarations returns the latest, otherwise
-  /// returns itself.
-  const VarDecl *getLatestDeclaration() const {
-    const VarDecl *First = getFirstDeclaration();
-    assert(First->PreviousDeclaration.getInt() == 1 && "Expected first");
-    return First->PreviousDeclaration.getPointer();
-  }
-
   virtual VarDecl *getCanonicalDecl();
 
   /// \brief Iterates through all the redeclarations of the same var decl.
@@ -891,21 +876,6 @@
     return const_cast<FunctionDecl *>(this)->getPreviousDeclaration();
   }
 
-  /// \brief For multiple redeclarations returns the first one, otherwise
-  /// returns itself.
-  FunctionDecl *getFirstDeclaration();
-  const FunctionDecl *getFirstDeclaration() const {
-    return const_cast<FunctionDecl *>(this)->getFirstDeclaration();
-  }
-
-  /// \brief For multiple redeclarations returns the latest, otherwise
-  /// returns itself.
-  const FunctionDecl *getLatestDeclaration() const {
-    const FunctionDecl *First = getFirstDeclaration();
-    assert(First->PreviousDeclaration.getInt() == 1 && "Expected first");
-    return First->PreviousDeclaration.getPointer();
-  }
-
   void setPreviousDeclaration(FunctionDecl * PrevDecl);
 
   virtual FunctionDecl *getCanonicalDecl();

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=76275&r1=76274&r2=76275&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Jul 17 19:34:35 2009
@@ -369,7 +369,8 @@
     PreviousDeclaration.setInt(0);
     
     // First one will point to this one as latest.
-    VarDecl *First = PrevDecl->getFirstDeclaration();
+    // getCanonicalDecl returns the first one.
+    VarDecl *First = PrevDecl->getCanonicalDecl();
     assert(First->PreviousDeclaration.getInt() == 1 && "Expected first");
     First->PreviousDeclaration.setPointer(this);
   } else {
@@ -379,14 +380,6 @@
   }
 }
 
-VarDecl *VarDecl::getFirstDeclaration() {
-  VarDecl *First = this;
-  while (First->getPreviousDeclaration())
-    First = First->getPreviousDeclaration();
-
-  return First;
-}
-
 VarDecl *VarDecl::getCanonicalDecl() {
   VarDecl *Var = this;
   while (Var->getPreviousDeclaration())
@@ -599,7 +592,8 @@
     PreviousDeclaration.setInt(0);
     
     // First one will point to this one as latest.
-    FunctionDecl *First = PrevDecl->getFirstDeclaration();
+    // getCanonicalDecl returns the first one.
+    FunctionDecl *First = PrevDecl->getCanonicalDecl();
     assert(First->PreviousDeclaration.getInt() == 1 && "Expected first");
     First->PreviousDeclaration.setPointer(this);
   } else {
@@ -616,14 +610,6 @@
   }
 }
 
-FunctionDecl *FunctionDecl::getFirstDeclaration() {
-  FunctionDecl *First = this;
-  while (First->getPreviousDeclaration())
-    First = First->getPreviousDeclaration();
-
-  return First;
-}
-
 FunctionDecl *FunctionDecl::getCanonicalDecl() {
   FunctionDecl *FD = this;
   while (FD->getPreviousDeclaration())





More information about the cfe-commits mailing list