[llvm] reland [InlineAsm] wrap ConstraintCode in enum class NFC (PR #66264)

Danila Malyutin via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 14 05:16:02 PDT 2023


================
@@ -375,11 +373,14 @@ class InlineAsm final : public Value {
       return true;
     }
 
-    // TODO: convert to enum?
-    unsigned getMemoryConstraintID() const {
+    ConstraintCode getMemoryConstraintID() const {
       assert((isMemKind() || isFuncKind()) &&
              "Not expected mem or function flag!");
-      return getData();
+      uint32_t D = getData();
+      assert(D <= static_cast<uint32_t>(ConstraintCode::Max) &&
+             D >= static_cast<uint32_t>(ConstraintCode::Unknown) &&
----------------
danilaml wrote:

Note that this triggers `type-limits` warning (if it's enabled) on GCC 7 and 8.
>error: comparison of unsigned expression >= 0 is always true

Don't know if there is a nice way to silence it and if we want to keep this check.

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


More information about the llvm-commits mailing list