Ericson2314 created this revision.
Ericson2314 added reviewers: arphaman, compnerd, dexonsmith, bob.wilson, 
steven_wu.
Herald added subscribers: cfe-commits, javed.absar.

Per my belated [reply] to the mailing list, I believe the "target"
nomenclature incorrect for cross compilation.

[reply]: http://lists.llvm.org/pipermail/cfe-dev/2018-March/057258.html


Repository:
  rC Clang

https://reviews.llvm.org/D44753

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPMacroExpansion.cpp
  test/Preprocessor/is_host.c
  test/Preprocessor/is_host_arm.c
  test/Preprocessor/is_host_arm64.c
  test/Preprocessor/is_host_environment_version.c
  test/Preprocessor/is_host_os_darwin.c
  test/Preprocessor/is_host_unknown.c
  test/Preprocessor/is_target.c
  test/Preprocessor/is_target_arm.c
  test/Preprocessor/is_target_arm64.c
  test/Preprocessor/is_target_environment_version.c
  test/Preprocessor/is_target_os_darwin.c
  test/Preprocessor/is_target_unknown.c

Index: test/Preprocessor/is_target.c
===================================================================
--- test/Preprocessor/is_target.c
+++ /dev/null
@@ -1,67 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin-simulator -verify %s
-
-#if !__is_target_arch(x86_64) || !__is_target_arch(X86_64)
-  #error "mismatching arch"
-#endif
-
-#if __is_target_arch(arm64)
-  #error "mismatching arch"
-#endif
-
-// Silently ignore invalid archs. This will ensure that older compilers will
-// accept headers that support new arches/vendors/os variants.
-#if __is_target_arch(foo)
-  #error "invalid arch"
-#endif
-
-#if !__is_target_vendor(apple) || !__is_target_vendor(APPLE)
-  #error "mismatching vendor"
-#endif
-
-#if __is_target_vendor(unknown)
-  #error "mismatching vendor"
-#endif
-
-#if __is_target_vendor(foo)
-  #error "invalid vendor"
-#endif
-
-#if !__is_target_os(darwin) || !__is_target_os(DARWIN)
-  #error "mismatching os"
-#endif
-
-#if __is_target_os(ios)
-  #error "mismatching os"
-#endif
-
-#if __is_target_os(foo)
-  #error "invalid os"
-#endif
-
-#if !__is_target_environment(simulator) || !__is_target_environment(SIMULATOR)
-  #error "mismatching environment"
-#endif
-
-#if __is_target_environment(unknown)
-  #error "mismatching environment"
-#endif
-
-#if __is_target_environment(foo)
-  #error "invalid environment"
-#endif
-
-#if !__has_builtin(__is_target_arch) || !__has_builtin(__is_target_os) || !__has_builtin(__is_target_vendor) || !__has_builtin(__is_target_environment)
-  #error "has builtin doesn't work"
-#endif
-
-#if __is_target_arch(11) // expected-error {{builtin feature check macro requires a parenthesized identifier}}
-  #error "invalid arch"
-#endif
-
-#if __is_target_arch x86 // expected-error{{missing '(' after '__is_target_arch'}}
-  #error "invalid arch"
-#endif
-
-#if __is_target_arch ( x86  // expected-error {{unterminated function-like macro invocation}}
-  #error "invalid arch"
-#endif // expected-error@-2 {{expected value in expression}}
Index: test/Preprocessor/is_host_unknown.c
===================================================================
--- test/Preprocessor/is_host_unknown.c
+++ test/Preprocessor/is_host_unknown.c
@@ -2,21 +2,21 @@
 // RUN: %clang_cc1 -fsyntax-only -triple i686-- -verify %s
 // expected-no-diagnostics
 
-#if __is_target_arch(unknown)
+#if __is_host_arch(unknown)
   #error "mismatching arch"
 #endif
 
 // Unknown vendor is allowed.
-#if !__is_target_vendor(unknown)
+#if !__is_host_vendor(unknown)
   #error "mismatching vendor"
 #endif
 
 // Unknown OS is allowed.
-#if !__is_target_os(unknown)
+#if !__is_host_os(unknown)
   #error "mismatching OS"
 #endif
 
 // Unknown environment is allowed.
-#if !__is_target_environment(unknown)
+#if !__is_host_environment(unknown)
   #error "mismatching environment"
 #endif
