[llvm] r213994 - IR/UseTest.cpp: Avoid std::to_string() to appease mingw32 bot.

Yaron Keren yaron.keren at gmail.com
Mon Aug 4 01:12:53 PDT 2014


+Aaron, Galina

Galina and Aaron were looking into to_string two weeks ago. The problem
reappears every month or so as to_string is standard and useful C++11. We
should be able to use it.

to_string may not be supported under older MingW from mingw.org, see

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015

but is supported under MinGW-w64 distribution (32 bit or 64 bit), with
4.8.2 this compiles and runs with -std=c++11 :

 #include <iostream>
 #include <string>
 using namespace std;
 int main() {
   cout << to_string(1234) << std::endl;
 }

Yaron




2014-08-04 1:11 GMT+03:00 NAKAMURA Takumi <geek4civic at gmail.com>:

> See also
> http://lab.llvm.org:8011/builders/clang-native-mingw32-win7/builds/7040
>
> I am not sure whether to avoid std::to_string() or drop away incomplete
> hosts.
> In fact in Cygwin's libstdc++-4.8.2, std::to_string is conditionalized,
>
> #if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
>      && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
>
> Cygwin's c++config.h doesn't provide _GLIBCXX_USE_C99. I don't know
> how it would be in mingw32 builder.
>
> 2014-08-04 4:30 GMT+09:00 Duncan P. N. Exon Smith <dexonsmith at apple.com>:
> >
> >> On 2014 Jul 25, at 17:45, NAKAMURA Takumi <geek4civic at gmail.com> wrote:
> >>
> >> Author: chapuni
> >> Date: Fri Jul 25 19:45:30 2014
> >> New Revision: 213994
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=213994&view=rev
> >> Log:
> >> IR/UseTest.cpp: Avoid std::to_string() to appease mingw32 bot.
> >>
> >> Modified:
> >>    llvm/trunk/unittests/IR/UseTest.cpp
> >>
> >
> > Thanks for this, I didn't see any bot failure emails.
> >
> > Is `std::to_string()` totally unsupported?  Let me know and I'll
> > add it to the list [1].
> >
> > [1]:
> http://llvm.org/docs/CodingStandards.html#supported-c-11-language-and-library-features
> >
> >> Modified: llvm/trunk/unittests/IR/UseTest.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/UseTest.cpp?rev=213994&r1=213993&r2=213994&view=diff
> >>
> ==============================================================================
> >> --- llvm/trunk/unittests/IR/UseTest.cpp (original)
> >> +++ llvm/trunk/unittests/IR/UseTest.cpp Fri Jul 25 19:45:30 2014
> >> @@ -13,9 +13,9 @@
> >> #include "llvm/IR/Module.h"
> >> #include "llvm/IR/User.h"
> >> #include "llvm/IR/Instructions.h"
> >> +#include "llvm/Support/Format.h"
> >> #include "llvm/Support/SourceMgr.h"
> >> #include "gtest/gtest.h"
> >> -#include <string>
> >>
> >> using namespace llvm;
> >>
> >> @@ -37,6 +37,7 @@ TEST(UseTest, sort) {
> >>                              "  ret void\n"
> >>                              "}\n";
> >>   SMDiagnostic Err;
> >> +  char vnbuf[8];
> >>   Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C);
> >>   Function *F = M->getFunction("f");
> >>   ASSERT_TRUE(F);
> >> @@ -48,16 +49,20 @@ TEST(UseTest, sort) {
> >>     return L.getUser()->getName() < R.getUser()->getName();
> >>   });
> >>   unsigned I = 0;
> >> -  for (User *U : X.users())
> >> -    EXPECT_EQ("v" + std::to_string(I++), U->getName());
> >> +  for (User *U : X.users()) {
> >> +    snprintf(vnbuf, sizeof(vnbuf), "v%u", I++);
> >> +    EXPECT_EQ(vnbuf, U->getName());
> >> +  }
> >>   ASSERT_EQ(8u, I);
> >>
> >>   X.sortUseList([](const Use &L, const Use &R) {
> >>     return L.getUser()->getName() > R.getUser()->getName();
> >>   });
> >>   I = 0;
> >> -  for (User *U : X.users())
> >> -    EXPECT_EQ("v" + std::to_string((7 - I++)), U->getName());
> >> +  for (User *U : X.users()) {
> >> +    snprintf(vnbuf, sizeof(vnbuf), "v%u", (7 - I++));
> >> +    EXPECT_EQ(vnbuf, U->getName());
> >> +  }
> >>   ASSERT_EQ(8u, I);
> >> }
> >>
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140804/437eb135/attachment.html>


More information about the llvm-commits mailing list