From 66de081f39a478446608b8fad8a8463f09f97c25 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 30 Jan 2010 20:38:10 +0000 Subject: [PATCH] Even more AsmStmt cleanup. llvm-svn: 94921 --- clang/include/clang/AST/Stmt.h | 9 +++++---- clang/lib/AST/Stmt.cpp | 17 ++++++++--------- clang/lib/Frontend/PCHReaderStmt.cpp | 3 ++- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index cc87867f1f5b..c94fe1511618 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -1215,7 +1215,7 @@ public: /// getOutputConstraint - Return the constraint string for the specified /// output operand. All output constraints are known to be non-empty (either /// '=' or '+'). - std::string getOutputConstraint(unsigned i) const; + llvm::StringRef getOutputConstraint(unsigned i) const; const StringLiteral *getOutputConstraintLiteral(unsigned i) const { return Constraints[i]; @@ -1252,7 +1252,7 @@ public: /// getInputConstraint - Return the specified input constraint. Unlike output /// constraints, these can be empty. - std::string getInputConstraint(unsigned i) const; + llvm::StringRef getInputConstraint(unsigned i) const; const StringLiteral *getInputConstraintLiteral(unsigned i) const { return Constraints[i + NumOutputs]; @@ -1267,7 +1267,8 @@ public: return const_cast(this)->getInputExpr(i); } - void setOutputsAndInputsAndClobbers(const std::string *Names, + void setOutputsAndInputsAndClobbers(ASTContext &C, + const std::string *Names, StringLiteral **Constraints, Stmt **Exprs, unsigned NumOutputs, @@ -1280,7 +1281,7 @@ public: /// getNamedOperand - Given a symbolic operand reference like %[foo], /// translate this into a numeric value needed to reference the same operand. /// This returns -1 if the operand name is invalid. - int getNamedOperand(const std::string &SymbolicName) const; + int getNamedOperand(llvm::StringRef SymbolicName) const; unsigned getNumClobbers() const { return Clobbers.size(); } StringLiteral *getClobber(unsigned i) { return Clobbers[i]; } diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 577b0ac56099..5e4de1a17867 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -132,9 +132,8 @@ Expr *AsmStmt::getOutputExpr(unsigned i) { /// getOutputConstraint - Return the constraint string for the specified /// output operand. All output constraints are known to be non-empty (either /// '=' or '+'). -std::string AsmStmt::getOutputConstraint(unsigned i) const { - return std::string(Constraints[i]->getStrData(), - Constraints[i]->getByteLength()); +llvm::StringRef AsmStmt::getOutputConstraint(unsigned i) const { + return getOutputConstraintLiteral(i)->getString(); } /// getNumPlusOperands - Return the number of output operands that have a "+" @@ -153,13 +152,13 @@ Expr *AsmStmt::getInputExpr(unsigned i) { /// getInputConstraint - Return the specified input constraint. Unlike output /// constraints, these can be empty. -std::string AsmStmt::getInputConstraint(unsigned i) const { - return std::string(Constraints[i + NumOutputs]->getStrData(), - Constraints[i + NumOutputs]->getByteLength()); +llvm::StringRef AsmStmt::getInputConstraint(unsigned i) const { + return getInputConstraintLiteral(i)->getString(); } -void AsmStmt::setOutputsAndInputsAndClobbers(const std::string *Names, +void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C, + const std::string *Names, StringLiteral **Constraints, Stmt **Exprs, unsigned NumOutputs, @@ -183,7 +182,7 @@ void AsmStmt::setOutputsAndInputsAndClobbers(const std::string *Names, /// getNamedOperand - Given a symbolic operand reference like %[foo], /// translate this into a numeric value needed to reference the same operand. /// This returns -1 if the operand name is invalid. -int AsmStmt::getNamedOperand(const std::string &SymbolicName) const { +int AsmStmt::getNamedOperand(llvm::StringRef SymbolicName) const { unsigned NumPlusOperands = 0; // Check if this is an output operand. @@ -311,7 +310,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl&Pieces, if (NameEnd == CurPtr) return diag::err_asm_empty_symbolic_operand_name; - std::string SymbolicName(CurPtr, NameEnd); + llvm::StringRef SymbolicName(CurPtr, NameEnd - CurPtr - 1); int N = getNamedOperand(SymbolicName); if (N == -1) { diff --git a/clang/lib/Frontend/PCHReaderStmt.cpp b/clang/lib/Frontend/PCHReaderStmt.cpp index 630aa36fd2cc..4c80c87f1962 100644 --- a/clang/lib/Frontend/PCHReaderStmt.cpp +++ b/clang/lib/Frontend/PCHReaderStmt.cpp @@ -331,7 +331,8 @@ unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) { for (unsigned I = 0; I != NumClobbers; ++I) Clobbers.push_back(cast_or_null(StmtStack[StackIdx++])); - S->setOutputsAndInputsAndClobbers(Names.data(), Constraints.data(), + S->setOutputsAndInputsAndClobbers(*Reader.getContext(), + Names.data(), Constraints.data(), Exprs.data(), NumOutputs, NumInputs, Clobbers.data(), NumClobbers);