New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-cl] __FUNCTION__ used in templated function is not returning the same string than MSVC. #66114
Comments
@zahiraam I am currently working at semi-related problem (support of |
@llvm/issue-subscribers-clang-frontend
__FUNCTION__ in clang is not returning the same string than MS for templated functions.
See https://godbolt.org/z/88n1rGs3b For this test case MSVC is returning: I have looked at it briefly. It looks like a fix can be implemented in PredefinedExpr::ComputeName by adding a case for IK==PredefinedExpr::Function? However, I couldn't find a way to stick the "class" keyword in front of the class name. May be some policy argument should be used to print the function? @RIscRIpt I think you have been working on MS compatibility. I am wondering if you are currently working on this or if you might have some suggestion on the fix I am about to work on? |
@RIscRIpt I have a draft (unfinished) PR here: #66120. When you have a minute take a look to see if this is the right way to tackle it. Thanks. |
@zahiraam I don't have access neither of PR approval nor PR merge, so I won't pollute your PR with my comments. But as you've requested, here're my two cents:
Overall you are in the right direction. |
@RIscRIpt I wasn't able to add you as a reviewer in the PR? I suppose you have read/write access to the PR right? Don't hesitate to add comment on it. At any case I have updated the PR but still have a few doubts about the addition of "class" because it's changing the behavior of the debuginfo LIT tests. May adding "class" should be done somewhere else, or have a stricter condition or that's simply correct (will need to ask a debugger person). |
I guess this issue should've been closed by #66120. But, I found a bug in the merged implementation. Consider the following code: https://godbolt.org/z/KWTKPcG6G #include <iostream>
template<class T> class A {
public:
A() {
std::cout << __FUNCTION__ << '\n';
}
};
class C {};
struct S {};
union U {};
int main() {
A<int> i;
A<C> c;
A<S> s;
A<U> u;
return 0;
} MSVC:
Clang-cl:
Shortly, MSVC distinguishes between Another problem with new implementation, is that it makes no difference between MSVC:
Clang-cl:
Edit: MSVC also prints |
…e for c++. (#66120)" This reverts commit 265568c. See #66114 (comment)
…e for c++. (llvm#66120)" This reverts commit 265568c. See llvm#66114 (comment)
__FUNCTION__
in clang is not returning the same string than MS for templated functions.See https://godbolt.org/z/88n1rGs3b
For this test case MSVC is returning:
function: TestClass<class UnitTestNative>::TestClass
func: TestClass
I have looked at it briefly. It looks like a fix can be implemented in PredefinedExpr::ComputeName by adding a case for IK==PredefinedExpr::Function? However, I couldn't find a way to stick the "class" keyword in front of the class name. May be some policy argument should be used to print the function?
Unless everything should be computed in PredefinedExpr::ComputeName using some string manipulation (meaning getting the string from printQualifiedName and manipulating it to get the "class" keyword?
@RIscRIpt I think you have been working on MS compatibility. I am wondering if you are currently working on this or if you might have some suggestion on the fix I am about to work on?
Thanks.
The text was updated successfully, but these errors were encountered: