]> granicus.if.org Git - clang/commitdiff
[ms-inline asm] Add a very simple test case. Basically, we're only testing for
authorChad Rosier <mcrosier@apple.com>
Wed, 8 Aug 2012 20:37:31 +0000 (20:37 +0000)
committerChad Rosier <mcrosier@apple.com>
Wed, 8 Aug 2012 20:37:31 +0000 (20:37 +0000)
crashers at the moment (and coincidentally this case was causing a crash).

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

lib/Sema/SemaStmt.cpp
test/CodeGen/ms-inline-asm.c [new file with mode: 0644]

index a8a06a93fcfbaad7e8d57a51701d2954e8d234c4..be905781637dade2e63ab77345e177359629f02a 100644 (file)
@@ -2786,6 +2786,9 @@ static std::string PatchMSAsmString(Sema &SemaRef, bool &IsSimple,
                                     SourceLocation AsmLoc,
                                     ArrayRef<Token> AsmToks,
                                     const TargetInfo &TI) {
+  if (!AsmToks.size())
+    return "";
+
   std::string Res;
   IdentifierInfo *II = AsmToks[0].getIdentifierInfo();
   Res = II->getName().str();
@@ -2841,6 +2844,9 @@ static std::string PatchMSAsmString(Sema &SemaRef, bool &IsSimple,
 static std::string buildMSAsmString(Sema &SemaRef,
                                     ArrayRef<Token> AsmToks,
                                     ArrayRef<unsigned> LineEnds) {
+  if (!AsmToks.size())
+    return "";
+
   // Collect the tokens into a string
   SmallString<512> Asm;
   SmallString<512> TokenBuf;
diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c
new file mode 100644 (file)
index 0000000..2d36bbc
--- /dev/null
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fms-extensions -w -emit-llvm -o - | FileCheck %s
+
+void t1() {
+// CHECK: @t1
+// CHECK: ret void
+  __asm {}
+}