When expanding template arguments for pretty function printing,
such as for PRETTY_FUNCTION, make TypePrinter apply
macro-prefix-map remapping to anonymous tags such as lambdas.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I still need to make a unit test for this. Should be more-or-less a cleaned up version of the testcase in https://github.com/llvm/llvm-project/issues/63219.
clang/lib/AST/Expr.cpp | ||
---|---|---|
791 | Makes sense, I was going for unambiguity between the class's member name and the constructor argument name, but if it's widely used that's fine. I'll add that change when I add unit tests. |
Looks great!
[clang] Fix filename remapping in template arguments
Personally I don't consider this a bug fix (AnonymousTagLocations behavior in TypePrinter; GCC doesn't print the filename), so I'd avoid "Fix", but this changes does move into a desired direction, by making -fmacro-prefix-map= add local determinism.
I wonder whether Make -fmacro-prefix-map= apply to anonymous tag in TypePrinter will be more meaningful subject without being too verbose.
clang/test/CodeGenCXX/file-prefix-map-lambda.cpp | ||
---|---|---|
1 ↗ | (On Diff #530638) | You can use -triple x86_64 to test generic ELF behavior, if you don't want to write linux-gnu :) For this test, perhaps -triple %itanium_abi_triple is better (coverage for non-x86 targets). |
2 ↗ | (On Diff #530638) | For the new test file, I was thinking of https://maskray.me/blog/2021-08-08-toolchain-testing#the-test-checks-at-the-wrong-layer#i-dont-know-an-existing-test-can-be-enhanced. The main C++ test CodeGenCXX/predefined-expr.cpp does not say about __PRETTY_FUNCTION__ in its filename, so a new file seems fine. If we are going to retain this new test, I think macro-prefix-map- is a better prefix. |
11 ↗ | (On Diff #530638) | 10 should be replaced with [[#@LINE-1]] so that adding more tests will not easily make this stale. |
Avoiding "Fix" in the description is a good suggestion. Whether it's a bugfix or not is a matter of perspective, and what's really happening here is I'm adjusting compliant implementation defined behavior, not really fixing it.
clang/test/CodeGenCXX/file-prefix-map-lambda.cpp | ||
---|---|---|
1 ↗ | (On Diff #530638) | Generic ELF (or rather Itanium ABI) is probably fine, I just found Windows didn't work, so used the platform I was testing on. But I like the itanium abi triple suggestion. |
2 ↗ | (On Diff #530638) | Yes, I was just quickly thinking of a new filename; macro-prefix-map makes more sense to me too. I'll rename the file. |
11 ↗ | (On Diff #530638) | Thanks, I was looking for how to do that. Not too familiar with filecheck and lit. |
Maybe for the description something like:
Apply -fmacro-prefix-map to anonymous tags in template arguments
Do I need to mention TypePrinter?
LG, but give @aaron.ballman and @shafik some time if they have opinions.
I think it's fine to not mention it in the subject. You can mention TypePrinter in the description, though.
clang/docs/ReleaseNotes.rst | ||
---|---|---|
514 | This needs adjustment as the subject has changed. |
Hi,
clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp | ||
---|---|---|
11 | Hi, it's weird that the align in CSKY target is not 1, instead it's 4. Anybody know the key point? |
clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp | ||
---|---|---|
11 | And on SystemZ it's 2. |
This needs adjustment as the subject has changed.