this patch fixes Bug 27113 by adding support for string literals to the implementation of the MS extension __identifier.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Interesting, I hadn't seen __identifier before. It seems like a pretty esoteric feature.
clang/lib/Lex/PPMacroExpansion.cpp | ||
---|---|---|
1818 | I'm not sure this is the right way to get the string out of a string_literal.. this pattern seems more common: https://github.com/llvm/llvm-project/blob/llvmorg-12.0.0/clang/lib/Lex/Pragma.cpp#L755 For example, what should happen with __identifier("foo" "bar")? | |
1820 | It says in the bug report that MSVC emits a warning for this. What does the warning look like, and would it make sense for Clang too warn too (it might not, just wondering if we should consider it). | |
clang/test/Parser/MicrosoftExtensions.cpp | ||
273 | Maybe instead of removing this, move it to the cases that work above. For example, I guess this should work now? int __identifier("foo") = 42; int bar = foo; | |
282 | It would be interesting to see a non-error test case too, perhaps with a mangled name like in the PR, and to see that it makes it through to LLVM IR correctly.. |
Correctly handle string literals and add more test cases. Also MSVC by default gives an error when trying to use __identifier with a string literal but disabling/suppressing that error allows string literals to be used with __identifier. However given how esoteric it is, it wouldn't really be necessary for clang to give a warning or error like MSVC
I'm not sure this is the right way to get the string out of a string_literal.. this pattern seems more common: https://github.com/llvm/llvm-project/blob/llvmorg-12.0.0/clang/lib/Lex/Pragma.cpp#L755
For example, what should happen with __identifier("foo" "bar")?