Unverified Commit d92413a4 authored by Nathan James's avatar Nathan James
Browse files

[clangd] Selection handles CXXBaseSpecifier

Selection now includes the virtual and access modifier as part of their range for cxx base specifiers.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D95231
parent dad55c22
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -493,6 +493,9 @@ public:
    return traverseNode(
        X, [&] { return Base::TraverseConstructorInitializer(X); });
  }
  bool TraverseCXXBaseSpecifier(const CXXBaseSpecifier &X) {
    return traverseNode(&X, [&] { return Base::TraverseCXXBaseSpecifier(X); });
  }
  // Stmt is the same, but this form allows the data recursion optimization.
  bool dataTraverseStmtPre(Stmt *X) {
    if (!X || isImplicit(X))
+6 −0
Original line number Diff line number Diff line
@@ -1024,6 +1024,12 @@ TEST(RenameTest, Renameable) {
        }
      )cpp",
       "new name is the same", !HeaderFile, nullptr, "SameName"},
      {R"cpp(// Ensure it doesn't associate base specifier with base name.
        struct A {};
        struct B : priv^ate A {};
      )cpp",
       "Cannot rename symbol: there is no symbol at the given location", false,
       nullptr},
  };

  for (const auto& Case : Cases) {
+21 −0
Original line number Diff line number Diff line
@@ -261,6 +261,27 @@ TEST(SelectionTest, CommonAncestor) {
          )cpp",
          "StringLiteral", // Not DeclRefExpr to operator()!
      },
      {
          R"cpp(
            struct Foo {};
            struct Bar : [[v^ir^tual private Foo]] {};
          )cpp",
          "CXXBaseSpecifier",
      },
      {
          R"cpp(
            struct Foo {};
            struct Bar : private [[Fo^o]] {};
          )cpp",
          "RecordTypeLoc",
      },
      {
          R"cpp(
            struct Foo {};
            struct Bar : [[Fo^o]] {};
          )cpp",
          "RecordTypeLoc",
      },

      // Point selections.
      {"void foo() { [[^foo]](); }", "DeclRefExpr"},
+2 −0
Original line number Diff line number Diff line
@@ -193,5 +193,7 @@ SourceRange DynTypedNode::getSourceRange() const {
    return TAL->getSourceRange();
  if (const auto *C = get<OMPClause>())
    return SourceRange(C->getBeginLoc(), C->getEndLoc());
  if (const auto *CBS = get<CXXBaseSpecifier>())
    return CBS->getSourceRange();
  return SourceRange();
}