<div class="gmail_quote"><div>I hope this is the right place to ask this question.  If not, please let me know where I can ask for help.</div><div><br></div><div>We are using Kaleidoscope as the base framework to write a source to source compiler.  Our source language has Strings with supported operations such as concatenation, upper case, and substrings.</div>

<div><br></div><div>I am following the patterns set forth in Kaleidoscope, and need to represent my std::string as a Value *.</div><div><br></div><div>I have:</div><div><br></div><div><div>Value *StringExprAST::Codegen() {</div>

<div>  StringRef r(Val);  // Val is a std::string captured by the parser</div><div>  return ConstantDataArray::getString(getGlobalContext(), r);</div><div>}</div></div><div><br></div><div>For a test string of "Hello World!", I am trying to create an Alloca * and store the InitVal, which I get from codegen of StringExprAST.</div>

<div><br></div><div><div>uint64_t v(13); </div><div>APInt d(8, v); </div><div>Value * ArraySize = ConstantInt::get(getGlobalContext(), d); </div><div>Alloca = CreateEntryBlockAllocaString(TheFunction, VarName, ArraySize); </div>

<div>Builder.CreateStore(InitVal, Alloca);</div></div><div><br></div><div>I get the following error:</div><div><div>tok_string: "Hello World!"</div><div>Assertion failed: (getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"), function AssertOK, file /Users/rcatlin1/lldb/llvm/lib/IR/Instructions.cpp, line 1089.</div>

</div><div><br></div><div>Thanks for any guidance.</div><div><br></div><div>Regards,</div>
<div>Richard Catlin</div>
</div><br>