When building the IR from an existing AST, my AST has some string values (at compile-time they are built from std::string
) and I want to set them safely as llvm::Value
to use as a part of an expression.
In this case, I don't need to bind the string at run-time, because string values are only meant to resolve stuff as variables, functions or classes at compile-time (the language doesn't support a native string type).
Whats the best way to keep my string content as llvm::Value
and still be able to retrieve it at later stages of compilation (when the nesting expressions are built)?
More concretely, if I set the llvm::Value
with:
llvm::Value* v = llvm::ConstantArray::get(llvmContext, myString.c_str());
How do I safely retrieve the string value? Is llvm::ConstantArray
the appropriate way to wrap strings?