]> granicus.if.org Git - clang/commitdiff
Handle using declarations and overload sets in code completion.
authorDouglas Gregor <dgregor@apple.com>
Fri, 18 Sep 2009 17:54:00 +0000 (17:54 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 18 Sep 2009 17:54:00 +0000 (17:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82233 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/CodeCompleteConsumer.cpp
test/CodeCompletion/tag.cpp

index 7dee12a3dcb7d13b86822aa8afee77e08b41f54a..b626847d6251a86ea87604a23165d152a6e90c0d 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/Parse/Scope.h"
 #include "clang/Lex/Preprocessor.h"
 #include "Sema.h"
@@ -123,9 +124,21 @@ void CodeCompleteConsumer::ResultSet::MaybeAddResult(Result R) {
     Results.push_back(R);
     return;
   }
+
+  // Look through using declarations.
+  if (UsingDecl *Using = dyn_cast<UsingDecl>(R.Declaration))
+    return MaybeAddResult(Result(Using->getTargetDecl(), R.Rank));
   
-  // FIXME: Using declarations
-  // FIXME: Separate overload sets
+  // Handle each declaration in an overload set separately.
+  if (OverloadedFunctionDecl *Ovl 
+        = dyn_cast<OverloadedFunctionDecl>(R.Declaration)) {
+    for (OverloadedFunctionDecl::function_iterator F = Ovl->function_begin(),
+                                                FEnd = Ovl->function_end();
+         F != FEnd; ++F)
+      MaybeAddResult(Result(*F, R.Rank));
+    
+    return;
+  }
   
   Decl *CanonDecl = R.Declaration->getCanonicalDecl();
   unsigned IDNS = CanonDecl->getIdentifierNamespace();
index addad9d76905ce9c0c77916691ba890845345219..d8f6f2fa0a8d202de22e8690a80ef7033725f215 100644 (file)
@@ -8,13 +8,20 @@ namespace N {
   template<typename> class Z;
 }
 
+namespace M {
+  class A;
+}
+using M::A;
+
 namespace N {
   class Y;
   
   void test() {
     // CHECK-CC1: Y : 2
     // CHECK-CC1: Z : 2
+    // CHECK-CC1: A : 3
     // CHECK-CC1: X : 3
     // CHECK-CC1: Y : 3
+    // CHECK-CC1: M : 6
     // CHECK-CC1: N : 6
     class