Index: test/Preprocessor/is_host_os_darwin.c
===================================================================
--- test/Preprocessor/is_host_os_darwin.c
+++ test/Preprocessor/is_host_os_darwin.c
@@ -4,22 +4,22 @@
 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-watchos -verify %s
 // expected-no-diagnostics
 
-#if !__is_target_os(darwin)
+#if !__is_host_os(darwin)
   #error "mismatching os"
 #endif
 
 // macOS matches both macOS and macOSX.
 #ifdef MAC
 
-#if !__is_target_os(macos)
+#if !__is_host_os(macos)
   #error "mismatching os"
 #endif
 
-#if !__is_target_os(macosx)
+#if !__is_host_os(macosx)
   #error "mismatching os"
 #endif
 
-#if __is_target_os(ios)
+#if __is_host_os(ios)
   #error "mismatching os"
 #endif
 
Index: test/Preprocessor/is_host_environment_version.c
===================================================================
--- test/Preprocessor/is_host_environment_version.c
+++ test/Preprocessor/is_host_environment_version.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-pc-windows-msvc18.0.0 -verify %s
 // expected-no-diagnostics
 
-#if !__is_target_environment(msvc)
+#if !__is_host_environment(msvc)
   #error "mismatching environment"
 #endif
Index: test/Preprocessor/is_host_arm64.c
===================================================================
--- test/Preprocessor/is_host_arm64.c
+++ test/Preprocessor/is_host_arm64.c
@@ -1,10 +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)
+#if !__is_host_arch(arm64) || !__is_host_arch(aarch64)
   #error "mismatching arch"
 #endif
 
-#if __is_target_arch(aarch64_be)
+#if __is_host_arch(aarch64_be)
   #error "mismatching arch"
 #endif
Index: test/Preprocessor/is_host_arm.c
===================================================================
--- test/Preprocessor/is_host_arm.c
+++ test/Preprocessor/is_host_arm.c
@@ -3,48 +3,48 @@
 // expected-no-diagnostics
 
 // ARM does match arm and thumb.
-#if !__is_target_arch(arm)
+#if !__is_host_arch(arm)
   #error "mismatching arch"
 #endif
 
-#if __is_target_arch(armeb) || __is_target_arch(armebv7) || __is_target_arch(thumbeb) || __is_target_arch(thumbebv7)
+#if __is_host_arch(armeb) || __is_host_arch(armebv7) || __is_host_arch(thumbeb) || __is_host_arch(thumbebv7)
   #error "mismatching arch"
 #endif
 
 // ARMV7 does match armv7 and thumbv7.
-#if !__is_target_arch(armv7)
+#if !__is_host_arch(armv7)
   #error "mismatching arch"
 #endif
 
 // ARMV6 does not match armv7 or thumbv7.
-#if __is_target_arch(armv6)
+#if __is_host_arch(armv6)
   #error "mismatching arch"
 #endif
 
-#if __is_target_arch(arm64)
+#if __is_host_arch(arm64)
   #error "mismatching arch"
 #endif
 
 #ifndef ARM
 
 // Allow checking for precise arch + subarch.
-#if !__is_target_arch(thumbv7)
+#if !__is_host_arch(thumbv7)
   #error "mismatching arch"
 #endif
 
 // But also allow checking for the arch without subarch.
-#if !__is_target_arch(thumb)
+#if !__is_host_arch(thumb)
   #error "mismatching arch"
 #endif
 
 // Same arch with a different subarch doesn't match.
-#if __is_target_arch(thumbv6)
+#if __is_host_arch(thumbv6)
   #error "mismatching arch"
 #endif
 
 #else
 
-#if __is_target_arch(thumbv7) || __is_target_arch(thumb)
+#if __is_host_arch(thumbv7) || __is_host_arch(thumb)
   #error "mismatching arch"
 #endif
 
