[llvm-dev] [BUG] Incorrect ASCII escape characters on Mac

Ramkumar Ramachandra artagnon at gmail.com
Wed Aug 5 13:49:40 PDT 2015


Thanks. Whose fault is it exactly though? I can reproduce the issue
with this construction code:

    IRBuilder<> builder(getGlobalContext());
    auto M = new llvm::Module("main", getGlobalContext());
    std::vector<Type *> ATyAr;
    auto i8Ty = builder.getInt8Ty();
    auto i8ArTy = ArrayType::get(builder.getInt8Ty(), 10);
    auto pi8ArTy = PointerType::get(i8ArTy, 0);
    auto FTy = FunctionType::get(i8ArTy, ATyAr, false);
    auto Fcn = cast<Function>(M->getOrInsertFunction("testFcn", FTy));
    auto BB = BasicBlock::Create(builder.getContext(), "entry", Fcn);
    builder.SetInsertPoint(BB);
    std::vector<int> rawData = { 34 , -48 , 18 , -12 , 33 , 0 , 21 ,
-7 , -20 , -31 };
    std::vector<Constant *> coercedData;
    for (auto el : rawData) {
        coercedData.push_back(ConstantInt::get(i8Ty, el, 10));
    }
    auto V = ConstantArray::get(i8ArTy, ArrayRef<Constant *>(coercedData));
    builder.CreateRet(V);

    std::string scratchspace;
    raw_string_ostream scratch(scratchspace);
    auto aaw = new AssemblyAnnotationWriter;
    M->print(scratch, aaw);

It prints fine on Linux, but prints those weird characters on Mac.

Is just the pretty-printer broken?

Thanks.

Ram


More information about the llvm-dev mailing list