summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeCompletion
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-06-07 09:45:17 +0000
committerSam McCall <sam.mccall@gmail.com>2019-06-07 09:45:17 +0000
commitf1f6e0fc2468e9c120b22b939507c527d08b8ee8 (patch)
treed4453059dea318a86dd5d38baa7800b3f6189ab4 /clang/test/CodeCompletion
parent15fec3a69cc0f8511463610071e6de66f0cc25f1 (diff)
downloadbcm5719-llvm-f1f6e0fc2468e9c120b22b939507c527d08b8ee8.tar.gz
bcm5719-llvm-f1f6e0fc2468e9c120b22b939507c527d08b8ee8.zip
[CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods.
Summary: - when a method is not available because of the target value kind (e.g. an && method on a Foo& variable), then don't offer it. - when a method is effectively shadowed by another method from the same class with a) an identical argument list and b) superior qualifiers, then don't offer it. Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62582 llvm-svn: 362785
Diffstat (limited to 'clang/test/CodeCompletion')
-rw-r--r--clang/test/CodeCompletion/member-access.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/clang/test/CodeCompletion/member-access.cpp b/clang/test/CodeCompletion/member-access.cpp
index 003d224fbe2..6d7cf6ac7cd 100644
--- a/clang/test/CodeCompletion/member-access.cpp
+++ b/clang/test/CodeCompletion/member-access.cpp
@@ -210,3 +210,66 @@ void test3(const Proxy2 &p) {
// CHECK-CC9: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>) (requires fix-it: {181:4-181:5} to "->")
// CHECK-CC9: memfun3 : [#int#]memfun3(<#int#>) (requires fix-it: {181:4-181:5} to "->")
// CHECK-CC9: operator-> : [#Derived *#]operator->()[# const#]
+
+// These overload sets differ only by return type and this-qualifiers.
+// So for any given callsite, only one is available.
+struct Overloads {
+ double ConstOverload(char);
+ int ConstOverload(char) const;
+
+ int RefOverload(char) &;
+ double RefOverload(char) const&;
+ char RefOverload(char) &&;
+};
+void testLValue(Overloads& Ref) {
+ Ref.
+}
+void testConstLValue(const Overloads& ConstRef) {
+ ConstRef.
+}
+void testRValue() {
+ Overloads().
+}
+void testXValue(Overloads& X) {
+ static_cast<Overloads&&>(X).
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:225:7 %s -o - | FileCheck -check-prefix=CHECK-LVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload(" \
+// RUN: --implicit-check-not="[#char#]RefOverload("
+// CHECK-LVALUE-DAG: [#double#]ConstOverload(
+// CHECK-LVALUE-DAG: [#int#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:228:12 %s -o - | FileCheck -check-prefix=CHECK-CONSTLVALUE %s \
+// RUN: --implicit-check-not="[#double#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#char#]RefOverload("
+// CHECK-CONSTLVALUE: [#int#]ConstOverload(
+// CHECK-CONSTLVALUE: [#double#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:231:15 %s -o - | FileCheck -check-prefix=CHECK-PRVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload("
+// CHECK-PRVALUE: [#double#]ConstOverload(
+// CHECK-PRVALUE: [#char#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:234:31 %s -o - | FileCheck -check-prefix=CHECK-XVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload("
+// CHECK-XVALUE: [#double#]ConstOverload(
+// CHECK-XVALUE: [#char#]RefOverload(
+
+void testOverloadOperator() {
+ struct S {
+ char operator=(int) const;
+ int operator=(int);
+ } s;
+ return s.
+}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:270:12 %s -o - | FileCheck -check-prefix=CHECK-OPER %s \
+// RUN: --implicit-check-not="[#char#]operator=("
+// CHECK-OPER: [#int#]operator=(
+
OpenPOWER on IntegriCloud