[clang] [Clang] Reject __annotation on unsupported targets (PR #193731)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 28 01:58:45 PDT 2026
================
@@ -3263,10 +3263,17 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
case Builtin::BI##ID: \
return AtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID);
#include "clang/Basic/Builtins.inc"
- case Builtin::BI__annotation:
+ case Builtin::BI__annotation: {
+ const llvm::Triple &TT = Context.getTargetInfo().getTriple();
+ if (!TT.isOSWindows() && !TT.isUEFI()) {
----------------
kjedruczyk wrote:
Now that's an interesting observation - you're right that clang allows it even on UEFI, where as far as I can tell it goes against the standard: https://godbolt.org/z/jP137Wdqx
I am not sure why this is allowed, but since it is: I wouldn't think that rejecting the CodeView annotations based on wchar width is the right thing. As long as there is a reason to support `-fno-short-wchar` on these targets, the annotation should probably be supported too, especially since it's normalized to UTF8 after all.
My suggestion would be to bring back 9f4a8007ac96ee96e15da962e0bc51c9429c5761 on top of platform checks, so we get both rejection of CodeView annotations on non Windows/UEFI COFF targets and avoid assertion triggering when the `wchar` width assumption doesn't hold.
FWIW, maybe it would be worthwhile to add a wchar-width agnostic version of the UTF8 conversion, instead of awkwardly dispatching on wchar width when UTF8 form is needed (I'm surprised such conversion doesn't seem to exist but maybe I'm missing something)?
https://github.com/llvm/llvm-project/pull/193731
More information about the cfe-commits
mailing list