[cfe-commits] r90313 - in /cfe/trunk: include/clang/AST/DeclCXX.h include/clang/AST/DeclNodes.def lib/AST/DeclBase.cpp lib/AST/DeclCXX.cpp lib/AST/DeclPrinter.cpp lib/AST/Expr.cpp lib/AST/StmtProfile.cpp lib/Sema/Lookup.h lib/Sema/SemaOverload.cpp

John McCall rjmccall at apple.com
Wed Dec 2 00:47:38 PST 2009


Author: rjmccall
Date: Wed Dec  2 02:47:38 2009
New Revision: 90313

URL: http://llvm.org/viewvc/llvm-project?rev=90313&view=rev
Log:
r90313, in which OverloadedFunctionDecl is removed and never spoken of again.


Modified:
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/include/clang/AST/DeclNodes.def
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/AST/DeclPrinter.cpp
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/AST/StmtProfile.cpp
    cfe/trunk/lib/Sema/Lookup.h
    cfe/trunk/lib/Sema/SemaOverload.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Dec  2 02:47:38 2009
@@ -88,108 +88,6 @@
 
 namespace clang {
 
-/// OverloadedFunctionDecl - An instance of this class represents a
-/// set of overloaded functions. All of the functions have the same
-/// name and occur within the same scope.
-///
-/// An OverloadedFunctionDecl has no ownership over the FunctionDecl
-/// nodes it contains. Rather, the FunctionDecls are owned by the
-/// enclosing scope (which also owns the OverloadedFunctionDecl
-/// node). OverloadedFunctionDecl is used primarily to store a set of
-/// overloaded functions for name lookup.
-class OverloadedFunctionDecl : public NamedDecl {
-protected:
-  OverloadedFunctionDecl(DeclContext *DC, DeclarationName N)
-    : NamedDecl(OverloadedFunction, DC, SourceLocation(), N) { }
-
-  /// Functions - the set of overloaded functions contained in this
-  /// overload set.
-  llvm::SmallVector<AnyFunctionDecl, 4> Functions;
-
-  // FIXME: This should go away when we stop using
-  // OverloadedFunctionDecl to store conversions in CXXRecordDecl.
-  friend class CXXRecordDecl;
-
-public:
-  typedef llvm::SmallVector<AnyFunctionDecl, 4>::iterator function_iterator;
-  typedef llvm::SmallVector<AnyFunctionDecl, 4>::const_iterator
-    function_const_iterator;
-
-  static OverloadedFunctionDecl *Create(ASTContext &C, DeclContext *DC,
-                                        DeclarationName N);
-
-  /// \brief Add a new overloaded function or function template to the set
-  /// of overloaded function templates.
-  void addOverload(AnyFunctionDecl F);
-
-  function_iterator function_begin() { return Functions.begin(); }
-  function_iterator function_end() { return Functions.end(); }
-  function_const_iterator function_begin() const { return Functions.begin(); }
-  function_const_iterator function_end() const { return Functions.end(); }
-
-  /// \brief Returns the number of overloaded functions stored in
-  /// this set.
-  unsigned size() const { return Functions.size(); }
-
-  // Implement isa/cast/dyncast/etc.
-  static bool classof(const Decl *D) {
-    return D->getKind() == OverloadedFunction;
-  }
-  static bool classof(const OverloadedFunctionDecl *D) { return true; }
-};
-
-/// \brief Provides uniform iteration syntax for an overload set, function,
-/// or function template.
-class OverloadIterator {
-  /// \brief An overloaded function set, function declaration, or
-  /// function template declaration.
-  NamedDecl *D;
-
-  /// \brief If the declaration is an overloaded function set, this is the
-  /// iterator pointing to the current position within that overloaded
-  /// function set.
-  OverloadedFunctionDecl::function_iterator Iter;
-
-public:
-  typedef AnyFunctionDecl value_type;
-  typedef value_type      reference;
-  typedef NamedDecl      *pointer;
-  typedef int             difference_type;
-  typedef std::forward_iterator_tag iterator_category;
-
-  OverloadIterator() : D(0) { }
-
-  OverloadIterator(FunctionDecl *FD) : D(FD) { }
-  OverloadIterator(FunctionTemplateDecl *FTD)
-    : D(reinterpret_cast<NamedDecl*>(FTD)) { }
-  OverloadIterator(OverloadedFunctionDecl *Ovl)
-    : D(Ovl), Iter(Ovl->function_begin()) { }
-
-  OverloadIterator(NamedDecl *ND);
-
-  reference operator*() const;
-
-  pointer operator->() const { return (**this).get(); }
-
-  OverloadIterator &operator++();
-
-  OverloadIterator operator++(int) {
-    OverloadIterator Temp(*this);
-    ++(*this);
-    return Temp;
-  }
-
-  bool Equals(const OverloadIterator &Other) const;
-};
-
-inline bool operator==(const OverloadIterator &X, const OverloadIterator &Y) {
-  return X.Equals(Y);
-}
-
-inline bool operator!=(const OverloadIterator &X, const OverloadIterator &Y) {
-  return !(X == Y);
-}
-
 /// CXXBaseSpecifier - A base class of a C++ class.
 ///
 /// Each CXXBaseSpecifier represents a single, direct base class (or

Modified: cfe/trunk/include/clang/AST/DeclNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclNodes.def?rev=90313&r1=90312&r2=90313&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclNodes.def (original)
+++ cfe/trunk/include/clang/AST/DeclNodes.def Wed Dec  2 02:47:38 2009
@@ -75,7 +75,6 @@
 
 DECL(TranslationUnit, Decl)
 ABSTRACT_DECL(Named,  Decl)
-  DECL(OverloadedFunction, NamedDecl)
   DECL(Namespace, NamedDecl)
   DECL(UsingDirective, NamedDecl)
   DECL(NamespaceAlias, NamedDecl)
@@ -143,7 +142,7 @@
 LAST_DECL_CONTEXT(Block)
 
 // Declaration ranges
-DECL_RANGE(Named, OverloadedFunction, ObjCCompatibleAlias)
+DECL_RANGE(Named, Namespace, ObjCCompatibleAlias)
 DECL_RANGE(ObjCContainer, ObjCContainer, ObjCImplementation)
 DECL_RANGE(Field, Field, ObjCAtDefsField)
 DECL_RANGE(Type, Typedef, TemplateTypeParm)

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

==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Dec  2 02:47:38 2009
@@ -190,7 +190,6 @@
     case CXXConstructor:
     case CXXDestructor:
     case CXXConversion:
-    case OverloadedFunction:
     case Typedef:
     case EnumConstant:
     case Var:

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

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Wed Dec  2 02:47:38 2009
@@ -797,64 +797,6 @@
   return new (C) CXXConversionDecl(RD, L, N, T, DInfo, isInline, isExplicit);
 }
 
