[llvm] [NFC][Offload] Fix possible edge cases in offload-tblgen (PR #146511)

Callum Fare via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 05:54:58 PDT 2025


================
@@ -157,9 +157,14 @@ class ParamRec {
   bool isHandleType() const { return getType().ends_with("_handle_t"); }
   bool isFptrType() const { return getType().ends_with("_cb_t"); }
   StringRef getDesc() const { return rec->getValueAsString("desc"); }
-  bool isIn() const { return dyn_cast<BitInit>(flags->getBit(0))->getValue(); }
-  bool isOut() const { return dyn_cast<BitInit>(flags->getBit(1))->getValue(); }
-  bool isOpt() const { return dyn_cast<BitInit>(flags->getBit(2))->getValue(); }
+  bool getFlagBit(unsigned int Bit) const {
+    if (auto *BitValue = dyn_cast<BitInit>(flags->getBit(Bit)))
+      return BitValue->getValue();
+    return false;
----------------
callumfare wrote:

The flags field always has a default value of 0 set (in APIDefs.td), I've added an assert since if that goes missing then something weird has happened

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


More information about the llvm-commits mailing list