Index: test/Preprocessor/is_host.c
===================================================================
--- /dev/null
+++ test/Preprocessor/is_host.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin-simulator -verify %s
+
+#if !__is_host_arch(x86_64) || !__is_host_arch(X86_64)
+  #error "mismatching arch"
+#endif
+
+#if __is_host_arch(arm64)
+  #error "mismatching arch"
+#endif
+
+// Silently ignore invalid archs. This will ensure that older compilers will
+// accept headers that support new arches/vendors/os variants.
+#if __is_host_arch(foo)
+  #error "invalid arch"
+#endif
+
+#if !__is_host_vendor(apple) || !__is_host_vendor(APPLE)
+  #error "mismatching vendor"
+#endif
+
+#if __is_host_vendor(unknown)
+  #error "mismatching vendor"
+#endif
+
+#if __is_host_vendor(foo)
+  #error "invalid vendor"
+#endif
+
+#if !__is_host_os(darwin) || !__is_host_os(DARWIN)
+  #error "mismatching os"
+#endif
+
+#if __is_host_os(ios)
+  #error "mismatching os"
+#endif
+
+#if __is_host_os(foo)
+  #error "invalid os"
+#endif
+
+#if !__is_host_environment(simulator) || !__is_host_environment(SIMULATOR)
+  #error "mismatching environment"
+#endif
+
+#if __is_host_environment(unknown)
+  #error "mismatching environment"
+#endif
+
+#if __is_host_environment(foo)
+  #error "invalid environment"
+#endif
+
+#if !__has_builtin(__is_host_arch) || !__has_builtin(__is_host_os) || !__has_builtin(__is_host_vendor) || !__has_builtin(__is_host_environment)
+  #error "has builtin doesn't work"
+#endif
+
+#if __is_host_arch(11) // expected-error {{builtin feature check macro requires a parenthesized identifier}}
+  #error "invalid arch"
+#endif
+
+#if __is_host_arch x86 // expected-error{{missing '(' after '__is_host_arch'}}
+  #error "invalid arch"
+#endif
+
+#if __is_host_arch ( x86  // expected-error {{unterminated function-like macro invocation}}
+  #error "invalid arch"
+#endif // expected-error@-2 {{expected value in expression}}
Index: lib/Lex/PPMacroExpansion.cpp
===================================================================
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -375,11 +375,11 @@
   Ident__has_include_next = RegisterBuiltinMacro(*this, "__has_include_next");
   Ident__has_warning      = RegisterBuiltinMacro(*this, "__has_warning");
   Ident__is_identifier    = RegisterBuiltinMacro(*this, "__is_identifier");
-  Ident__is_target_arch   = RegisterBuiltinMacro(*this, "__is_target_arch");
-  Ident__is_target_vendor = RegisterBuiltinMacro(*this, "__is_target_vendor");
-  Ident__is_target_os     = RegisterBuiltinMacro(*this, "__is_target_os");
-  Ident__is_target_environment =
-      RegisterBuiltinMacro(*this, "__is_target_environment");
+  Ident__is_host_arch     = RegisterBuiltinMacro(*this, "__is_host_arch");
+  Ident__is_host_vendor   = RegisterBuiltinMacro(*this, "__is_host_vendor");
+  Ident__is_host_os       = RegisterBuiltinMacro(*this, "__is_host_os");
+  Ident__is_host_environment =
+      RegisterBuiltinMacro(*this, "__is_host_environment");
 
   // Modules.
   Ident__building_module  = RegisterBuiltinMacro(*this, "__building_module");
@@ -1599,8 +1599,8 @@
   return nullptr;
 }
 
