aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-01-17 23:36:15 +0000
committerAnders Carlsson <andersca@mac.com>2009-01-17 23:36:15 +0000
commit45b050e72d058131e6f169fe54888bb91a003fb5 (patch)
tree8e509aa4ab8c4c90efb3af384bfe792711042a3c
parent573acde1db5cb3e216e3d63fee173230834093d8 (diff)
Change TargetInfo::validateInputConstraint to take begin/end name iterators instead of the number of outputs. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62433 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Stmt.h10
-rw-r--r--include/clang/Basic/TargetInfo.h6
-rw-r--r--lib/Basic/TargetInfo.cpp6
-rw-r--r--lib/CodeGen/CGStmt.cpp4
-rw-r--r--lib/Sema/SemaStmt.cpp3
5 files changed, 23 insertions, 6 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index a8eed16a6b..c46ae775c8 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -944,6 +944,16 @@ public:
const_outputs_iterator begin_outputs() const { return &Exprs[0]; }
const_outputs_iterator end_outputs() const { return &Exprs[0] + NumOutputs; }
+ // Input name iterator.
+
+ const std::string *begin_output_names() const {
+ return &Names[0];
+ }
+
+ const std::string *end_output_names() const {
+ return &Names[0] + NumOutputs;
+ }
+
// Child iterators
virtual child_iterator child_begin();
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index a9a71367bc..ce7f7daeb9 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -198,8 +198,10 @@ public:
// a constraint is valid and provides information about it.
// FIXME: These should return a real error instead of just true/false.
bool validateOutputConstraint(const char *Name, ConstraintInfo &Info) const;
- bool validateInputConstraint (const char *Name, unsigned NumOutputs,
- ConstraintInfo &info) const;
+ bool validateInputConstraint(const char *Name,
+ const std::string *OutputNamesBegin,
+ const std::string *OutputNamesEnd,
+ ConstraintInfo &info) const;
virtual std::string convertConstraint(const char Constraint) const {
return std::string(1, Constraint);
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
index 05004b7305..89bc8b4c8f 100644
--- a/lib/Basic/TargetInfo.cpp
+++ b/lib/Basic/TargetInfo.cpp
@@ -188,7 +188,8 @@ bool TargetInfo::validateOutputConstraint(const char *Name,
}
bool TargetInfo::validateInputConstraint(const char *Name,
- unsigned NumOutputs,
+ const std::string *OutputNamesBegin,
+ const std::string *OutputNamesEnd,
ConstraintInfo &info) const {
info = CI_None;
@@ -197,8 +198,9 @@ bool TargetInfo::validateInputConstraint(const char *Name,
default:
// Check if we have a matching constraint
if (*Name >= '0' && *Name <= '9') {
+ unsigned NumOutputs = OutputNamesEnd - OutputNamesBegin;
unsigned i = *Name - '0';
-
+
// Check if matching constraint is out of bounds.
if (i >= NumOutputs)
return false;
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index edccbe41bf..d86c3f4389 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -977,7 +977,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
TargetInfo::ConstraintInfo Info;
bool result = Target.validateInputConstraint(InputConstraint.c_str(),
- NumConstraints, Info);
+ S.begin_output_names(),
+ S.end_output_names(),
+ Info);
assert(result && "Failed to parse input constraint"); result=result;
if (i != 0 || S.getNumOutputs() > 0)
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 7a41f4d976..cb467d41d8 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -897,7 +897,8 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
TargetInfo::ConstraintInfo info;
if (!Context.Target.validateInputConstraint(InputConstraint.c_str(),
- NumOutputs, info)) {
+ &Names[0],
+ &Names[0] + NumOutputs, info)) {
// FIXME: We currently leak memory here.
return Diag(Literal->getLocStart(),
diag::err_asm_invalid_input_constraint) << InputConstraint;