__is_target_arch: Check the arch and subarch instead of the arch name

This ensures that when compiling for "arm64" __is_target_arch will succeed for
both "arm64" and "aarch64".

Thanks to Bob Wilson who pointed this out!

llvm-svn: 320853
This commit is contained in:
Alex Lorenz 2017-12-15 19:58:38 +00:00
parent 72546fe87b
commit 268759e58f
2 changed files with 13 additions and 3 deletions

View File

@ -1615,9 +1615,9 @@ static bool isTargetArch(const TargetInfo &TI, const IdentifierInfo *II) {
}
// Check the parsed arch when it has no sub arch to allow Clang to
// match thumb to thumbv7 but to prohibit matching thumbv6 to thumbv7.
return (Arch.getSubArch() == llvm::Triple::NoSubArch &&
Arch.getArch() == TT.getArch()) ||
Arch.getArchName() == TT.getArchName();
return (Arch.getSubArch() == llvm::Triple::NoSubArch ||
Arch.getSubArch() == TT.getSubArch()) &&
Arch.getArch() == TT.getArch();
}
/// Implements the __is_target_vendor builtin macro.

View File

@ -0,0 +1,10 @@
// RUN: %clang_cc1 -fsyntax-only -triple arm64-apple-ios11 -verify %s
// expected-no-diagnostics
#if !__is_target_arch(arm64) || !__is_target_arch(aarch64)
#error "mismatching arch"
#endif
#if __is_target_arch(aarch64_be)
#error "mismatching arch"
#endif