[PATCH] MS inline asm: Allow __asm blocks to set a return value

Reid Kleckner rnk at google.com
Thu Sep 4 11:32:01 PDT 2014


Thanks! It sounds like this rewrite step is still our best idea for handling this. I'm going to land this then.

================
Comment at: lib/CodeGen/TargetInfo.cpp:645
@@ +644,3 @@
+      size_t DigitStart = Pos;
+      size_t DigitEnd = AsmString.find_first_not_of("0123456789", DigitStart);
+      if (DigitEnd == std::string::npos)
----------------
majnemer wrote:
> If the character at DigitStart is not a number, DigitStart == DigitEnd.
That should be OK, getAsInteger will return an error.

================
Comment at: lib/CodeGen/TargetInfo.cpp:657
@@ +656,3 @@
+      }
+      Pos = DigitEnd;
+    }
----------------
majnemer wrote:
> If DigitStart == DigitEnd, wouldn't Pos be unchanged at this point? I guess that would be handled by the next iteration of the loop.
We should be fine. getAsInteger should fail, so we hit the else clause, stream an empty string, and continue the next iteration looking for dollars. That said, this would already be a malformed inline asm string, which Sema shouldn't produce.

Of course, you never know with stringly typed data structures. :)

http://reviews.llvm.org/D5177






More information about the cfe-commits mailing list