-OverloadedFunctionDecl *
-OverloadedFunctionDecl::Create(ASTContext &C, DeclContext *DC,
-                               DeclarationName N) {
-  return new (C) OverloadedFunctionDecl(DC, N);
-}
-
-OverloadIterator::OverloadIterator(NamedDecl *ND) : D(0) {
-  if (!ND)
-    return;
-
-  if (isa<FunctionDecl>(ND) || isa<FunctionTemplateDecl>(ND))
-    D = ND;
-  else if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(ND)) {
-    if (Ovl->size() != 0) {
-      D = ND;
-      Iter = Ovl->function_begin();
-    }
-  }
-}
-
-void OverloadedFunctionDecl::addOverload(AnyFunctionDecl F) {
-  Functions.push_back(F);
-  this->setLocation(F.get()->getLocation());
-}
-
-OverloadIterator::reference OverloadIterator::operator*() const {
-  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
-    return FD;
-
-  if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(D))
-    return FTD;
-
-  assert(isa<OverloadedFunctionDecl>(D));
-  return *Iter;
-}
-
-OverloadIterator &OverloadIterator::operator++() {
-  if (isa<FunctionDecl>(D) || isa<FunctionTemplateDecl>(D)) {
-    D = 0;
-    return *this;
-  }
-
-  if (++Iter == cast<OverloadedFunctionDecl>(D)->function_end())
-    D = 0;
-
-  return *this;
-}
-
-bool OverloadIterator::Equals(const OverloadIterator &Other) const {
-  if (!D || !Other.D)
-    return D == Other.D;
-
-  if (D != Other.D)
-    return false;
-
-  return !isa<OverloadedFunctionDecl>(D) || Iter == Other.Iter;
-}
-
 FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC,
                                SourceLocation L,
                                FriendUnion Friend,

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

