summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-04-14 20:33:34 +0000
committerDouglas Gregor <dgregor@apple.com>2011-04-14 20:33:34 +0000
commitaf670a81e9b74829a8a1381f7db9d6c646f32428 (patch)
tree1ae821fb15249c224f30c0020304f29606d3f406 /clang/lib/Sema/SemaCodeComplete.cpp
parent231e875b5c44db3197d548b8b7c16d1bc3d8a81e (diff)
downloadbcm5719-llvm-af670a81e9b74829a8a1381f7db9d6c646f32428.tar.gz
bcm5719-llvm-af670a81e9b74829a8a1381f7db9d6c646f32428.zip
When determining the "usage" type of a declaration for the purposes of code
completion, look through block pointer and function pointer types to the result type of the block/function. Fixes <rdar://problem/9282583>. llvm-svn: 129535
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 75253b5b308..12ce270c748 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -667,8 +667,39 @@ QualType clang::getDeclUsageType(ASTContext &C, NamedDecl *ND) {
T = Value->getType();
else
return QualType();
-
- return T.getNonReferenceType();
+
+ // Dig through references, function pointers, and block pointers to
+ // get down to the likely type of an expression when the entity is
+ // used.
+ do {
+ if (const ReferenceType *Ref = T->getAs<ReferenceType>()) {
+ T = Ref->getPointeeType();
+ continue;
+ }
+
+ if (const PointerType *Pointer = T->getAs<PointerType>()) {
+ if (Pointer->getPointeeType()->isFunctionType()) {
+ T = Pointer->getPointeeType();
+ continue;
+ }
+
+ break;
+ }
+
+ if (const BlockPointerType *Block = T->getAs<BlockPointerType>()) {
+ T = Block->getPointeeType();
+ continue;
+ }
+
+ if (const FunctionType *Function = T->getAs<FunctionType>()) {
+ T = Function->getResultType();
+ continue;
+ }
+
+ break;
+ } while (true);
+
+ return T;
}
void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
OpenPOWER on IntegriCloud