diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-23 23:51:41 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-23 23:51:41 +0000 |
commit | aaa107acc8f906203101af259e8d764b5027700a (patch) | |
tree | c3d8ca615957a9e98c9f5d808c8a52ffee3a1a39 /lib | |
parent | c070da46b896940aa2cbac416e5a2f8eee22d7d8 (diff) |
When calling a function or messaging a method marked "sentinel", add
the ", nil", ", NULL", or ", (void*)0" to the end of the code
completion, since it always has to be there anyway.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111867 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index d886e64bb5..aec5568218 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -1666,6 +1666,20 @@ static void AddResultTypeChunk(ASTContext &Context, Result->AddResultTypeChunk(TypeStr); } +static void MaybeAddSentinel(ASTContext &Context, NamedDecl *FunctionOrMethod, + CodeCompletionString *Result) { + if (SentinelAttr *Sentinel = FunctionOrMethod->getAttr<SentinelAttr>()) + if (Sentinel->getSentinel() == 0) { + if (Context.getLangOptions().ObjC1 && + Context.Idents.get("nil").hasMacroDefinition()) + Result->AddTextChunk(", nil"); + else if (Context.Idents.get("NULL").hasMacroDefinition()) + Result->AddTextChunk(", NULL"); + else + Result->AddTextChunk(", (void*)0"); + } +} + /// \brief Add function parameter chunks to the given code completion string. static void AddFunctionParameterChunks(ASTContext &Context, FunctionDecl *Function, @@ -1702,8 +1716,11 @@ static void AddFunctionParameterChunks(ASTContext &Context, if (const FunctionProtoType *Proto = Function->getType()->getAs<FunctionProtoType>()) - if (Proto->isVariadic()) + if (Proto->isVariadic()) { CCStr->AddPlaceholderChunk(", ..."); + + MaybeAddSentinel(Context, Function, CCStr); + } } /// \brief Add template parameter chunks to the given code completion string. @@ -2020,6 +2037,8 @@ CodeCompleteConsumer::Result::CreateCodeCompletionString(Sema &S, Result->AddInformativeChunk(", ..."); else Result->AddPlaceholderChunk(", ..."); + + MaybeAddSentinel(S.Context, Method, Result); } return Result; |