]> granicus.if.org Git - clang/commitdiff
Use DeclContext::getLookupContext wherever necessary to ensure that we look through...
authorDouglas Gregor <dgregor@apple.com>
Wed, 7 Jan 2009 16:34:42 +0000 (16:34 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 7 Jan 2009 16:34:42 +0000 (16:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61861 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/Sema/SemaDecl.cpp

index 5b96153d595e52bdceb83f36422bc85937b34ec9..ceea987ce0f68afc5ba48cf30c50655c6f067f15 100644 (file)
@@ -195,7 +195,7 @@ public:
   // be defined inside or outside a function etc).
   bool isDefinedOutsideFunctionOrMethod() const {
     if (getDeclContext())
-      return !getDeclContext()->isFunctionOrMethod();
+      return !getDeclContext()->getLookupContext()->isFunctionOrMethod();
     else
       return true;
   }
@@ -420,7 +420,7 @@ public:
     if (getKind() != Decl::Var)
       return false;
     if (const DeclContext *DC = getDeclContext())
-      return DC->isFunctionOrMethod();
+      return DC->getLookupContext()->isFunctionOrMethod();
     return false;
   }
   
@@ -428,9 +428,11 @@ public:
   bool isFileVarDecl() const {
     if (getKind() != Decl::Var)
       return false;
-    const DeclContext *Ctx = getDeclContext()->getLookupContext();
-    if (isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx) )
-      return true;
+    if (const DeclContext *Ctx = getDeclContext()) {
+      Ctx = Ctx->getLookupContext();
+      if (isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx) )
+        return true;
+    }
     return false;
   }
   
index ea2ea074aadbcf9b018e21c5591d72aa4d0fc465..e1c9efc326e7d9a4035828408e28e824742bd1fa 100644 (file)
@@ -116,7 +116,8 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S) {
   //   in this case the class name or enumeration name is hidden.
   if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
     // We are pushing the name of a tag (enum or class).
-    if (CurContext == TD->getDeclContext()) {
+    if (CurContext->getLookupContext() 
+          == TD->getDeclContext()->getLookupContext()) {
       // We're pushing the tag into the current context, which might
       // require some reshuffling in the identifier resolver.
       IdentifierResolver::iterator
@@ -679,7 +680,7 @@ void Sema::CheckForFileScopedRedefinitions(Scope *S, VarDecl *VD) {
   bool VDIsTentative = isTentativeDefinition(VD);
   bool VDIsIncompleteArray = VD->getType()->isIncompleteArrayType();
   
-  // FIXME: I don't this will actually see all of the
+  // FIXME: I don't think this will actually see all of the
   // redefinitions. Can't we check this property on-the-fly?
   for (IdentifierResolver::iterator
        I = IdResolver.begin(VD->getIdentifier(),