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 | dbb71db4cc79d6b74c0683ffec5f3a847179603c (patch) | |
tree | 5c27e5f0d0cf0775d93204e6fcc90fc1e669662b /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | 846022495866f4234a7cc4e99329637888128f32 (diff) | |
download | bcm5719-llvm-dbb71db4cc79d6b74c0683ffec5f3a847179603c.tar.gz bcm5719-llvm-dbb71db4cc79d6b74c0683ffec5f3a847179603c.zip |
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.
llvm-svn: 111867
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index d886e64bb53..aec55682180 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/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; |