diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-01-31 05:03:46 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-01-31 05:03:46 +0000 |
commit | 52e0de4c6e3644fb8b2e02aced03c6731452591f (patch) | |
tree | 50104a83feaa1df3bf5a86864dbd8b7d064e6bdc /clang/lib/Sema/SemaCodeComplete.cpp | |
parent | 0a0e2b3631a1c95c280f20d839e82eb9a7647b09 (diff) | |
download | bcm5719-llvm-52e0de4c6e3644fb8b2e02aced03c6731452591f.tar.gz bcm5719-llvm-52e0de4c6e3644fb8b2e02aced03c6731452591f.zip |
When code completing in a statement, parenthesized expression, or
Objective-C message receiver, the user is as likely to want to write a
type name as any other declaration, so give types the same priority as
other declarations. Fixes <rdar://problem/12480600>.
llvm-svn: 174038
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 3f6393724ee..04f6ba72fc2 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -733,7 +733,15 @@ unsigned ResultBuilder::getBasePriority(const NamedDecl *ND) { if (isa<EnumConstantDecl>(ND)) return CCP_Constant; - if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))) + // Use CCP_Type for type declarations unless we're in a statement, Objective-C + // message receiver, or parenthesized expression context. There, it's as + // likely that the user will want to write a type as other declarations. + if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) && + !(CompletionContext.getKind() == CodeCompletionContext::CCC_Statement || + CompletionContext.getKind() + == CodeCompletionContext::CCC_ObjCMessageReceiver || + CompletionContext.getKind() + == CodeCompletionContext::CCC_ParenthesizedExpression)) return CCP_Type; return CCP_Declaration; |