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 | cceb8f44a0ca3a9c57ab3a7f4947b2abda531cef (patch) | |
tree | df0581a29b4644511809100f9d9cc789c8e64561 /lib/Support | |
parent | 23ec5d7759ed9a3b52fc8c470695248a1719cce8 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Triple.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index 9621dd31f1..24ead35c20 100644 --- a/lib/Support/Triple.cpp +++ b/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; |