==============================================================================
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Wed Dec  2 02:47:38 2009
@@ -52,7 +52,6 @@
     void VisitVarDecl(VarDecl *D);
     void VisitParmVarDecl(ParmVarDecl *D);
     void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
-    void VisitOverloadedFunctionDecl(OverloadedFunctionDecl *D);
     void VisitNamespaceDecl(NamespaceDecl *D);
     void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
     void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
@@ -488,11 +487,6 @@
 //----------------------------------------------------------------------------
 // C++ declarations
 //----------------------------------------------------------------------------
-void DeclPrinter::VisitOverloadedFunctionDecl(OverloadedFunctionDecl *D) {
-  assert(false &&
-         "OverloadedFunctionDecls aren't really decls and are never printed");
-}
-
 void DeclPrinter::VisitNamespaceDecl(NamespaceDecl *D) {
   Out << "namespace " << D->getNameAsString() << " {\n";
   VisitDeclContext(D);

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

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Dec  2 02:47:38 2009
@@ -118,7 +118,6 @@
                (Qualifier? HasQualifierFlag : 0) |
                (TemplateArgs ? HasExplicitTemplateArgumentListFlag : 0)),
     Loc(NameLoc) {
-  assert(!isa<OverloadedFunctionDecl>(D));
   if (Qualifier) {
     NameQualifier *NQ = getNameQualifier();
     NQ->NNS = Qualifier;
@@ -944,8 +943,7 @@
   return isa<VarDecl>(Decl) || isa<FieldDecl>(Decl) ||
     // C++ 3.10p2: An lvalue refers to an object or function.
     (Ctx.getLangOptions().CPlusPlus &&
-     (isa<FunctionDecl>(Decl) || isa<OverloadedFunctionDecl>(Decl) ||
-      isa<FunctionTemplateDecl>(Decl)));
+     (isa<FunctionDecl>(Decl) || isa<FunctionTemplateDecl>(Decl)));
 }
 
 /// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or an

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

==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Wed Dec  2 02:47:38 2009
@@ -659,13 +659,6 @@
       ID.AddInteger(TTP->getIndex());
       return;
     }
-
-    if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(D)) {
-      // The Itanium C++ ABI mangles references to a set of overloaded
-      // functions using just the function name, so we do the same here.
-      VisitName(Ovl->getDeclName());
-      return;
-    }
   }
 
   ID.AddPointer(D? D->getCanonicalDecl() : 0);

Modified: cfe/trunk/lib/Sema/Lookup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Lookup.h?rev=90313&r1=90312&r2=90313&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Lookup.h (original)
+++ cfe/trunk/lib/Sema/Lookup.h Wed Dec  2 02:47:38 2009
@@ -33,12 +33,11 @@
     NotFound = 0,
 
     /// @brief Name lookup found a single declaration that met the
-    /// criteria. getAsDecl will return this declaration.
+    /// criteria.  getFoundDecl() will return this declaration.
     Found,
 
     /// @brief Name lookup found a set of overloaded functions that
