[llvm] [NVPTX][NFC] Use preferred LLVM coding style in NVPTX backend (PR #190572)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 15:08:36 PDT 2026


================
@@ -284,7 +284,7 @@ void NVPTXInstPrinter::printAtomicCode(const MCInst *MI, int OpNum,
                                        const MCSubtargetInfo &STI,
                                        raw_ostream &O, StringRef Modifier) {
   const MCOperand &MO = MI->getOperand(OpNum);
-  int Imm = (int)MO.getImm();
+  int Imm = static_cast<int>(MO.getImm());
----------------
Artem-B wrote:

Nit: Style guide explicitly allows C-style casts for integer types https://llvm.org/docs/CodingStandards.html#prefer-c-style-casts:

- When casting between integral types (including enums that are not strongly- typed), functional-style casts are permitted as an alternative to `static_cast`.

I do not think static_cast buys us anything here. If we want to clean this up, then use the correct type, or auto.

https://github.com/llvm/llvm-project/pull/190572


More information about the llvm-commits mailing list