]> granicus.if.org Git - clang/commitdiff
Look through using decls when checking whether a name is an acceptable
authorJohn McCall <rjmccall@apple.com>
Fri, 18 Dec 2009 10:48:10 +0000 (10:48 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 18 Dec 2009 10:48:10 +0000 (10:48 +0000)
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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91677 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaLookup.cpp

index 5e60cc8727aa8bfed53a9c49d497724110b9d588..aac3ffe6dd83bffbbf6a1546a2bafcae47dc2444 100644 (file)
@@ -202,10 +202,22 @@ static bool IsAcceptableOperatorName(NamedDecl *D, unsigned IDNS) {
 }
 
 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);
 }