]> granicus.if.org Git - clang/commitdiff
[ASTImporter] Import fix of GCCAsmStmts w/ missing symbolic operands
authorGabor Horvath <xazax.hun@gmail.com>
Mon, 13 Mar 2017 15:32:24 +0000 (15:32 +0000)
committerGabor Horvath <xazax.hun@gmail.com>
Mon, 13 Mar 2017 15:32:24 +0000 (15:32 +0000)
Patch by Zoltan Gera!

Differential Revision: https://reviews.llvm.org/D30831

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

lib/AST/ASTImporter.cpp
test/ASTMerge/asm/Inputs/asm-function.cpp
test/ASTMerge/asm/test.cpp

index 525d82e22d60fdb80adb2b9cb453bfb15566f8d2..2a7768a4249ac5259231ee9c7e3011c1a231befc 100644 (file)
@@ -5218,13 +5218,17 @@ Stmt *ASTNodeImporter::VisitGCCAsmStmt(GCCAsmStmt *S) {
   SmallVector<IdentifierInfo *, 4> Names;
   for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
     IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(I));
-    if (!ToII)
+    // ToII is nullptr when no symbolic name is given for output operand
+    // see ParseStmtAsm::ParseAsmOperandsOpt
+    if (!ToII && S->getOutputIdentifier(I))
       return nullptr;
     Names.push_back(ToII);
   }
   for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
     IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(I));
-    if (!ToII)
+    // ToII is nullptr when no symbolic name is given for input operand
+    // see ParseStmtAsm::ParseAsmOperandsOpt
+    if (!ToII && S->getInputIdentifier(I))
       return nullptr;
     Names.push_back(ToII);
   }
index 59c4edfbcd251deffc7214cd18a716862423284c..1b8783354fcebd89db8646ac475547f8492d3447 100644 (file)
@@ -9,3 +9,13 @@ unsigned char asmFunc(unsigned char a, unsigned char b) {
   res = bigres;
   return res;
 }
+
+int asmFunc2(int i) {
+  int res;
+  asm ("mov %1, %0 \t\n"
+       "inc %0 "
+      : "=r" (res)
+      : "r" (i)
+      : "cc");
+  return res;
+}
index 3a0a205720fe1ebe22fd43c2f0fba9183b0f9ff3..8c3bdfe17b75b42e8ee659382271e8a66e7ebfa3 100644 (file)
@@ -4,4 +4,5 @@
 
 void testAsmImport() {
   asmFunc(12, 42);
+  asmFunc2(42);
 }