Implement code completion for tags, e.g., code completion after "enum"
will provide the names of various enumerations currently
visible. Introduced filtering of code-completion results when we build
the result set, so that we can identify just the kinds of declarations
we want.
This implementation is incomplete for C++, since we don't consider
that the token after the tag keyword could start a
nested-name-specifier.
llvm-svn: 82222
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 2183cfa..bfee4d8 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -34,6 +34,35 @@
CodeCompleter->CodeCompleteMemberReferenceExpr(S, BaseType, IsArrow);
}
+void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) {
+ if (!CodeCompleter)
+ return;
+
+ TagDecl::TagKind TK;
+ switch ((DeclSpec::TST)TagSpec) {
+ case DeclSpec::TST_enum:
+ TK = TagDecl::TK_enum;
+ break;
+
+ case DeclSpec::TST_union:
+ TK = TagDecl::TK_union;
+ break;
+
+ case DeclSpec::TST_struct:
+ TK = TagDecl::TK_struct;
+ break;
+
+ case DeclSpec::TST_class:
+ TK = TagDecl::TK_class;
+ break;
+
+ default:
+ assert(false && "Unknown type specifier kind in CodeCompleteTag");
+ return;
+ }
+ CodeCompleter->CodeCompleteTag(S, TK);
+}
+
void Sema::CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS,
bool EnteringContext) {
if (!SS.getScopeRep() || !CodeCompleter)