mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 07:01:03 +08:00
__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:
@@ -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.
|
||||
|
||||
10
clang/test/Preprocessor/is_target_arm64.c
Normal file
10
clang/test/Preprocessor/is_target_arm64.c
Normal 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
|
||||
Reference in New Issue
Block a user