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

Zoltán Gera via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 05:31:50 PDT 2017


gerazo updated this revision to Diff 91541.
gerazo added a comment.

Better check not letting a real import problem passing through


https://reviews.llvm.org/D30831

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


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


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


More information about the cfe-commits mailing list