[cfe-commits] r94921 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp lib/Frontend/PCHReaderStmt.cpp

Anders Carlsson andersca at mac.com
Sat Jan 30 12:38:12 PST 2010


Author: andersca
Date: Sat Jan 30 14:38:10 2010
New Revision: 94921

URL: http://llvm.org/viewvc/llvm-project?rev=94921&view=rev
Log:
Even more AsmStmt cleanup.

Modified:
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/lib/AST/Stmt.cpp
    cfe/trunk/lib/Frontend/PCHReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=94921&r1=94920&r2=94921&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sat Jan 30 14:38:10 2010
@@ -1215,7 +1215,7 @@
   /// 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 @@
 
   /// 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 @@
     return const_cast<AsmStmt*>(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 @@
   /// 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]; }

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=94921&r1=94920&r2=94921&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Sat Jan 30 14:38:10 2010
@@ -132,9 +132,8 @@
 /// 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 @@
 
 /// 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 @@
 /// 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 @@
       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) {

Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=94921&r1=94920&r2=94921&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Sat Jan 30 14:38:10 2010
@@ -331,7 +331,8 @@
   for (unsigned I = 0; I != NumClobbers; ++I)
     Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
 
-  S->setOutputsAndInputsAndClobbers(Names.data(), Constraints.data(), 
+  S->setOutputsAndInputsAndClobbers(*Reader.getContext(),
+                                    Names.data(), Constraints.data(), 
                                     Exprs.data(), NumOutputs, NumInputs, 
                                     Clobbers.data(), NumClobbers);
 





More information about the cfe-commits mailing list