[cfe-commits] r82233 - in /cfe/trunk: lib/Sema/CodeCompleteConsumer.cpp test/CodeCompletion/tag.cpp
Douglas Gregor
dgregor at apple.com
Fri Sep 18 10:54:00 PDT 2009
Author: dgregor
Date: Fri Sep 18 12:54:00 2009
New Revision: 82233
URL: http://llvm.org/viewvc/llvm-project?rev=82233&view=rev
Log:
Handle using declarations and overload sets in code completion.
Modified:
cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
cfe/trunk/test/CodeCompletion/tag.cpp
Modified: cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp?rev=82233&r1=82232&r2=82233&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp (original)
+++ cfe/trunk/lib/Sema/CodeCompleteConsumer.cpp Fri Sep 18 12:54:00 2009
@@ -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 @@
Results.push_back(R);
return;
}
-
- // FIXME: Using declarations
- // FIXME: Separate overload sets
+
+ // Look through using declarations.
+ if (UsingDecl *Using = dyn_cast<UsingDecl>(R.Declaration))
+ return MaybeAddResult(Result(Using->getTargetDecl(), R.Rank));
+
+ // 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();
Modified: cfe/trunk/test/CodeCompletion/tag.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/tag.cpp?rev=82233&r1=82232&r2=82233&view=diff
==============================================================================
--- cfe/trunk/test/CodeCompletion/tag.cpp (original)
+++ cfe/trunk/test/CodeCompletion/tag.cpp Fri Sep 18 12:54:00 2009
@@ -8,13 +8,20 @@
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
More information about the cfe-commits
mailing list