diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-02-20 00:02:47 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-02-20 00:02:47 +0000 |
commit | 0d887dd0b905da589c75664430e5ad7eb033b512 (patch) | |
tree | 2790d5c8c38f5a6dccee29a5e34ad209c62e4598 | |
parent | 807c2dba606c028229f3a0c156625c6e4ec66a65 (diff) | |
download | llvm-0d887dd0b905da589c75664430e5ad7eb033b512.zip llvm-0d887dd0b905da589c75664430e5ad7eb033b512.tar.gz llvm-0d887dd0b905da589c75664430e5ad7eb033b512.tar.bz2 |
Move constructors out-of-line and flesh out their documentation. No
functionality changed. This is in preparation for some refactoring of
how this class behaves.
llvm-svn: 150941
-rw-r--r-- | llvm/include/llvm/ADT/Triple.h | 13 | ||||
-rw-r--r-- | llvm/lib/Support/Triple.cpp | 34 |
2 files changed, 36 insertions, 11 deletions
diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index f5f96a2..a4b496e 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -136,18 +136,13 @@ public: /// @name Constructors /// @{ + /// \brief Default constructor produces an empty, invalid triple. Triple() : Data(), Arch(InvalidArch) {} - explicit Triple(const Twine &Str) : Data(Str.str()), Arch(InvalidArch) {} - Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr) - : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()), - Arch(InvalidArch) { - } + explicit Triple(const Twine &Str); + Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr); Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr, - const Twine &EnvironmentStr) - : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') + - EnvironmentStr).str()), Arch(InvalidArch) { - } + const Twine &EnvironmentStr); /// @} /// @name Normalization diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 9621dd3..24ead35 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -215,8 +215,6 @@ const char *Triple::getArchNameForAssembler() { .Default(NULL); } -// - Triple::ArchType Triple::ParseArch(StringRef ArchName) { return StringSwitch<ArchType>(ArchName) .Cases("i386", "i486", "i586", "i686", x86) @@ -304,6 +302,38 @@ void Triple::Parse() const { assert(isInitialized() && "Failed to initialize!"); } +/// \brief Construct a triple from the string representation provided. +/// +/// This doesn't actually parse the string representation eagerly. Instead it +/// stores it, and tracks the fact that it hasn't been parsed. The first time +/// any of the structural queries are made, the string is parsed and the +/// results cached in various members. +Triple::Triple(const Twine &Str) : Data(Str.str()), Arch(InvalidArch) {} + +/// \brief Construct a triple from string representations of the architecture, +/// vendor, and OS. +/// +/// This doesn't actually use these already distinct strings to setup the +/// triple information. Instead it joins them into a canonical form of a triple +/// string, and lazily parses it on use. +Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr) + : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr).str()), + Arch(InvalidArch) { +} + +/// \brief Construct a triple from string representations of the architecture, +/// vendor, OS, and environment. +/// +/// This doesn't actually use these already distinct strings to setup the +/// triple information. Instead it joins them into a canonical form of a triple +/// string, and lazily parses it on use. +Triple::Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr, + const Twine &EnvironmentStr) + : Data((ArchStr + Twine('-') + VendorStr + Twine('-') + OSStr + Twine('-') + + EnvironmentStr).str()), + Arch(InvalidArch) { +} + std::string Triple::normalize(StringRef Str) { // Parse into components. SmallVector<StringRef, 4> Components; |