hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137064

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -887,6 +887,17 @@
         $TemplateParameter[[T]] $Variable_def[[x]] = {};
         template <>
         int $Variable_def[[x]]<int> = (int)sizeof($Class[[Base]]);
+      )cpp",
+      // no crash
+      R"cpp(
+        struct $Class_def[[Foo]] {
+          void $Method_decl[[foo]]();
+        };
+
+        void $Function_def[[s]]($Class[[Foo]] $Parameter_def[[f]]) {
+          auto $LocalVariable_def[[k]] = &$Class[[Foo]]::$Method[[foo]];
+          ($Parameter[[f]].*$LocalVariable[[k]])(); // no crash on 
VisitCXXMemberCallExpr
+        }
       )cpp"};
   for (const auto &TestCase : TestCases)
     // Mask off scope modifiers to keep the tests manageable.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -661,7 +661,7 @@
   }
 
   bool VisitCXXMemberCallExpr(CXXMemberCallExpr *CE) {
-    if (isa<CXXDestructorDecl>(CE->getMethodDecl())) {
+    if (isa_and_nonnull<CXXDestructorDecl>(CE->getMethodDecl())) {
       if (auto *ME = dyn_cast<MemberExpr>(CE->getCallee())) {
         if (auto *TI = ME->getMemberNameInfo().getNamedTypeInfo()) {
           H.addExtraModifier(TI->getTypeLoc().getBeginLoc(),


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -887,6 +887,17 @@
         $TemplateParameter[[T]] $Variable_def[[x]] = {};
         template <>
         int $Variable_def[[x]]<int> = (int)sizeof($Class[[Base]]);
+      )cpp",
+      // no crash
+      R"cpp(
+        struct $Class_def[[Foo]] {
+          void $Method_decl[[foo]]();
+        };
+
+        void $Function_def[[s]]($Class[[Foo]] $Parameter_def[[f]]) {
+          auto $LocalVariable_def[[k]] = &$Class[[Foo]]::$Method[[foo]];
+          ($Parameter[[f]].*$LocalVariable[[k]])(); // no crash on VisitCXXMemberCallExpr
+        }
       )cpp"};
   for (const auto &TestCase : TestCases)
     // Mask off scope modifiers to keep the tests manageable.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -661,7 +661,7 @@
   }
 
   bool VisitCXXMemberCallExpr(CXXMemberCallExpr *CE) {
-    if (isa<CXXDestructorDecl>(CE->getMethodDecl())) {
+    if (isa_and_nonnull<CXXDestructorDecl>(CE->getMethodDecl())) {
       if (auto *ME = dyn_cast<MemberExpr>(CE->getCallee())) {
         if (auto *TI = ME->getMemberNameInfo().getNamedTypeInfo()) {
           H.addExtraModifier(TI->getTypeLoc().getBeginLoc(),
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to