From: Alex Lorenz Date: Fri, 15 Dec 2017 19:58:38 +0000 (+0000) Subject: __is_target_arch: Check the arch and subarch instead of the arch name X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3adf7e6c06c9e886fbc5f33a6c786344931ca2c9;p=clang __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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320853 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 3d72006bad..9b062643b9 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -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. diff --git a/test/Preprocessor/is_target_arm64.c b/test/Preprocessor/is_target_arm64.c new file mode 100644 index 0000000000..87ebe94d18 --- /dev/null +++ b/test/Preprocessor/is_target_arm64.c @@ -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