Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions clang/lib/Sema/SemaCodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5680,8 +5680,15 @@ QualType getApproximateType(const Expr *E) {
}
}
if (const auto *UO = llvm::dyn_cast<UnaryOperator>(E)) {
if (UO->getOpcode() == UnaryOperatorKind::UO_Deref)
return UO->getSubExpr()->getType()->getPointeeType();
if (UO->getOpcode() == UnaryOperatorKind::UO_Deref) {
// We recurse into the subexpression because it could be of dependent
// type.
if (auto Pointee = getApproximateType(UO->getSubExpr())->getPointeeType();
!Pointee.isNull())
return Pointee;
// Our caller expects a non-null result, even though the SubType is
// supposed to have a pointee. Fall through to Unresolved anyway.
}
}
return Unresolved;
}
Expand Down
16 changes: 16 additions & 0 deletions clang/test/CodeCompletion/member-access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,20 @@ class A {
// CHECK-DEREF-THIS: [#void#]function()
}
};

template <typename Element>
struct RepeatedField {
void Add();
};

template <typename T>
RepeatedField<T>* MutableRepeatedField() {}

template <class T>
void Foo() {
auto& C = *MutableRepeatedField<T>();
C.
}
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:382:5 %s -o - | FileCheck -check-prefix=CHECK-DEREF-DEPENDENT %s
// CHECK-DEREF-DEPENDENT: [#void#]Add()
}