[PATCH] D30831: [ASTImporter] Import fix of GCCAsmStmts w/ missing symbolic operands

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 08:44:37 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL297627: [ASTImporter] Import fix of GCCAsmStmts w/ missing symbolic operands (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D30831?vs=91541&id=91567#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30831

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/test/ASTMerge/asm/Inputs/asm-function.cpp
  cfe/trunk/test/ASTMerge/asm/test.cpp


Index: cfe/trunk/lib/AST/ASTImporter.cpp
===================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -5218,13 +5218,17 @@
   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: cfe/trunk/test/ASTMerge/asm/test.cpp
===================================================================
--- cfe/trunk/test/ASTMerge/asm/test.cpp
+++ cfe/trunk/test/ASTMerge/asm/test.cpp
@@ -4,4 +4,5 @@
 
 void testAsmImport() {
   asmFunc(12, 42);
+  asmFunc2(42);
 }
Index: cfe/trunk/test/ASTMerge/asm/Inputs/asm-function.cpp
===================================================================
--- cfe/trunk/test/ASTMerge/asm/Inputs/asm-function.cpp
+++ cfe/trunk/test/ASTMerge/asm/Inputs/asm-function.cpp
@@ -9,3 +9,13 @@
   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;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30831.91567.patch
Type: text/x-patch
Size: 1711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170313/6f51db20/attachment.bin>


More information about the cfe-commits mailing list