[cfe-commits] r63256 - in /cfe/trunk/lib/Sema: Sema.h SemaDecl.cpp SemaDeclCXX.cpp SemaDeclObjC.cpp SemaExpr.cpp SemaExprCXX.cpp SemaExprObjC.cpp SemaTemplate.cpp

Steve Naroff snaroff at apple.com
Wed Jan 28 16:07:50 PST 2009


Author: snaroff
Date: Wed Jan 28 18:07:50 2009
New Revision: 63256

URL: http://llvm.org/viewvc/llvm-project?rev=63256&view=rev
Log:
Refactor Sema::LookupDecl() into 2 functions: LookupDeclInScope() and LookupDeclInContext().

The previous interface was very confusing. This is much more explicit, which will be easier to understand/optimize/convert.

The plan is to eventually deprecate both of these functions. For now, I'm focused on performance.


Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Jan 28 18:07:50 2009
@@ -783,8 +783,10 @@
                                    LookupCriteria Criteria);
   LookupResult LookupParsedName(Scope *S, const CXXScopeSpec &SS, 
                                 DeclarationName Name, LookupCriteria Criteria);
-  LookupResult LookupDecl(DeclarationName Name, unsigned NSI, Scope *S,
-                          const DeclContext *LookupCtx = 0,
+  LookupResult LookupDeclInScope(DeclarationName Name, unsigned NSI, Scope *S,
+                                 bool LookInParent = true);
+  LookupResult LookupDeclInContext(DeclarationName Name, unsigned NSI,
+                          const DeclContext *LookupCtx,
                           bool LookInParent = true);
 
   bool DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name,

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan 28 18:07:50 2009
@@ -34,13 +34,16 @@
 Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, Scope *S,
                                 const CXXScopeSpec *SS) {
   DeclContext *DC = 0;
+  
   if (SS) {
     if (SS->isInvalid())
       return 0;
     DC = static_cast<DeclContext*>(SS->getScopeRep());
   }
-  LookupResult Result = LookupDecl(&II, Decl::IDNS_Ordinary, S, DC);
-
+  LookupResult Result = DC ? 
+                 LookupDeclInContext(&II, Decl::IDNS_Ordinary, DC) :
+                 LookupDeclInScope(&II, Decl::IDNS_Ordinary, S);
+                   
   Decl *IIDecl = 0;
   switch (Result.getKind()) {
   case LookupResult::NotFound:
@@ -215,7 +218,7 @@
 ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) {
   // The third "scope" argument is 0 since we aren't enabling lazy built-in
   // creation from this context.
-  Decl *IDecl = LookupDecl(Id, Decl::IDNS_Ordinary, 0);
+  Decl *IDecl = LookupDeclInScope(Id, Decl::IDNS_Ordinary, 0);
   
   return dyn_cast_or_null<ObjCInterfaceDecl>(IDecl);
 }
@@ -252,7 +255,7 @@
   return S;
 }
 
-/// LookupDecl - Look up the inner-most declaration in the specified
+/// LookupDeclInScope - Look up the inner-most declaration in the specified
 /// namespace. NamespaceNameOnly - during lookup only namespace names
 /// are considered as required in C++ [basic.lookup.udir] 3.4.6.p1
 /// 'When looking up a namespace-name in a using-directive or
@@ -261,9 +264,8 @@
 /// Note: The use of this routine is deprecated. Please use
 /// LookupName, LookupQualifiedName, or LookupParsedName instead.
 Sema::LookupResult
-Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S,
-                 const DeclContext *LookupCtx,
-                 bool LookInParent) {
+Sema::LookupDeclInScope(DeclarationName Name, unsigned NSI, Scope *S,
+                        bool LookInParent) {
   LookupCriteria::NameKind Kind;
   if (NSI == Decl::IDNS_Ordinary) {
     Kind = LookupCriteria::Ordinary;
@@ -273,24 +275,37 @@
     assert(NSI == Decl::IDNS_Member &&"Unable to grok LookupDecl NSI argument");
     Kind = LookupCriteria::Member;
   }
-  
-  if (LookupCtx)
-    return LookupQualifiedName(const_cast<DeclContext *>(LookupCtx), Name, 
-                               LookupCriteria(Kind, !LookInParent,
-                                              getLangOptions().CPlusPlus));
-
   // Unqualified lookup
   return LookupName(S, Name, 
                     LookupCriteria(Kind, !LookInParent,
                                    getLangOptions().CPlusPlus));
 }
 
+Sema::LookupResult
+Sema::LookupDeclInContext(DeclarationName Name, unsigned NSI,
+                          const DeclContext *LookupCtx,
+                          bool LookInParent) {
+  assert(LookupCtx && "LookupDeclInContext(): Missing DeclContext");
+  LookupCriteria::NameKind Kind;
+  if (NSI == Decl::IDNS_Ordinary) {
+    Kind = LookupCriteria::Ordinary;
+  } else if (NSI == Decl::IDNS_Tag) 
+    Kind = LookupCriteria::Tag;
+  else {
+    assert(NSI == Decl::IDNS_Member &&"Unable to grok LookupDecl NSI argument");
+    Kind = LookupCriteria::Member;
+  }
+  return LookupQualifiedName(const_cast<DeclContext *>(LookupCtx), Name, 
+                             LookupCriteria(Kind, !LookInParent,
+                                            getLangOptions().CPlusPlus));
+}
+
 void Sema::InitBuiltinVaListType() {
   if (!Context.getBuiltinVaListType().isNull())
     return;
   
   IdentifierInfo *VaIdent = &Context.Idents.get("__builtin_va_list");
-  Decl *VaDecl = LookupDecl(VaIdent, Decl::IDNS_Ordinary, TUScope);
+  Decl *VaDecl = LookupDeclInScope(VaIdent, Decl::IDNS_Ordinary, TUScope);
   TypedefDecl *VaTypedef = cast<TypedefDecl>(VaDecl);
   Context.setBuiltinVaListType(Context.getTypedefType(VaTypedef));
 }
@@ -339,7 +354,7 @@
   if (!StdNamespace) {
     IdentifierInfo *StdIdent = &PP.getIdentifierTable().get("std");
     DeclContext *Global = Context.getTranslationUnitDecl();
-    Decl *Std = LookupDecl(StdIdent, Decl::IDNS_Ordinary, 0, Global);
+    Decl *Std = LookupDeclInContext(StdIdent, Decl::IDNS_Ordinary, Global);
     StdNamespace = dyn_cast_or_null<NamespaceDecl>(Std);
   }
   return StdNamespace;
@@ -783,8 +798,8 @@
                                FEnd = AnonRecord->field_end();
        F != FEnd; ++F) {
     if ((*F)->getDeclName()) {
-      Decl *PrevDecl = LookupDecl((*F)->getDeclName(), Decl::IDNS_Ordinary,
-                                  S, Owner, false);
+      Decl *PrevDecl = LookupDeclInContext((*F)->getDeclName(), 
+                         Decl::IDNS_Ordinary, Owner, false);
       if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
         // C++ [class.union]p2:
         //   The names of the members of an anonymous union shall be
@@ -1235,10 +1250,11 @@
   // See if this is a redefinition of a variable in the same scope.
   if (!D.getCXXScopeSpec().isSet()) {
     DC = CurContext;
-    PrevDecl = LookupDecl(Name, Decl::IDNS_Ordinary, S);
+    PrevDecl = LookupDeclInScope(Name, Decl::IDNS_Ordinary, S);
   } else { // Something like "int foo::x;"
     DC = static_cast<DeclContext*>(D.getCXXScopeSpec().getScopeRep());
-    PrevDecl = LookupDecl(Name, Decl::IDNS_Ordinary, S, DC);
+    PrevDecl = DC ? LookupDeclInContext(Name, Decl::IDNS_Ordinary, DC)
+                  : LookupDeclInScope(Name, Decl::IDNS_Ordinary, S);
 
     // C++ 7.3.1.2p2:
     // Members (including explicit specializations of templates) of a named
@@ -1727,7 +1743,7 @@
         << D.getCXXScopeSpec().getRange();
       InvalidDecl = true;
         
-      PrevDecl = LookupDecl(Name, Decl::IDNS_Ordinary, S, DC);
+      PrevDecl = LookupDeclInContext(Name, Decl::IDNS_Ordinary, DC);
       if (!PrevDecl) {
         // Nothing to suggest.
       } else if (OverloadedFunctionDecl *Ovl 
@@ -2582,7 +2598,7 @@
   // among each other.  Here they can only shadow globals, which is ok.
   IdentifierInfo *II = D.getIdentifier();
   if (II) {
-    if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) {
+    if (Decl *PrevDecl = LookupDeclInScope(II, Decl::IDNS_Ordinary, S)) {
       if (PrevDecl->isTemplateParameter()) {
         // Maybe we will complain about the shadowed template parameter.
         DiagnoseTemplateParameterShadow(D.getIdentifierLoc(), PrevDecl);
@@ -2873,8 +2889,8 @@
 
     DC = static_cast<DeclContext*>(SS.getScopeRep());
     // Look-up name inside 'foo::'.
-    PrevDecl = dyn_cast_or_null<TagDecl>(LookupDecl(Name, Decl::IDNS_Tag,S,DC)
-                                           .getAsDecl());
+    PrevDecl = dyn_cast_or_null<TagDecl>(
+                 LookupDeclInContext(Name, Decl::IDNS_Tag, DC).getAsDecl());
 
     // A tag 'foo::bar' must already exist.
     if (PrevDecl == 0) {
@@ -2885,7 +2901,8 @@
   } else if (Name) {
     // If this is a named struct, check to see if there was a previous forward
     // declaration or definition.
-    PrevDecl = dyn_cast_or_null<NamedDecl>(LookupDecl(Name, Decl::IDNS_Tag,S)
+    PrevDecl = dyn_cast_or_null<NamedDecl>(LookupDeclInScope(Name, 
+                                                             Decl::IDNS_Tag,S)
                                            .getAsDecl());
 
     if (!getLangOptions().CPlusPlus && TK != TK_Reference) {
@@ -3273,7 +3290,7 @@
 
   if (II) {
     Decl *PrevDecl 
-      = LookupDecl(II, Decl::IDNS_Member, S, 0, false);
+      = LookupDeclInScope(II, Decl::IDNS_Member, S, false);
     if (PrevDecl && isDeclInScope(PrevDecl, CurContext, S)
         && !isa<TagDecl>(PrevDecl)) {
       Diag(Loc, diag::err_duplicate_member) << II;
@@ -3365,8 +3382,7 @@
                                              (Expr *)BitfieldWidth);
   
   if (II) {
-    Decl *PrevDecl 
-      = LookupDecl(II, Decl::IDNS_Member, S, 0, false);
+    Decl *PrevDecl = LookupDeclInScope(II, Decl::IDNS_Member, S, false);
     if (PrevDecl && isDeclInScope(PrevDecl, CurContext, S)
         && !isa<TagDecl>(PrevDecl)) {
       Diag(Loc, diag::err_duplicate_member) << II;
@@ -3542,7 +3558,7 @@
   
   // Verify that there isn't already something declared with this name in this
   // scope.
-  Decl *PrevDecl = LookupDecl(Id, Decl::IDNS_Ordinary, S);
+  Decl *PrevDecl = LookupDeclInScope(Id, Decl::IDNS_Ordinary, S);
   if (PrevDecl && PrevDecl->isTemplateParameter()) {
     // Maybe we will complain about the shadowed template parameter.
     DiagnoseTemplateParameterShadow(IdLoc, PrevDecl);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 28 18:07:50 2009
@@ -1376,9 +1376,8 @@
     // original-namespace-definition is the name of the namespace. Subsequently
     // in that declarative region, it is treated as an original-namespace-name.
 
-    Decl *PrevDecl =
-      LookupDecl(II, Decl::IDNS_Ordinary, DeclRegionScope, 0,
-                /*LookupInParent=*/false);
+    Decl *PrevDecl = LookupDeclInScope(II, Decl::IDNS_Ordinary, DeclRegionScope, 
+                                       /*LookupInParent=*/false);
     
     if (NamespaceDecl *OrigNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl)) {
       // This is an extended namespace definition.
@@ -2181,7 +2180,7 @@
   // FIXME: Need to check for abstract classes.
 
   IdentifierInfo *II = D.getIdentifier();
-  if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) {
+  if (Decl *PrevDecl = LookupDeclInScope(II, Decl::IDNS_Ordinary, S)) {
     // The scope should be freshly made just for us. There is just no way
     // it contains any previous declaration.
     assert(!S->isDeclScope(PrevDecl));

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Jan 28 18:07:50 2009
@@ -65,7 +65,7 @@
   assert(ClassName && "Missing class identifier");
   
   // Check for another declaration kind with the same name.
-  Decl *PrevDecl = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
+  Decl *PrevDecl = LookupDeclInScope(ClassName, Decl::IDNS_Ordinary, TUScope);
   if (PrevDecl && PrevDecl->isTemplateParameter()) {
     // Maybe we will complain about the shadowed template parameter.
     DiagnoseTemplateParameterShadow(ClassLoc, PrevDecl);
@@ -108,7 +108,7 @@
   if (SuperName) {
     ObjCInterfaceDecl* SuperClassEntry = 0;
     // Check if a different kind of symbol declared in this scope.
-    PrevDecl = LookupDecl(SuperName, Decl::IDNS_Ordinary, TUScope);
+    PrevDecl = LookupDeclInScope(SuperName, Decl::IDNS_Ordinary, TUScope);
     if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
       Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
       Diag(PrevDecl->getLocation(), diag::note_previous_definition);
@@ -150,7 +150,7 @@
                                            IdentifierInfo *ClassName,
                                            SourceLocation ClassLocation) {
   // Look for previous declaration of alias name
-  Decl *ADecl = LookupDecl(AliasName, Decl::IDNS_Ordinary, TUScope);
+  Decl *ADecl = LookupDeclInScope(AliasName, Decl::IDNS_Ordinary, TUScope);
   if (ADecl) {
     if (isa<ObjCCompatibleAliasDecl>(ADecl))
       Diag(AliasLocation, diag::warn_previous_alias_decl);
@@ -160,13 +160,13 @@
     return 0;
   }
   // Check for class declaration
-  Decl *CDeclU = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
+  Decl *CDeclU = LookupDeclInScope(ClassName, Decl::IDNS_Ordinary, TUScope);
   if (const TypedefDecl *TDecl = dyn_cast_or_null<TypedefDecl>(CDeclU)) {
     QualType T = TDecl->getUnderlyingType();
     if (T->isObjCInterfaceType()) {
       if (NamedDecl *IDecl = T->getAsObjCInterfaceType()->getDecl()) {
         ClassName = IDecl->getIdentifier();
-        CDeclU = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
+        CDeclU = LookupDeclInScope(ClassName, Decl::IDNS_Ordinary, TUScope);
       }
     }
   }
@@ -536,7 +536,7 @@
                       SourceLocation SuperClassLoc) {
   ObjCInterfaceDecl* IDecl = 0;
   // Check for another declaration kind with the same name.
-  Decl *PrevDecl = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
+  Decl *PrevDecl = LookupDeclInScope(ClassName, Decl::IDNS_Ordinary, TUScope);
   if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
     Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
     Diag(PrevDecl->getLocation(), diag::note_previous_definition);
@@ -552,7 +552,7 @@
   ObjCInterfaceDecl* SDecl = 0;
   if (SuperClassname) {
     // Check if a different kind of symbol declared in this scope.
-    PrevDecl = LookupDecl(SuperClassname, Decl::IDNS_Ordinary, TUScope);
+    PrevDecl = LookupDeclInScope(SuperClassname, Decl::IDNS_Ordinary, TUScope);
     if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
       Diag(SuperClassLoc, diag::err_redefinition_different_kind)
         << SuperClassname;
@@ -910,7 +910,7 @@
   
   for (unsigned i = 0; i != NumElts; ++i) {
     // Check for another declaration kind with the same name.
-    Decl *PrevDecl = LookupDecl(IdentList[i], Decl::IDNS_Ordinary, TUScope);
+    Decl *PrevDecl = LookupDeclInScope(IdentList[i], Decl::IDNS_Ordinary, TUScope);
     if (PrevDecl && PrevDecl->isTemplateParameter()) {
       // Maybe we will complain about the shadowed template parameter.
       DiagnoseTemplateParameterShadow(AtClassLoc, PrevDecl);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan 28 18:07:50 2009
@@ -561,9 +561,9 @@
     DeclContext *DC = static_cast<DeclContext*>(SS->getScopeRep());
     if (DC == 0)
       return ExprError();
-    Lookup = LookupDecl(Name, Decl::IDNS_Ordinary, S, DC);
+    Lookup = LookupDeclInContext(Name, Decl::IDNS_Ordinary, DC);
   } else
-    Lookup = LookupDecl(Name, Decl::IDNS_Ordinary, S);
+    Lookup = LookupDeclInScope(Name, Decl::IDNS_Ordinary, S);
 
   if (Lookup.isAmbiguous()) {
     DiagnoseAmbiguousLookup(Lookup, Name, Loc,
@@ -4031,9 +4031,9 @@
     // Get the decl corresponding to this.
     RecordDecl *RD = RC->getDecl();
     FieldDecl *MemberDecl 
-      = dyn_cast_or_null<FieldDecl>(LookupDecl(OC.U.IdentInfo, 
+      = dyn_cast_or_null<FieldDecl>(LookupDeclInContext(OC.U.IdentInfo, 
                                                Decl::IDNS_Ordinary,
-                                               S, RD, false).getAsDecl());
+                                               RD, false).getAsDecl());
     if (!MemberDecl)
       return Diag(BuiltinLoc, diag::err_typecheck_no_member)
        << OC.U.IdentInfo << SourceRange(OC.LocStart, OC.LocEnd);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jan 28 18:07:50 2009
@@ -61,7 +61,7 @@
     return Diag(OpLoc, diag::err_need_header_before_typeid);
   
   IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get("type_info");
-  Decl *TypeInfoDecl = LookupDecl(TypeInfoII, Decl::IDNS_Tag, 0, StdNs);
+  Decl *TypeInfoDecl = LookupDeclInContext(TypeInfoII, Decl::IDNS_Tag, StdNs);
   RecordDecl *TypeInfoRecordDecl = dyn_cast_or_null<RecordDecl>(TypeInfoDecl);
   if (!TypeInfoRecordDecl)
     return Diag(OpLoc, diag::err_need_header_before_typeid);

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jan 28 18:07:50 2009
@@ -53,7 +53,7 @@
     // Initialize the constant string interface lazily. This assumes
     // the NSConstantString interface is seen in this translation unit.
     IdentifierInfo *NSIdent = &Context.Idents.get("NSConstantString");
-    Decl *IFace = LookupDecl(NSIdent, Decl::IDNS_Ordinary, TUScope);
+    Decl *IFace = LookupDeclInScope(NSIdent, Decl::IDNS_Ordinary, TUScope);
     ObjCInterfaceDecl *strIFace = dyn_cast_or_null<ObjCInterfaceDecl>(IFace);
     if (strIFace)
       Context.setObjCConstantStringInterface(strIFace);
@@ -210,7 +210,7 @@
     } else {
       // 'super' has been used outside a method context. If a variable named
       // 'super' has been declared, redirect. If not, produce a diagnostic.
-      Decl *SuperDecl = LookupDecl(receiverName, Decl::IDNS_Ordinary, S);
+      Decl *SuperDecl = LookupDeclInScope(receiverName, Decl::IDNS_Ordinary, S);
       ValueDecl *VD = dyn_cast_or_null<ValueDecl>(SuperDecl);
       if (VD) {
         ExprResult ReceiverExpr = new DeclRefExpr(VD, VD->getType(), 
@@ -235,7 +235,7 @@
   //
   // If necessary, the following lookup could move to getObjCInterfaceDecl().
   if (!ClassDecl) {
-    Decl *IDecl = LookupDecl(receiverName, Decl::IDNS_Ordinary, 0);
+    Decl *IDecl = LookupDeclInScope(receiverName, Decl::IDNS_Ordinary, 0);
     if (TypedefDecl *OCTD = dyn_cast_or_null<TypedefDecl>(IDecl)) {
       const ObjCInterfaceType *OCIT;
       OCIT = OCTD->getUnderlyingType()->getAsObjCInterfaceType();

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jan 28 18:07:50 2009
@@ -26,12 +26,15 @@
 Sema::DeclTy *Sema::isTemplateName(IdentifierInfo &II, Scope *S,
                                    const CXXScopeSpec *SS) {
   DeclContext *DC = 0;
+  
   if (SS) {
     if (SS->isInvalid())
       return 0;
     DC = static_cast<DeclContext*>(SS->getScopeRep());
   }
-  Decl *IIDecl = LookupDecl(&II, Decl::IDNS_Ordinary, S, DC, false);
+  Decl *IIDecl = DC ? 
+                 LookupDeclInContext(&II, Decl::IDNS_Ordinary, DC, false) :
+                 LookupDeclInScope(&II, Decl::IDNS_Ordinary, S, false);
 
   if (IIDecl) {
     // FIXME: We need to represent templates via some kind of
@@ -93,7 +96,7 @@
   bool Invalid = false;
 
   if (ParamName) {
-    Decl *PrevDecl = LookupDecl(ParamName, Decl::IDNS_Tag, S);
+    Decl *PrevDecl = LookupDeclInScope(ParamName, Decl::IDNS_Tag, S);
     if (PrevDecl && PrevDecl->isTemplateParameter())
       Invalid = Invalid || DiagnoseTemplateParameterShadow(ParamNameLoc,
 							   PrevDecl);
@@ -129,7 +132,7 @@
 
   IdentifierInfo *ParamName = D.getIdentifier();
   if (ParamName) {
-    Decl *PrevDecl = LookupDecl(ParamName, Decl::IDNS_Tag, S);
+    Decl *PrevDecl = LookupDeclInScope(ParamName, Decl::IDNS_Tag, S);
     if (PrevDecl && PrevDecl->isTemplateParameter())
       Invalid = Invalid || DiagnoseTemplateParameterShadow(D.getIdentifierLoc(),
 							   PrevDecl);





More information about the cfe-commits mailing list