Skip to content

[clang] namespace duplicated in getQualifiedNameAsString output #155537

@rupprecht

Description

@rupprecht

Calling getQualifiedNameAsString() for a function decl in a namespace will end up duplicating the namespace.

Test case (using the pattern from LookupTest.cpp):

namespace {
struct CheckFunctionDeclVisitor : TestVisitor {
  bool VisitFunctionDecl(FunctionDecl *FD) override {
    EXPECT_EQ("x::y::Foo::Foo<T>", FD->getQualifiedNameAsString());
    return true;
  }
};
}

TEST(LookupTest, namespaceInQualifiedName) {
  CheckFunctionDeclVisitor Visitor;
  Visitor.runOver(
      "namespace x { namespace y {\n"
      "template <typename T> class Foo { Foo() {} };\n"
      "}}");
}

This passes prior to #147835. After that, and still at trunk, it fails:

Expected equality of these values:
  "x::y::Foo::Foo<T>"
  FD->getQualifiedNameAsString()
    Which is: "x::y::Foo::x::y::Foo<T>"

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions