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

Patch by Zoltan Gera!

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

llvm-svn: 297627
This commit is contained in:
Gabor Horvath 2017-03-13 15:32:24 +00:00
parent 083b727da9
commit 27f5ff66cc
3 changed files with 17 additions and 2 deletions

View 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);
}

View 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;
}

View File

@ -4,4 +4,5 @@
void testAsmImport() {
asmFunc(12, 42);
asmFunc2(42);
}