[cfe-commits] r94524 - in /cfe/trunk: lib/Sema/SemaLookup.cpp lib/Sema/SemaOverload.cpp test/SemaCXX/using-decl-1.cpp

John McCall rjmccall at apple.com
Mon Jan 25 22:04:06 PST 2010


Author: rjmccall
Date: Tue Jan 26 00:04:06 2010
New Revision: 94524

URL: http://llvm.org/viewvc/llvm-project?rev=94524&view=rev
Log:
Allow ADL to find functions imported by using decls.  Leave wordy comment
about interaction between ADL and default arguments.  Shrug shoulders, commit.


Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/using-decl-1.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Jan 26 00:04:06 2010
@@ -1785,16 +1785,20 @@
           continue;
       }
 
-      // FIXME: using decls?  canonical decls?
+      if (isa<UsingShadowDecl>(D))
+        D = cast<UsingShadowDecl>(D)->getTargetDecl();
 
-      FunctionDecl *Fn;
-      if (!Operator || !(Fn = dyn_cast<FunctionDecl>(D)) ||
-          IsAcceptableNonMemberOperatorCandidate(Fn, T1, T2, Context)) {
-        if (isa<FunctionDecl>(D))
-          Functions.insert(D);
-        else if (isa<FunctionTemplateDecl>(D))
-          Functions.insert(D);
-      }
+      // FIXME: canonical decls.
+      // See comment in AddArgumentDependentLookupCandidates().
+
+      if (isa<FunctionDecl>(D)) {
+        if (Operator &&
+            !IsAcceptableNonMemberOperatorCandidate(cast<FunctionDecl>(D),
+                                                    T1, T2, Context))
+          continue;
+        Functions.insert(D);
+      } else if (isa<FunctionTemplateDecl>(D))
+        Functions.insert(D);
     }
   }
 }

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Jan 26 00:04:06 2010
@@ -4133,8 +4133,13 @@
                                            bool PartialOverloading) {
   ADLFunctionSet Functions;
 
-  // FIXME: Should we be trafficking in canonical function decls throughout?
-  
+  // FIXME: This approach for uniquing ADL results (and removing
+  // redundant candidates from the set) relies on pointer-equality,
+  // which means we need to key off the canonical decl.  However,
+  // always going back to the canonical decl might not get us the
+  // right set of default arguments.  What default arguments are
+  // we supposed to consider on ADL candidates, anyway?
+
   // FIXME: Pass in the explicit template arguments?
   ArgumentDependentLookup(Name, Operator, Args, NumArgs, Functions);
 

Modified: cfe/trunk/test/SemaCXX/using-decl-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-1.cpp?rev=94524&r1=94523&r2=94524&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp Tue Jan 26 00:04:06 2010
@@ -60,3 +60,20 @@
     g(f);
   }
 }
+
+// Make sure that ADL can find names brought in by using decls.
+namespace test0 {
+  namespace ns {
+    class Foo {};
+    
+    namespace inner {
+      void foo(char *); // expected-note {{no known conversion}} 
+    }
+
+    using inner::foo;
+  }
+
+  void test(ns::Foo *p) {
+    foo(*p); // expected-error {{no matching function for call to 'foo'}}
+  }
+}





More information about the cfe-commits mailing list