kbobyrev updated this revision to Diff 238791.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.
Address comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72638/new/
https://reviews.llvm.org/D72638
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -265,6 +265,33 @@
}
)cpp",
+ // Destructor explicit call.
+ R"cpp(
+ class [[F^oo]] {
+ public:
+ ~[[^Foo]]();
+ };
+
+ [[Foo^]]::~[[^Foo]]() {}
+
+ int main() {
+ [[Fo^o]] f;
+ f.~/*something*/[[^Foo]]();
+ f.~[[^Foo]]();
+ }
+ )cpp",
+
+ // Derived destructor explicit call.
+ R"cpp(
+ class [[Bas^e]] {};
+ class Derived : public [[Bas^e]] {}
+
+ int main() {
+ [[Bas^e]] *foo = new Derived();
+ foo->[[^Base]]::~[[^Base]]();
+ }
+ )cpp",
+
// CXXConstructor initializer list.
R"cpp(
class Baz {};
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -879,6 +879,50 @@
"8: targets = {INT2}, decl\n"
"9: targets = {NS}, decl\n"
"10: targets = {ns}\n"},
+ // User-defined conversion operator.
+ {R"cpp(
+ void foo() {
+ class $0^Foo {
+ public:
+ $1^operator int();
+ };
+
+ $2^Foo $3^f;
+ $4^f.$5^operator int();
+ }
+ )cpp",
+ "0: targets = {Foo}, decl\n"
+ "1: targets = {foo()::Foo::operator int}, decl\n"
+ "2: targets = {Foo}\n"
+ "3: targets = {f}, decl\n"
+ "4: targets = {f}\n"
+ "5: targets = {foo()::Foo::operator int}\n"},
+ // Destructor.
+ {R"cpp(
+ void foo() {
+ class $0^Foo {
+ public:
+ ~$1^Foo() {}
+
+ void $2^destructMe() {
+ this->~$3^Foo();
+ }
+ };
+
+ $4^Foo $5^f;
+ $6^f.~ /*...*/ $7^Foo();
+ }
+ )cpp",
+ "0: targets = {Foo}, decl\n"
+ // FIXME: Should this target destructor instead of the type itself
+ // (similar to constructor)?
+ "1: targets = {Foo}\n"
+ "2: targets = {foo()::Foo::destructMe}, decl\n"
+ "3: targets = {Foo}\n"
+ "4: targets = {Foo}\n"
+ "5: targets = {f}, decl\n"
+ "6: targets = {f}\n"
+ "7: targets = {Foo}\n"},
// cxx constructor initializer.
{R"cpp(
class Base {};
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -596,6 +596,10 @@
}
void VisitMemberExpr(const MemberExpr *E) {
+ // Skip destructor calls to avoid duplication: TypeLoc within will be
+ // visited separately.
+ if (llvm::dyn_cast<CXXDestructorDecl>(E->getFoundDecl().getDecl()))
+ return;
Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
E->getMemberNameInfo().getLoc(),
/*IsDecl=*/false,
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits