--- include/llvm/IR/ValueMap.h +++ include/llvm/IR/ValueMap.h @@ -99,7 +99,7 @@ public: explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64) : Map(NumInitBuckets), Data(Data) {} - bool hasMD() const { return MDMap; } + bool hasMD() const { return static_cast(MDMap); } MDMapT &MD() { if (!MDMap) MDMap.reset(new MDMapT); Backport from https://reviews.llvm.org/rC330696 to include the detection of GCC versions without second and third component in path, such as "/usr/lib/gcc/x86_64-redhat-linux/8/". Support for single digit versions was introduced with https://reviews.llvm.org/D14727 --- tools/clang/lib/Driver/ToolChains.cpp +++ tools/clang/lib/Driver/ToolChains.cpp @@ -1241,20 +1241,31 @@ Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) { if (First.first.getAsInteger(10, GoodVersion.Major) || GoodVersion.Major < 0) return BadVersion; GoodVersion.MajorStr = First.first.str(); - if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0) + if (First.second.empty()) + return GoodVersion; + StringRef MinorStr = Second.first; + if (Second.second.empty()) { + if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) { + GoodVersion.PatchSuffix = MinorStr.substr(EndNumber); + MinorStr = MinorStr.slice(0, EndNumber); + } + } + if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0) return BadVersion; - GoodVersion.MinorStr = Second.first.str(); + GoodVersion.MinorStr = MinorStr.str(); // First look for a number prefix and parse that if present. Otherwise just // stash the entire patch string in the suffix, and leave the number // unspecified. This covers versions strings such as: + // 5 (handled above) // 4.4 + // 4.4-patched // 4.4.0 // 4.4.x // 4.4.2-rc4 // 4.4.x-patched // And retains any patch number it finds. - StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str(); + StringRef PatchText = Second.second.str(); if (!PatchText.empty()) { if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) { // Try to parse the number and any suffix.