diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-02-21 03:39:36 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-02-21 03:39:36 +0000 |
commit | 124e51c0d2b521b0fb3aaaf2443403cd451b7857 (patch) | |
tree | e698a2f26a96b4e06e1c43c5161f782f97d933ec /include/llvm/ADT/Triple.h | |
parent | 4b04578d65e38cdb5077de2498889e4a174ccdfd (diff) | |
download | llvm-124e51c0d2b521b0fb3aaaf2443403cd451b7857.tar.gz llvm-124e51c0d2b521b0fb3aaaf2443403cd451b7857.tar.bz2 llvm-124e51c0d2b521b0fb3aaaf2443403cd451b7857.tar.xz |
Switch the llvm::Triple class to immediately parse the triple string on
construction. Simplify its interface, implementation, and users
accordingly as there is no longer an 'uninitialized' state to check for.
Also, fixes a bug lurking in the interface as there was one method that
didn't correctly check for initialization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151024 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/Triple.h')
-rw-r--r-- | include/llvm/ADT/Triple.h | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index a4b496e499..1266da96a1 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -64,9 +64,7 @@ public: ptx32, // PTX: ptx (32-bit) ptx64, // PTX: ptx (64-bit) le32, // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten) - amdil, // amdil: amd IL - - InvalidArch + amdil // amdil: amd IL }; enum VendorType { UnknownVendor, @@ -113,31 +111,29 @@ public: private: std::string Data; - /// The parsed arch type (or InvalidArch if uninitialized). - mutable ArchType Arch; + /// The parsed arch type. + ArchType Arch; /// The parsed vendor type. - mutable VendorType Vendor; + VendorType Vendor; /// The parsed OS type. - mutable OSType OS; + OSType OS; /// The parsed Environment type. - mutable EnvironmentType Environment; + EnvironmentType Environment; - bool isInitialized() const { return Arch != InvalidArch; } static ArchType ParseArch(StringRef ArchName); static VendorType ParseVendor(StringRef VendorName); static OSType ParseOS(StringRef OSName); static EnvironmentType ParseEnvironment(StringRef EnvironmentName); - void Parse() const; public: /// @name Constructors /// @{ /// \brief Default constructor produces an empty, invalid triple. - Triple() : Data(), Arch(InvalidArch) {} + Triple() : Data(), Arch(), Vendor(), OS(), Environment() {} explicit Triple(const Twine &Str); Triple(const Twine &ArchStr, const Twine &VendorStr, const Twine &OSStr); @@ -159,22 +155,13 @@ public: /// @{ /// getArch - Get the parsed architecture type of this triple. - ArchType getArch() const { - if (!isInitialized()) Parse(); - return Arch; - } + ArchType getArch() const { return Arch; } /// getVendor - Get the parsed vendor type of this triple. - VendorType getVendor() const { - if (!isInitialized()) Parse(); - return Vendor; - } + VendorType getVendor() const { return Vendor; } /// getOS - Get the parsed operating system type of this triple. - OSType getOS() const { - if (!isInitialized()) Parse(); - return OS; - } + OSType getOS() const { return OS; } /// hasEnvironment - Does this triple have the optional environment /// (fourth) component? @@ -183,10 +170,7 @@ public: } /// getEnvironment - Get the parsed environment type of this triple. - EnvironmentType getEnvironment() const { - if (!isInitialized()) Parse(); - return Environment; - } + EnvironmentType getEnvironment() const { return Environment; } /// getOSVersion - Parse the version number from the OS name component of the /// triple, if present. |