diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-10-01 01:16:22 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-10-01 01:16:22 +0000 |
commit | b7fb1245129a8336ede6179119294879b50935c9 (patch) | |
tree | b60b03aee98d09b73e6eafee2124d35f4a15cd64 | |
parent | d216922a806eee5b5119ffd2dee836c459654583 (diff) | |
download | bcm5719-llvm-b7fb1245129a8336ede6179119294879b50935c9.tar.gz bcm5719-llvm-b7fb1245129a8336ede6179119294879b50935c9.zip |
Use StringRef in Triple API (NFC)
llvm-svn: 282996
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 9 | ||||
-rw-r--r-- | llvm/include/llvm/ADT/Triple.h | 10 | ||||
-rw-r--r-- | llvm/lib/Support/Triple.cpp | 14 |
3 files changed, 17 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 8ce69b8921e..c272e80d5df 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -2492,14 +2492,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, // See if we have a target specific intrinsic. const char *Name = getContext().BuiltinInfo.getName(BuiltinID); Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic; - if (const char *Prefix = - llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch())) { - IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix, Name); + StringRef Prefix = + llvm::Triple::getArchTypePrefix(getTarget().getTriple().getArch()); + if (!Prefix.empty()) { + IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name); // NOTE we dont need to perform a compatibility flag check here since the // intrinsics are declared in Builtins*.def via LANGBUILTIN which filter the // MS builtins via ALL_MS_LANGUAGES and are filtered earlier. if (IntrinsicID == Intrinsic::not_intrinsic) - IntrinsicID = Intrinsic::getIntrinsicForMSBuiltin(Prefix, Name); + IntrinsicID = Intrinsic::getIntrinsicForMSBuiltin(Prefix.data(), Name); } if (IntrinsicID != Intrinsic::not_intrinsic) { diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index 6173cd2bd91..2e02045f157 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -691,7 +691,7 @@ public: /// @{ /// getArchTypeName - Get the canonical name for the \p Kind architecture. - static const char *getArchTypeName(ArchType Kind); + static StringRef getArchTypeName(ArchType Kind); /// getArchTypePrefix - Get the "prefix" canonical name for the \p Kind /// architecture. This is the prefix used by the architecture specific @@ -699,17 +699,17 @@ public: /// Intrinsic::getIntrinsicForGCCBuiltin(). /// /// \return - The architecture prefix, or 0 if none is defined. - static const char *getArchTypePrefix(ArchType Kind); + static StringRef getArchTypePrefix(ArchType Kind); /// getVendorTypeName - Get the canonical name for the \p Kind vendor. - static const char *getVendorTypeName(VendorType Kind); + static StringRef getVendorTypeName(VendorType Kind); /// getOSTypeName - Get the canonical name for the \p Kind operating system. - static const char *getOSTypeName(OSType Kind); + static StringRef getOSTypeName(OSType Kind); /// getEnvironmentTypeName - Get the canonical name for the \p Kind /// environment. - static const char *getEnvironmentTypeName(EnvironmentType Kind); + static StringRef getEnvironmentTypeName(EnvironmentType Kind); /// @} /// @name Static helpers for converting alternate architecture names. diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 179e9d2790f..bc12203d817 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -17,7 +17,7 @@ #include <cstring> using namespace llvm; -const char *Triple::getArchTypeName(ArchType Kind) { +StringRef Triple::getArchTypeName(ArchType Kind) { switch (Kind) { case UnknownArch: return "unknown"; @@ -71,10 +71,10 @@ const char *Triple::getArchTypeName(ArchType Kind) { llvm_unreachable("Invalid ArchType!"); } -const char *Triple::getArchTypePrefix(ArchType Kind) { +StringRef Triple::getArchTypePrefix(ArchType Kind) { switch (Kind) { default: - return nullptr; + return StringRef(); case aarch64: case aarch64_be: return "aarch64"; @@ -137,7 +137,7 @@ const char *Triple::getArchTypePrefix(ArchType Kind) { } } -const char *Triple::getVendorTypeName(VendorType Kind) { +StringRef Triple::getVendorTypeName(VendorType Kind) { switch (Kind) { case UnknownVendor: return "unknown"; @@ -160,7 +160,7 @@ const char *Triple::getVendorTypeName(VendorType Kind) { llvm_unreachable("Invalid VendorType!"); } -const char *Triple::getOSTypeName(OSType Kind) { +StringRef Triple::getOSTypeName(OSType Kind) { switch (Kind) { case UnknownOS: return "unknown"; @@ -197,7 +197,7 @@ const char *Triple::getOSTypeName(OSType Kind) { llvm_unreachable("Invalid OSType"); } -const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) { +StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { switch (Kind) { case UnknownEnvironment: return "unknown"; case GNU: return "gnu"; @@ -557,7 +557,7 @@ static Triple::SubArchType parseSubArch(StringRef SubArchName) { } } -static const char *getObjectFormatTypeName(Triple::ObjectFormatType Kind) { +static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) { switch (Kind) { case Triple::UnknownObjectFormat: return ""; case Triple::COFF: return "coff"; |