[PATCH] D85028: [clangd] Support new/deleta operator in TargetFinder.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 31 07:17:06 PDT 2020
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85028
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -559,6 +559,28 @@
};
)cpp";
EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
+
+ Code = R"cpp(
+ struct X {
+ static void *operator new(unsigned long s);
+ };
+
+ void k() {
+ [[new]] X();
+ }
+ )cpp";
+ EXPECT_DECLS("CXXNewExpr", "static void *operator new(unsigned long s)");
+
+ Code = R"cpp(
+ struct X {
+ static void operator delete(void *) noexcept;
+ };
+
+ void k(X* x) {
+ [[delete]] x;
+ }
+ )cpp";
+ EXPECT_DECLS("CXXDeleteExpr", "static void operator delete(void *) noexcept");
}
TEST_F(TargetDeclTest, DependentExprs) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -460,6 +460,12 @@
void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
Outer.add(POE->getSyntacticForm(), Flags);
}
+ void VisitCXXNewExpr(const CXXNewExpr *CNE) {
+ Outer.add(CNE->getOperatorNew(), Flags);
+ }
+ void VisitCXXDeleteExpr(const CXXDeleteExpr *CNE) {
+ Outer.add(CNE->getOperatorDelete(), Flags);
+ }
};
Visitor(*this, Flags).Visit(S);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85028.282214.patch
Type: text/x-patch
Size: 1513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200731/03e49fc3/attachment.bin>
More information about the cfe-commits
mailing list