[ms-inline asm] Add constraints to MSAsmStmt. We don't currently compute
the constraints, so in the interim we speculatively assume a 'r' constraint.
This is expected to work for most cases on x86.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162784 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 8462265..ac432e8 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -630,14 +630,6 @@
return cast<Expr>(Exprs[i]);
}
-/// getOutputConstraint - Return the constraint string for the specified
-/// output operand. All output constraints are known to be non-empty (either
-/// '=' or '+').
-StringRef MSAsmStmt::getOutputConstraint(unsigned i) const {
- // FIXME: Compute constraints.
- return StringRef();
-}
-
Expr *MSAsmStmt::getInputExpr(unsigned i) {
return cast<Expr>(Exprs[i + NumOutputs]);
}
@@ -645,13 +637,6 @@
Exprs[i + NumOutputs] = E;
}
-/// getInputConstraint - Return the specified input constraint. Unlike output
-/// constraints, these can be empty.
-StringRef MSAsmStmt::getInputConstraint(unsigned i) const {
- // FIXME: Compute constraints.
- return StringRef();
-}
-
QualType CXXCatchStmt::getCaughtType() const {
if (ExceptionDecl)
return ExceptionDecl->getType();
@@ -691,8 +676,8 @@
ArrayRef<Token> asmtoks, ArrayRef<IdentifierInfo*> inputs,
ArrayRef<IdentifierInfo*> outputs,
ArrayRef<Expr*> inputexprs, ArrayRef<Expr*> outputexprs,
- StringRef asmstr, ArrayRef<StringRef> clobbers,
- SourceLocation endloc)
+ StringRef asmstr, ArrayRef<StringRef> constraints,
+ ArrayRef<StringRef> clobbers, SourceLocation endloc)
: AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, outputs.size(), inputs.size(),
clobbers.size()), LBraceLoc(lbraceloc), EndLoc(endloc),
AsmStr(asmstr.str()), NumAsmToks(asmtoks.size()) {
@@ -717,6 +702,14 @@
for (unsigned i = 0, e = NumAsmToks; i != e; ++i)
AsmToks[i] = asmtoks[i];
+ Constraints = new (C) StringRef[NumExprs];
+ for (unsigned i = 0, e = NumExprs; i != e; ++i) {
+ size_t size = constraints[i].size();
+ char *dest = new (C) char[size];
+ std::strncpy(dest, constraints[i].data(), size);
+ Constraints[i] = StringRef(dest, size);
+ }
+
Clobbers = new (C) StringRef[NumClobbers];
for (unsigned i = 0, e = NumClobbers; i != e; ++i) {
// FIXME: Avoid the allocation/copy if at all possible.