r320853 - __is_target_arch: Check the arch and subarch instead of the arch name
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 15 11:58:39 PST 2017
Author: arphaman
Date: Fri Dec 15 11:58:38 2017
New Revision: 320853
URL: http://llvm.org/viewvc/llvm-project?rev=320853&view=rev
Log:
__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!
Added:
cfe/trunk/test/Preprocessor/is_target_arm64.c
Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=320853&r1=320852&r2=320853&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Dec 15 11:58:38 2017
@@ -1615,9 +1615,9 @@ static bool isTargetArch(const TargetInf
}
// 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.
Added: cfe/trunk/test/Preprocessor/is_target_arm64.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/is_target_arm64.c?rev=320853&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/is_target_arm64.c (added)
+++ cfe/trunk/test/Preprocessor/is_target_arm64.c Fri Dec 15 11:58:38 2017
@@ -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
More information about the cfe-commits
mailing list