File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
lib/CIR/Lowering/DirectToLLVM Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2283,7 +2283,10 @@ class CIRGlobalOpLowering
22832283 if (auto constArr =
22842284 mlir::dyn_cast<mlir::cir::ConstArrayAttr>(init.value ())) {
22852285 if (auto attr = mlir::dyn_cast<mlir::StringAttr>(constArr.getElts ())) {
2286- init = rewriter.getStringAttr (attr.getValue ());
2286+ llvm::SmallString<256 > literal (attr.getValue ());
2287+ if (constArr.getTrailingZerosNum ())
2288+ literal.append (constArr.getTrailingZerosNum (), ' \0 ' );
2289+ init = rewriter.getStringAttr (literal);
22872290 } else if (auto attr =
22882291 mlir::dyn_cast<mlir::ArrayAttr>(constArr.getElts ())) {
22892292 // Failed to use a compact attribute as an initializer:
Original file line number Diff line number Diff line change 1+ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll
2+ // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
3+
4+ void f (char * fmt , ...);
5+ void test () {
6+ f ("test\0" );
7+ }
8+
9+ // LLVM: @.str = {{.*}}[6 x i8] c"test\00\00"
You can’t perform that action at this time.
0 commit comments