[clang] [clang][CodeGen] Don't crash on sizeless output. (PR #99849)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 22 21:13:54 PDT 2024
================
@@ -2751,7 +2751,10 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
if (RequiresCast) {
unsigned Size = getContext().getTypeSize(QTy);
- Ty = llvm::IntegerType::get(getLLVMContext(), Size);
+ if (Size)
+ Ty = llvm::IntegerType::get(getLLVMContext(), Size);
+ else
+ CGM.Error(S.getAsmLoc(), "Output operand is sizeless!");
----------------
efriedma-quic wrote:
Can we use the SourceLocation of the specific operand in question, instead of using `S.getAsmLoc()`, which points at the beginning of the asm statement?
Diagnostics aren't capitalized, and don't end in punctuation.
Maybe say "size zero" instead of "sizeless".
https://github.com/llvm/llvm-project/pull/99849
More information about the cfe-commits
mailing list