[llvm] [TableGen] Fix operand constraint checking problem. (PR #85859)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 10:10:50 PDT 2024


================
@@ -325,7 +325,8 @@ static void ParseConstraint(StringRef CStr, CGIOperandList &Ops, Record *Rec) {
 
   // Only other constraint is "TIED_TO" for now.
   StringRef::size_type pos = CStr.find_first_of('=');
-  if (pos == StringRef::npos)
+  if (pos == StringRef::npos || CStr.find_first_of(" \t", pos) != (pos + 1) ||
+      CStr.find_last_of(" \t", pos) != (pos - 1))
----------------
topperc wrote:

The wrapping of `pos - 1` to alias with `StringRef::npos` feels weird to me. Should we add `pos == 0` as one of the conditions in this if?

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


More information about the llvm-commits mailing list