llvm / llvm/llvm-project

`-ast-print` drops namespace qualifier from conversion operator's target type

Open
#218,420 3 comments 1 reaction 0 assignees View on GitHub
clang:frontend
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`clang -Xclang -ast-print` for:

```cpp
namespace ns_will_be_dropped {
template struct tp {
};
}
template auto f(T t) {
return t.operator ns_will_be_dropped::tp();
}
```

drops the namespace qualifier from the conversion operator's target type ([clang-22](https://godbolt.org/z/jWq19ehfs)):

```cpp
namespace ns_will_be_dropped {
template struct tp {
};
}
template auto f(T t) {
return t.operator tp(); // <-- no namespace here
}
```

The resulting code does not compile: [clang-22](https://godbolt.org/z/W3xajdKKa)

Contributor guide

Open the contributing guide

Research direction

Start by running the reduced C++ example with clang -Xclang -ast-print and compare the printed conversion operator target type with the source. Trace the AST-printing path for conversion operators and templates; done means the namespace qualifier is retained and the printed result compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.