Fix bad length argument to substr calls. Apparently I'm the first one to
authorBob Wilson <bob.wilson@apple.com>
Wed, 26 Aug 2009 22:50:39 +0000 (22:50 +0000)
committerBob Wilson <bob.wilson@apple.com>
Wed, 26 Aug 2009 22:50:39 +0000 (22:50 +0000)
attempt more than 2 constraints on an instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80169 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/CodeGenInstruction.cpp

index 4650b88fd5174f676f6e15c6aba419f9e11452e7..b7968a0e9cd73b6f5ed2874204257dd16d2945df 100644 (file)
@@ -22,7 +22,7 @@ static void ParseConstraint(const std::string &CStr, CodeGenInstruction *I) {
   std::string::size_type pos = CStr.find_first_of('=');
   assert(pos != std::string::npos && "Unrecognized constraint");
   std::string::size_type start = CStr.find_first_not_of(" \t");
-  std::string Name = CStr.substr(start, pos);
+  std::string Name = CStr.substr(start, pos - start);
   
   // TIED_TO: $src1 = $dst
   std::string::size_type wpos = Name.find_first_of(" \t");
@@ -70,7 +70,7 @@ static void ParseConstraints(const std::string &CStr, CodeGenInstruction *I) {
     if (eidx == std::string::npos)
       eidx = CStr.length();
     
-    ParseConstraint(CStr.substr(bidx, eidx), I);
+    ParseConstraint(CStr.substr(bidx, eidx - bidx), I);
     bidx = CStr.find_first_not_of(delims, eidx);
   }
 }