[llvm] Fix gcc 7.5 incompatibility in GlobPattern.cpp (PR #66155)

Steven Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 16:09:29 PDT 2023


https://github.com/steven-johnson created https://github.com/llvm/llvm-project/pull/66155:

rG8daace8b2d89 injected a build break in an older-but-still-supported version of gcc (at least, I think it's supported): `arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0`, in which we get failures on lines 62 and 132 of the form

`GlobPattern.cpp: In function ‘llvm::Expected<llvm::SmallVector<std::__cxx11::basic_string<char>, 1> > parseBraceExpansions(llvm::StringRef, std::optional<unsigned int>)’:
GlobPattern.cpp:62:12: error: could not convert ‘SubPatterns’ from ‘llvm::SmallVector<std::__cxx11::basic_string<char> >’ to ‘llvm::Expected<llvm::SmallVector<std::__cxx11::basic_string<char>, 1> >’`

In both cases, replacing the `return SubPatterns;` with `return std::move(SubPatterns);` heals the misbehavior.

(Yes, gcc7.5 is probably getting a bit long in the tooth here, and we're looking to upgrade; unfortunately, we are temporarily hamstrung by some ancient build infrastructure that is essentially incapable of being easily upgraded to newer builds, and it will take us a little time to figure out good replacements, unfortunately.)

>From 919d81fd68e2461011ba17bb21c3c90138cad1e0 Mon Sep 17 00:00:00 2001
From: Steven Johnson <srj at google.com>
Date: Tue, 12 Sep 2023 16:08:57 -0700
Subject: [PATCH] Fix gcc 7.5 incompatibility in GlobPattern.cpp
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

rG8daace8b2d89 injected a build break in an older-but-still-supported version of gcc (at least, I think it's supported): `arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0`, in which we get failures on lines 62 and 132 of the form

`GlobPattern.cpp: In function ‘llvm::Expected<llvm::SmallVector<std::__cxx11::basic_string<char>, 1> > parseBraceExpansions(llvm::StringRef, std::optional<unsigned int>)’:
GlobPattern.cpp:62:12: error: could not convert ‘SubPatterns’ from ‘llvm::SmallVector<std::__cxx11::basic_string<char> >’ to ‘llvm::Expected<llvm::SmallVector<std::__cxx11::basic_string<char>, 1> >’`

In both cases, replacing the `return SubPatterns;` with `return std::move(SubPatterns);` heals the misbehavior.

(Yes, gcc7.5 is probably getting a bit long in the tooth here, and we're looking to upgrade; unfortunately, we are temporarily hamstrung by some ancient build infrastructure that is essentially incapable of being easily upgraded to newer builds, and it will take us a little time to figure out good replacements, unfortunately.)
---
 llvm/lib/Support/GlobPattern.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Support/GlobPattern.cpp b/llvm/lib/Support/GlobPattern.cpp
index 9813ed2d7a14252..7004adf461a0cc6 100644
--- a/llvm/lib/Support/GlobPattern.cpp
+++ b/llvm/lib/Support/GlobPattern.cpp
@@ -59,7 +59,7 @@ static Expected<SmallVector<std::string, 1>>
 parseBraceExpansions(StringRef S, std::optional<size_t> MaxSubPatterns) {
   SmallVector<std::string> SubPatterns = {S.str()};
   if (!MaxSubPatterns || !S.contains('{'))
-    return SubPatterns;
+    return std::move(SubPatterns);
 
   struct BraceExpansion {
     size_t Start;
@@ -129,7 +129,7 @@ parseBraceExpansions(StringRef S, std::optional<size_t> MaxSubPatterns) {
       for (StringRef Orig : OrigSubPatterns)
         SubPatterns.emplace_back(Orig).replace(BE.Start, BE.Length, Term);
   }
-  return SubPatterns;
+  return std::move(SubPatterns);
 }
 
 Expected<GlobPattern>



More information about the llvm-commits mailing list