-    /// met the criteria. getAsDecl will turn this set of overloaded
-    /// functions into an OverloadedFunctionDecl.
+    /// met the criteria.
     FoundOverloaded,
 
     /// @brief Name lookup found an unresolvable value declaration

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=90313&r1=90312&r2=90313&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Dec  2 02:47:38 2009
@@ -255,12 +255,13 @@
 }
 
 // IsOverload - Determine whether the given New declaration is an
-// overload of the Old declaration. This routine returns false if New
-// and Old cannot be overloaded, e.g., if they are functions with the
-// same signature (C++ 1.3.10) or if the Old declaration isn't a
-// function (or overload set). When it does return false and Old is an
-// OverloadedFunctionDecl, MatchedDecl will be set to point to the
-// FunctionDecl that New cannot be overloaded with.
+// overload of the declarations in Old. This routine returns false if
+// New and Old cannot be overloaded, e.g., if New has the same
+// signature as some function in Old (C++ 1.3.10) or if the Old
+// declarations aren't functions (or function templates) at all. When
+// it does return false and Old is an overload set, MatchedDecl will
+// be set to point to the FunctionDecl that New cannot be overloaded
+// with.
 //
 // Example: Given the following input:
 //
@@ -271,37 +272,37 @@
 // When we process #1, there is no previous declaration of "f",
 // so IsOverload will not be used.
 //
-// When we process #2, Old is a FunctionDecl for #1.  By comparing the
-// parameter types, we see that #1 and #2 are overloaded (since they
-// have different signatures), so this routine returns false;
-// MatchedDecl is unchanged.
+// When we process #2, Old contains only the FunctionDecl for #1.  By
+// comparing the parameter types, we see that #1 and #2 are overloaded
+// (since they have different signatures), so this routine returns
+// false; MatchedDecl is unchanged.
 //
-// When we process #3, Old is an OverloadedFunctionDecl containing #1
-// and #2. We compare the signatures of #3 to #1 (they're overloaded,
-// so we do nothing) and then #3 to #2. Since the signatures of #3 and
-// #2 are identical (return types of functions are not part of the
+// When we process #3, Old is an overload set containing #1 and #2. We
+// compare the signatures of #3 to #1 (they're overloaded, so we do
+// nothing) and then #3 to #2. Since the signatures of #3 and #2 are
+// identical (return types of functions are not part of the
 // signature), IsOverload returns false and MatchedDecl will be set to
 // point to the FunctionDecl for #2.
 bool
-Sema::IsOverload(FunctionDecl *New, LookupResult &Previous, NamedDecl *&Match) {
-  for (LookupResult::iterator I = Previous.begin(), E = Previous.end();
+Sema::IsOverload(FunctionDecl *New, LookupResult &Old, NamedDecl *&Match) {
+  for (LookupResult::iterator I = Old.begin(), E = Old.end();
          I != E; ++I) {
-    NamedDecl *Old = (*I)->getUnderlyingDecl();
-    if (FunctionTemplateDecl *OldT = dyn_cast<FunctionTemplateDecl>(Old)) {
+    NamedDecl *OldD = (*I)->getUnderlyingDecl();
+    if (FunctionTemplateDecl *OldT = dyn_cast<FunctionTemplateDecl>(OldD)) {
       if (!IsOverload(New, OldT->getTemplatedDecl())) {
-        Match = Old;
+        Match = OldT;
         return false;
       }
-    } else if (FunctionDecl *OldF = dyn_cast<FunctionDecl>(Old)) {
+    } else if (FunctionDecl *OldF = dyn_cast<FunctionDecl>(OldD)) {
       if (!IsOverload(New, OldF)) {
-        Match = Old;
+        Match = OldF;
         return false;
       }
     } else {
       // (C++ 13p1):
       //   Only function declarations can be overloaded; object and type
       //   declarations cannot be overloaded.
-      Match = Old;
+      Match = OldD;
       return false;
     }
   }





More information about the cfe-commits mailing list