[cfe-commits] r64802 - in /cfe/trunk/lib/Sema: IdentifierResolver.cpp IdentifierResolver.h

Argiris Kirtzidis akyrtzi at gmail.com
Tue Feb 17 12:21:51 PST 2009


Author: akirtzidis
Date: Tue Feb 17 14:21:51 2009
New Revision: 64802

URL: http://llvm.org/viewvc/llvm-project?rev=64802&view=rev
Log:
Now that ObjC decls have DeclContexts too, remove an ugly hack from IdentifierResolver.

Modified:
    cfe/trunk/lib/Sema/IdentifierResolver.cpp
    cfe/trunk/lib/Sema/IdentifierResolver.h

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

==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Tue Feb 17 14:21:51 2009
@@ -43,39 +43,6 @@
 
 
 //===----------------------------------------------------------------------===//
-// LookupContext Implementation
-//===----------------------------------------------------------------------===//
-
-/// getContext - Returns translation unit context for non Decls and
-/// for EnumConstantDecls returns the parent context of their EnumDecl.
-DeclContext *IdentifierResolver::LookupContext::getContext(Decl *D) {
-  DeclContext *Ctx = D->getDeclContext();
-
-  if (!Ctx) // FIXME: HACK! We shouldn't end up with a NULL context here.
-    return TUCtx();
-
-  Ctx = Ctx->getLookupContext();
-
-  if (isa<TranslationUnitDecl>(Ctx))
-    return TUCtx();
-
-  return Ctx;
-}
-
-/// isEqOrContainedBy - Returns true of the given context is the same or a
-/// parent of this one.
-bool IdentifierResolver::LookupContext::isEqOrContainedBy(
-                                                const LookupContext &PC) const {
-  if (PC.isTU()) return true;
-
-  for (LookupContext Next = *this; !Next.isTU();  Next = Next.getParent())
-    if (Next.Ctx == PC.Ctx) return true;
-
-  return false;
-}
-
-
-//===----------------------------------------------------------------------===//
 // IdDeclInfo Implementation
 //===----------------------------------------------------------------------===//
 
@@ -155,7 +122,7 @@
     return false;
   }
 
-  return LookupContext(D) == LookupContext(Ctx->getPrimaryContext());
+  return D->getDeclContext()->getLookupContext() == Ctx->getPrimaryContext();
 }
 
 /// AddDecl - Link the decl to its shadowed decl chain.

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

==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.h (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.h Tue Feb 17 14:21:51 2009
@@ -28,58 +28,6 @@
 /// implements efficent decl lookup based on a declaration name.
 class IdentifierResolver {
 
-  /// LookupContext - A wrapper for DeclContext. DeclContext is only part of
-  /// Decls, LookupContext can be used with all decls (assumes
-  /// translation unit context for non Decls).
-  class LookupContext {
-    const DeclContext *Ctx;
-
-    /// TUCtx - Provides a common value for translation unit context for all
-    /// decls.
-    /// FIXME: When (if ?) all decls can point to their translation unit context
-    /// remove this hack.
-    static inline DeclContext *TUCtx() {
-      return reinterpret_cast<DeclContext*>(-1);
-    }
-
-    /// getContext - Returns translation unit context for non Decls and
-    /// for EnumConstantDecls returns the parent context of their EnumDecl.
-    static DeclContext *getContext(Decl *D);
-
-  public:
-    LookupContext(Decl *D) {
-      Ctx = getContext(D);
-    }
-    LookupContext(const DeclContext *DC) {
-      if (!DC || isa<TranslationUnitDecl>(DC))
-        Ctx = TUCtx();
-      else
-        Ctx = DC;
-    }
-
-    bool isTU() const {
-      return (Ctx == TUCtx());
-    }
-
-    /// getParent - Returns the parent context. This should not be called for
-    /// a translation unit context.
-    LookupContext getParent() const {
-      assert(!isTU() && "TU has no parent!");
-      return LookupContext(Ctx->getParent());
-    }
-
-    /// isEqOrContainedBy - Returns true of the given context is the same or a
-    /// parent of this one.
-    bool isEqOrContainedBy(const LookupContext &PC) const;
-
-    bool operator==(const LookupContext &RHS) const {
-      return Ctx == RHS.Ctx;
-    }
-    bool operator!=(const LookupContext &RHS) const {
-      return Ctx != RHS.Ctx;
-    }
-  };
-
   /// IdDeclInfo - Keeps track of information about decls associated
   /// to a particular declaration name. IdDeclInfos are lazily
   /// constructed and assigned to a declaration name the first time a





More information about the cfe-commits mailing list