diff options
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenExpr.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index fa68ad9..b4c8924 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -1108,8 +1108,9 @@ CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) { return lv; } -LValue CIRGenFunction::emitStringLiteralLValue(const StringLiteral *e) { - cir::GlobalOp globalOp = cgm.getGlobalForStringLiteral(e); +LValue CIRGenFunction::emitStringLiteralLValue(const StringLiteral *e, + llvm::StringRef name) { + cir::GlobalOp globalOp = cgm.getGlobalForStringLiteral(e, name); assert(globalOp.getAlignment() && "expected alignment for string literal"); unsigned align = *(globalOp.getAlignment()); mlir::Value addr = @@ -2372,6 +2373,21 @@ mlir::Value CIRGenFunction::emitScalarConstant( return builder.getConstant(getLoc(e->getSourceRange()), constant.getValue()); } +LValue CIRGenFunction::emitPredefinedLValue(const PredefinedExpr *e) { + const StringLiteral *sl = e->getFunctionName(); + assert(sl != nullptr && "No StringLiteral name in PredefinedExpr"); + auto fn = cast<cir::FuncOp>(curFn); + StringRef fnName = fn.getName(); + fnName.consume_front("\01"); + std::array<StringRef, 2> nameItems = { + PredefinedExpr::getIdentKindName(e->getIdentKind()), fnName}; + std::string gvName = llvm::join(nameItems, "."); + if (isa_and_nonnull<BlockDecl>(curCodeDecl)) + cgm.errorNYI(e->getSourceRange(), "predefined lvalue in block"); + + return emitStringLiteralLValue(sl, gvName); +} + /// An LValue is a candidate for having its loads and stores be made atomic if /// we are operating under /volatile:ms *and* the LValue itself is volatile and /// performing such an operation can be performed without a libcall. |