From 0e8f630de9f8c50793c471e42f5200562cc28733 Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 9 Jul 2025 13:05:27 -0700 Subject: [PATCH 1/2] [ARM] Improve arm_neon.h header diagnostic when included on unsupported targets The footgun here was that the preprocessor diagnostic that looks for __ARM_FP would fire when included on targets like x86_64, but the suggestion it gives in that case is totally bogus. Avoid giving bad advice, by first checking whether we're being built for an appropriate target, and only then do the soft-fp check. rdar://155449666 --- clang/utils/TableGen/NeonEmitter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 409f1c4f71834..03da69ce7feb4 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -2417,7 +2417,9 @@ void NeonEmitter::run(raw_ostream &OS) { OS << "#ifndef __ARM_NEON_H\n"; OS << "#define __ARM_NEON_H\n\n"; - OS << "#ifndef __ARM_FP\n"; + OS << "#if !defined(__arm__) && !defined(__aarch64__) && !defined(__arm64ec__)\n"; + OS << "#error \" is intended only for ARM and AArch64 targets\"\n"; + OS << "#elif !defined(__ARM_FP)\n"; OS << "#error \"NEON intrinsics not available with the soft-float ABI. " "Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n"; OS << "#else\n\n"; From ec89296c2fea642719fa20675cf6c265eeb80bab Mon Sep 17 00:00:00 2001 From: Jon Roelofs Date: Wed, 9 Jul 2025 13:41:50 -0700 Subject: [PATCH 2/2] clang-format --- clang/utils/TableGen/NeonEmitter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 03da69ce7feb4..d4fb56e6a39b7 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -2417,8 +2417,10 @@ void NeonEmitter::run(raw_ostream &OS) { OS << "#ifndef __ARM_NEON_H\n"; OS << "#define __ARM_NEON_H\n\n"; - OS << "#if !defined(__arm__) && !defined(__aarch64__) && !defined(__arm64ec__)\n"; - OS << "#error \" is intended only for ARM and AArch64 targets\"\n"; + OS << "#if !defined(__arm__) && !defined(__aarch64__) && " + "!defined(__arm64ec__)\n"; + OS << "#error \" is intended only for ARM and AArch64 " + "targets\"\n"; OS << "#elif !defined(__ARM_FP)\n"; OS << "#error \"NEON intrinsics not available with the soft-float ABI. " "Please use -mfloat-abi=softfp or -mfloat-abi=hard\"\n";