-/// Implements the __is_target_arch builtin macro.
-static bool isTargetArch(const TargetInfo &TI, const IdentifierInfo *II) {
+/// Implements the __is_host_arch builtin macro.
+static bool isHostArch(const TargetInfo &TI, const IdentifierInfo *II) {
   std::string ArchName = II->getName().lower() + "--";
   llvm::Triple Arch(ArchName);
   const llvm::Triple &TT = TI.getTriple();
@@ -1621,16 +1621,16 @@
          Arch.getArch() == TT.getArch();
 }
 
-/// Implements the __is_target_vendor builtin macro.
-static bool isTargetVendor(const TargetInfo &TI, const IdentifierInfo *II) {
+/// Implements the __is_host_vendor builtin macro.
+static bool isHostVendor(const TargetInfo &TI, const IdentifierInfo *II) {
   StringRef VendorName = TI.getTriple().getVendorName();
   if (VendorName.empty())
     VendorName = "unknown";
   return VendorName.equals_lower(II->getName());
 }
 
-/// Implements the __is_target_os builtin macro.
-static bool isTargetOS(const TargetInfo &TI, const IdentifierInfo *II) {
+/// Implements the __is_host_os builtin macro.
+static bool isHostOS(const TargetInfo &TI, const IdentifierInfo *II) {
   std::string OSName =
       (llvm::Twine("unknown-unknown-") + II->getName().lower()).str();
   llvm::Triple OS(OSName);
@@ -1641,8 +1641,8 @@
   return TI.getTriple().getOS() == OS.getOS();
 }
 
-/// Implements the __is_target_environment builtin macro.
-static bool isTargetEnvironment(const TargetInfo &TI,
+/// Implements the __is_host_environment builtin macro.
+static bool isHostEnvironment(const TargetInfo &TI,
                                 const IdentifierInfo *II) {
   std::string EnvName = (llvm::Twine("---") + II->getName().lower()).str();
   llvm::Triple Env(EnvName);
@@ -1811,10 +1811,10 @@
                       .Case("__make_integer_seq", LangOpts.CPlusPlus)
                       .Case("__type_pack_element", LangOpts.CPlusPlus)
                       .Case("__builtin_available", true)
-                      .Case("__is_target_arch", true)
-                      .Case("__is_target_vendor", true)
-                      .Case("__is_target_os", true)
-                      .Case("__is_target_environment", true)
+                      .Case("__is_host_arch", true)
+                      .Case("__is_host_vendor", true)
+                      .Case("__is_host_os", true)
+                      .Case("__is_host_environment", true)
                       .Default(false);
         }
       });
@@ -1966,33 +1966,33 @@
       Diag(LParenLoc, diag::note_matching) << tok::l_paren;
     }
     return;
-  } else if (II == Ident__is_target_arch) {
+  } else if (II == Ident__is_host_arch) {
     EvaluateFeatureLikeBuiltinMacro(
         OS, Tok, II, *this, [this](Token &Tok, bool &HasLexedNextToken) -> int {
           IdentifierInfo *II = ExpectFeatureIdentifierInfo(
               Tok, *this, diag::err_feature_check_malformed);
-          return II && isTargetArch(getTargetInfo(), II);
+          return II && isHostArch(getTargetInfo(), II);
         });
-  } else if (II == Ident__is_target_vendor) {
+  } else if (II == Ident__is_host_vendor) {
     EvaluateFeatureLikeBuiltinMacro(
         OS, Tok, II, *this, [this](Token &Tok, bool &HasLexedNextToken) -> int {
           IdentifierInfo *II = ExpectFeatureIdentifierInfo(
               Tok, *this, diag::err_feature_check_malformed);
-          return II && isTargetVendor(getTargetInfo(), II);
+          return II && isHostVendor(getTargetInfo(), II);
         });
-  } else if (II == Ident__is_target_os) {
+  } else if (II == Ident__is_host_os) {
     EvaluateFeatureLikeBuiltinMacro(
         OS, Tok, II, *this, [this](Token &Tok, bool &HasLexedNextToken) -> int {
           IdentifierInfo *II = ExpectFeatureIdentifierInfo(
               Tok, *this, diag::err_feature_check_malformed);
-          return II && isTargetOS(getTargetInfo(), II);
+          return II && isHostOS(getTargetInfo(), II);
         });
-  } else if (II == Ident__is_target_environment) {
+  } else if (II == Ident__is_host_environment) {
     EvaluateFeatureLikeBuiltinMacro(
         OS, Tok, II, *this, [this](Token &Tok, bool &HasLexedNextToken) -> int {
           IdentifierInfo *II = ExpectFeatureIdentifierInfo(
               Tok, *this, diag::err_feature_check_malformed);
-          return II && isTargetEnvironment(getTargetInfo(), II);
+          return II && isHostEnvironment(getTargetInfo(), II);
         });
   } else {
     llvm_unreachable("Unknown identifier!");
Index: include/clang/Lex/Preprocessor.h
===================================================================
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -175,10 +175,10 @@
   IdentifierInfo *Ident__has_cpp_attribute;        // __has_cpp_attribute
   IdentifierInfo *Ident__has_c_attribute;          // __has_c_attribute
   IdentifierInfo *Ident__has_declspec;             // __has_declspec_attribute
-  IdentifierInfo *Ident__is_target_arch;           // __is_target_arch
-  IdentifierInfo *Ident__is_target_vendor;         // __is_target_vendor
-  IdentifierInfo *Ident__is_target_os;             // __is_target_os
-  IdentifierInfo *Ident__is_target_environment;    // __is_target_environment
+  IdentifierInfo *Ident__is_host_arch;             // __is_host_arch
+  IdentifierInfo *Ident__is_host_vendor;           // __is_host_vendor
+  IdentifierInfo *Ident__is_host_os;               // __is_host_os
+  IdentifierInfo *Ident__is_host_environment;      // __is_host_environment
 
   SourceLocation DATELoc, TIMELoc;
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to