From: Chandler Carruth Date: Sun, 6 Nov 2011 10:51:30 +0000 (+0000) Subject: The version objects need to actually store the version strings; they X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7902d766dea6366b84bf65c671f1cbd7b31b9388;p=clang The version objects need to actually store the version strings; they aren't guaranteed to live long enough otherwise. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143875 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index ec6aea7926..159d2afcd0 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1523,11 +1523,11 @@ static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) { /// /// This is the primary means of forming GCCVersion objects. /*static*/ Linux::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) { - const GCCVersion BadVersion = { VersionText, -1, -1, -1, "" }; + const GCCVersion BadVersion = { VersionText.str(), -1, -1, -1, "" }; std::pair First = VersionText.split('.'); std::pair Second = First.second.split('.'); - GCCVersion GoodVersion = { VersionText, -1, -1, -1, "" }; + GCCVersion GoodVersion = { VersionText.str(), -1, -1, -1, "" }; if (First.first.getAsInteger(10, GoodVersion.Major) || GoodVersion.Major < 0) return BadVersion; @@ -1544,14 +1544,14 @@ static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) { // 4.4.2-rc4 // 4.4.x-patched // And retains any patch number it finds. - StringRef PatchText = GoodVersion.PatchSuffix = Second.second; + StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str(); if (!PatchText.empty()) { if (unsigned EndNumber = PatchText.find_first_not_of("0123456789")) { // Try to parse the number and any suffix. if (PatchText.slice(0, EndNumber).getAsInteger(10, GoodVersion.Patch) || GoodVersion.Patch < 0) return BadVersion; - GoodVersion.PatchSuffix = PatchText.substr(EndNumber); + GoodVersion.PatchSuffix = PatchText.substr(EndNumber).str(); } } diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 7599cd6b45..31c97d6e45 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -389,13 +389,13 @@ class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF { /// becomes necessary, it can be added. struct GCCVersion { /// \brief The unparsed text of the version. - StringRef Text; + std::string Text; /// \brief The parsed major, minor, and patch numbers. int Major, Minor, Patch; /// \brief Any textual suffix on the patch number. - StringRef PatchSuffix; + std::string PatchSuffix; static GCCVersion Parse(StringRef VersionText); bool operator<(const GCCVersion &RHS) const;