Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeBase.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
Expand Down Expand Up @@ -116,7 +116,8 @@ std::string removePureVirtualSyntax(const std::string &MethodDecl,

DeclString += Tk.text();
if (Tk.Kind != tok::l_paren && Next.Kind != tok::comma &&
Next.Kind != tok::r_paren && Next.Kind != tok::l_paren)
Next.Kind != tok::r_paren && Next.Kind != tok::l_paren &&
Tk.Kind != tok::coloncolon && Next.Kind != tok::coloncolon)
DeclString += ' ';
}
// Trim the last whitespace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,45 @@ class D : public B {
EXPECT_EQ(Expected, Applied) << "Applied result:\n" << Applied;
}

TEST_F(OverridePureVirtualsTests, QualifiedNames) {
constexpr auto Before = R"cpp(
namespace foo { struct S{}; namespace bar { struct S2{}; } }

class B {
public:
virtual foo::S foo(int var = 0) = 0;
virtual foo::bar::S2 bar(int var = 0) = 0;
};

class ^D : public B {};
)cpp";

constexpr auto Expected = R"cpp(
namespace foo { struct S{}; namespace bar { struct S2{}; } }

class B {
public:
virtual foo::S foo(int var = 0) = 0;
virtual foo::bar::S2 bar(int var = 0) = 0;
};

class D : public B {
public:
foo::S foo(int var = 0) override {
// TODO: Implement this pure virtual method.
static_assert(false, "Method `foo` is not implemented.");
}

foo::bar::S2 bar(int var = 0) override {
// TODO: Implement this pure virtual method.
static_assert(false, "Method `bar` is not implemented.");
}
};
)cpp";
auto Applied = apply(Before);
EXPECT_EQ(Expected, Applied) << "Applied result:\n" << Applied;
}

} // namespace
} // namespace clangd
} // namespace clang