[cfe-commits] r91677 - /cfe/trunk/lib/Sema/SemaLookup.cpp

John McCall rjmccall at apple.com
Fri Dec 18 02:48:10 PST 2009


Author: rjmccall
Date: Fri Dec 18 04:48:10 2009
New Revision: 91677

URL: http://llvm.org/viewvc/llvm-project?rev=91677&view=rev
Log:
Look through using decls when checking whether a name is an acceptable
nested-name specifier name.

I accidentally checked in the test case for this in the last commit ---
fortunately, that refactor was inspired by having debugged this problem already,
so I can fix the bug quick (though probably not fast enough for the buildbots).


Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Dec 18 04:48:10 2009
@@ -202,10 +202,22 @@
 }
 
 static bool IsAcceptableNestedNameSpecifierName(NamedDecl *D, unsigned IDNS) {
-  return isa<TypedefDecl>(D) || D->isInIdentifierNamespace(Decl::IDNS_Tag);
+  // This lookup ignores everything that isn't a type.
+
+  // This is a fast check for the far most common case.
+  if (D->isInIdentifierNamespace(Decl::IDNS_Tag))
+    return true;
+
+  if (isa<UsingShadowDecl>(D))
+    D = cast<UsingShadowDecl>(D)->getTargetDecl();
+
+  return isa<TypeDecl>(D);
 }
 
 static bool IsAcceptableNamespaceName(NamedDecl *D, unsigned IDNS) {
+  // We don't need to look through using decls here because
+  // using decls aren't allowed to name namespaces.
+
   return isa<NamespaceDecl>(D) || isa<NamespaceAliasDecl>(D);
 }
 





More information about the cfe-commits mailing list