switch Triple to take twines instead of stringrefs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2011-07-24 20:45:08 +00:00
parent 3f25ee080c
commit b7fbcc9696
2 changed files with 9 additions and 25 deletions

View File

@@ -10,8 +10,7 @@
#ifndef LLVM_ADT_TRIPLE_H #ifndef LLVM_ADT_TRIPLE_H
#define LLVM_ADT_TRIPLE_H #define LLVM_ADT_TRIPLE_H
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h"
#include <string>
// Some system headers or GCC predefined macros conflict with identifiers in // Some system headers or GCC predefined macros conflict with identifiers in
// this file. Undefine them here. // this file. Undefine them here.
@@ -19,8 +18,6 @@
#undef sparc #undef sparc
namespace llvm { namespace llvm {
class StringRef;
class Twine;
/// Triple - Helper class for working with target triples. /// Triple - Helper class for working with target triples.
/// ///
@@ -134,24 +131,16 @@ public:
/// @{ /// @{
Triple() : Data(), Arch(InvalidArch) {} Triple() : Data(), Arch(InvalidArch) {}
explicit Triple(StringRef Str) : Data(Str), Arch(InvalidArch) {} explicit Triple(const Twine &Str) : Data(Str.str()), Arch(InvalidArch) {}
explicit Triple(StringRef ArchStr, StringRef VendorStr, StringRef OSStr) Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr)
: Data(ArchStr), Arch(InvalidArch) { : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()),
Data += '-'; Arch(InvalidArch) {
Data += VendorStr;
Data += '-';
Data += OSStr;
} }
explicit Triple(StringRef ArchStr, StringRef VendorStr, StringRef OSStr, Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr,
StringRef EnvironmentStr) const Twine &EnvironmentStr)
: Data(ArchStr), Arch(InvalidArch) { : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') +
Data += '-'; EnvironmentStr).str()), Arch(InvalidArch) {
Data += VendorStr;
Data += '-';
Data += OSStr;
Data += '-';
Data += EnvironmentStr;
} }
/// @} /// @}

View File

@@ -8,16 +8,11 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/ADT/Triple.h" #include "llvm/ADT/Triple.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Twine.h"
#include <cassert>
#include <cstring> #include <cstring>
using namespace llvm; using namespace llvm;
//
const char *Triple::getArchTypeName(ArchType Kind) { const char *Triple::getArchTypeName(ArchType Kind) {
switch (Kind) { switch (Kind) {
case InvalidArch: return "<invalid>"; case InvalidArch: return "<invalid>";