[llvm-commits] [llvm] r150941 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp
Chandler Carruth
chandlerc at gmail.com
Sun Feb 19 16:02:47 PST 2012
Author: chandlerc
Date: Sun Feb 19 18:02:47 2012
New Revision: 150941
URL: http://llvm.org/viewvc/llvm-project?rev=150941&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/lib/Support/Triple.cpp
Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=150941&r1=150940&r2=150941&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Sun Feb 19 18:02:47 2012
@@ -136,18 +136,13 @@
/// @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
Modified: llvm/trunk/lib/Support/Triple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=150941&r1=150940&r2=150941&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Triple.cpp (original)
+++ llvm/trunk/lib/Support/Triple.cpp Sun Feb 19 18:02:47 2012
@@ -215,8 +215,6 @@
.Default(NULL);
}
-//
-
Triple::ArchType Triple::ParseArch(StringRef ArchName) {
return StringSwitch<ArchType>(ArchName)
.Cases("i386", "i486", "i586", "i686", x86)
@@ -304,6 +302,38 @@
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;
More information about the llvm-commits
mailing list