]> granicus.if.org Git - clang/commitdiff
Use IdentifierInfo * instead of std::string for the AsmStmt names.
authorAnders Carlsson <andersca@mac.com>
Sat, 30 Jan 2010 22:25:16 +0000 (22:25 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 30 Jan 2010 22:25:16 +0000 (22:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94925 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Stmt.h
include/clang/Parse/Action.h
include/clang/Parse/Parser.h
lib/AST/Stmt.cpp
lib/Frontend/PCHReaderStmt.cpp
lib/Frontend/PCHWriterStmt.cpp
lib/Frontend/PrintParserCallbacks.cpp
lib/Parse/ParseStmt.cpp
lib/Sema/Sema.h
lib/Sema/SemaStmt.cpp
lib/Sema/TreeTransform.h

index c94fe151161829160a760595aec7366c6bc5c6c5..7a251b10b99d1c771fd3592729309dc633d6ffd2 100644 (file)
@@ -1121,7 +1121,7 @@ class AsmStmt : public Stmt {
   unsigned NumOutputs;
   unsigned NumInputs;
 
-  llvm::SmallVector<std::string, 4> Names;
+  llvm::SmallVector<IdentifierInfo *, 4> Names;
   llvm::SmallVector<StringLiteral*, 4> Constraints;
   llvm::SmallVector<Stmt*, 4> Exprs;
 
@@ -1129,7 +1129,7 @@ class AsmStmt : public Stmt {
 public:
   AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, bool msasm,
           unsigned numoutputs, unsigned numinputs,
-          const std::string *names, StringLiteral **constraints,
+          IdentifierInfo **names, StringLiteral **constraints,
           Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
           StringLiteral **clobbers, SourceLocation rparenloc);
 
@@ -1208,10 +1208,17 @@ public:
 
   unsigned getNumOutputs() const { return NumOutputs; }
 
-  const std::string &getOutputName(unsigned i) const {
+  IdentifierInfo *getOutputIdentifier(unsigned i) const {
     return Names[i];
   }
 
+  llvm::StringRef getOutputName(unsigned i) const {
+    if (IdentifierInfo *II = getOutputIdentifier(i))
+      return II->getName();
+    
+    return llvm::StringRef();
+  }
+
   /// getOutputConstraint - Return the constraint string for the specified
   /// output operand.  All output constraints are known to be non-empty (either
   /// '=' or '+').
@@ -1224,7 +1231,6 @@ public:
     return Constraints[i];
   }
 
-
   Expr *getOutputExpr(unsigned i);
 
   const Expr *getOutputExpr(unsigned i) const {
@@ -1246,10 +1252,17 @@ public:
 
   unsigned getNumInputs() const { return NumInputs; }
 
-  const std::string &getInputName(unsigned i) const {
+  IdentifierInfo *getInputIdentifier(unsigned i) const {
     return Names[i + NumOutputs];
   }
 
+  llvm::StringRef getInputName(unsigned i) const {
+    if (IdentifierInfo *II = getInputIdentifier(i))
+      return II->getName();
+
+    return llvm::StringRef();
+  }
+
   /// getInputConstraint - Return the specified input constraint.  Unlike output
   /// constraints, these can be empty.
   llvm::StringRef getInputConstraint(unsigned i) const;
@@ -1268,7 +1281,7 @@ public:
   }
 
   void setOutputsAndInputsAndClobbers(ASTContext &C,
-                                      const std::string *Names,
+                                      IdentifierInfo **Names,
                                       StringLiteral **Constraints,
                                       Stmt **Exprs,
                                       unsigned NumOutputs,
index 4854fe66d4b9a195905a1d91a0ee5940ed80f29c..3d470e6244c2e187d8d83fef01d9ff23655a2b89 100644 (file)
@@ -902,7 +902,7 @@ public:
                                         bool IsVolatile,
                                         unsigned NumOutputs,
                                         unsigned NumInputs,
-                                        const std::string *Names,
+                                        IdentifierInfo **Names,
                                         MultiExprArg Constraints,
                                         MultiExprArg Exprs,
                                         ExprArg AsmString,
index e7cb0a2493d30b09c1f630143b5421b6c4000604..33f653d8f931e6f9893ad58c4d0daac7da5721b9 100644 (file)
@@ -1009,9 +1009,9 @@ private:
   OwningStmtResult ParseReturnStatement(AttributeList *Attr);
   OwningStmtResult ParseAsmStatement(bool &msAsm);
   OwningStmtResult FuzzyParseMicrosoftAsmStatement();
-  bool ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
-                           llvm::SmallVectorImpl<ExprTy*> &Constraints,
-                           llvm::SmallVectorImpl<ExprTy*> &Exprs);
+  bool ParseAsmOperandsOpt(llvm::SmallVectorImpl<IdentifierInfo *> &Names,
+                           llvm::SmallVectorImpl<ExprTy *> &Constraints,
+                           llvm::SmallVectorImpl<ExprTy *> &Exprs);
 
   //===--------------------------------------------------------------------===//
   // C++ 6: Statements and Blocks
index 28f7371b09db67bad6fd40b4946e629ae6e835ca..c2c2f0a40961464642af8250f10f3a864b87f1b5 100644 (file)
@@ -158,7 +158,7 @@ llvm::StringRef AsmStmt::getInputConstraint(unsigned i) const {
 
 
 void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C,
-                                             const std::string *Names,
+                                             IdentifierInfo **Names,
                                              StringLiteral **Constraints,
                                              Stmt **Exprs,
                                              unsigned NumOutputs,
@@ -335,7 +335,7 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl<AsmStringPiece>&Pieces,
 
 AsmStmt::AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
                  bool msasm, unsigned numoutputs, unsigned numinputs,
-                 const std::string *names, StringLiteral **constraints,
+                 IdentifierInfo **names, StringLiteral **constraints,
                  Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
                  StringLiteral **clobbers, SourceLocation rparenloc)
   : Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr)
index 4c80c87f19622a1d6fc3829fd61b71f05cda0b14..aa80b362a5f9ef470d00d8db7abc1fe7fba5928c 100644 (file)
@@ -317,11 +317,11 @@ unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) {
   S->setAsmString(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
 
   // Outputs and inputs
-  llvm::SmallVector<std::string, 16> Names;
+  llvm::SmallVector<IdentifierInfo *, 16> Names;
   llvm::SmallVector<StringLiteral*, 16> Constraints;
   llvm::SmallVector<Stmt*, 16> Exprs;
   for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
-    Names.push_back(Reader.ReadString(Record, Idx));
+    Names.push_back(Reader.GetIdentifierInfo(Record, Idx));
     Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
     Exprs.push_back(StmtStack[StackIdx++]);
   }
index fdfdfefe08ef6867f8bf4f8cc3520e2258b4ce7a..13ca8cdd9f5f9bcad958bbce6ba9b2bb29fb7635 100644 (file)
@@ -287,15 +287,15 @@ void PCHStmtWriter::VisitAsmStmt(AsmStmt *S) {
   Writer.WriteSubStmt(S->getAsmString());
 
   // Outputs
-  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
-    Writer.AddString(S->getOutputName(I), Record);
+  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {      
+    Writer.AddIdentifierRef(S->getOutputIdentifier(I), Record);
     Writer.WriteSubStmt(S->getOutputConstraintLiteral(I));
     Writer.WriteSubStmt(S->getOutputExpr(I));
   }
 
   // Inputs
   for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
-    Writer.AddString(S->getInputName(I), Record);
+    Writer.AddIdentifierRef(S->getInputIdentifier(I), Record);
     Writer.WriteSubStmt(S->getInputConstraintLiteral(I));
     Writer.WriteSubStmt(S->getInputExpr(I));
   }
index 8f706e0371ec24f3bc7d296e38ea8f8cc5f58638..6af33c20a6453f87805cc34397014972a6d78d41 100644 (file)
@@ -391,7 +391,7 @@ namespace {
                                           bool IsVolatile,
                                           unsigned NumOutputs,
                                           unsigned NumInputs,
-                                          const std::string *Names,
+                                          IdentifierInfo **Names,
                                           MultiExprArg Constraints,
                                           MultiExprArg Exprs,
                                           ExprArg AsmString,
index 88481e8b06ca10337c2776dc37e394ed867a58e4..157e8b1a45f7fd3aba49b6210b146125456db45f 100644 (file)
@@ -1171,7 +1171,6 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
              Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
              Tok.isNot(tok::eof));
   }
-  llvm::SmallVector<std::string, 4> Names;
   Token t;
   t.setKind(tok::string_literal);
   t.setLiteralData("\"FIXME: not done\"");
@@ -1181,7 +1180,7 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
   ExprVector Constraints(Actions);
   ExprVector Exprs(Actions);
   ExprVector Clobbers(Actions);
-  return Actions.ActOnAsmStmt(Tok.getLocation(), true, true, 0, 0, Names.data(),
+  return Actions.ActOnAsmStmt(Tok.getLocation(), true, true, 0, 0, 0,
                               move_arg(Constraints), move_arg(Exprs),
                               move(AsmString), move_arg(Clobbers),
                               Tok.getLocation(), true);
@@ -1245,7 +1244,7 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
   if (AsmString.isInvalid())
     return StmtError();
 
-  llvm::SmallVector<std::string, 4> Names;
+  llvm::SmallVector<IdentifierInfo *, 4> Names;
   ExprVector Constraints(Actions);
   ExprVector Exprs(Actions);
   ExprVector Clobbers(Actions);
@@ -1336,9 +1335,9 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
 ///
 //
 // FIXME: Avoid unnecessary std::string trashing.
-bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
-                                 llvm::SmallVectorImpl<ExprTy*> &Constraints,
-                                 llvm::SmallVectorImpl<ExprTy*> &Exprs) {
+bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<IdentifierInfo *> &Names,
+                                 llvm::SmallVectorImpl<ExprTy *> &Constraints,
+                                 llvm::SmallVectorImpl<ExprTy *> &Exprs) {
   // 'asm-operands' isn't present?
   if (!isTokenStringLiteral() && Tok.isNot(tok::l_square))
     return false;
@@ -1357,10 +1356,10 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
       IdentifierInfo *II = Tok.getIdentifierInfo();
       ConsumeToken();
 
-      Names.push_back(II->getName());
+      Names.push_back(II);
       MatchRHSPunctuation(tok::r_square, Loc);
     } else
-      Names.push_back(std::string());
+      Names.push_back(0);
 
     OwningExprResult Constraint(ParseAsmStringLiteral());
     if (Constraint.isInvalid()) {
index b6f477f648fd3112a393dd7a457aaaaef4b01f58..86dbff30378585f1ee7084e90cba04302704c6b4 100644 (file)
@@ -1478,7 +1478,7 @@ public:
                                         bool IsVolatile,
                                         unsigned NumOutputs,
                                         unsigned NumInputs,
-                                        const std::string *Names,
+                                        IdentifierInfo **Names,
                                         MultiExprArg Constraints,
                                         MultiExprArg Exprs,
                                         ExprArg AsmString,
index 16623600529fa3fd95be47f99c21589c26ee23de..fc0fc4f9b246c0c185d157ad7198670356b6e6d2 100644 (file)
@@ -1170,7 +1170,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
                                           bool IsVolatile,
                                           unsigned NumOutputs,
                                           unsigned NumInputs,
-                                          const std::string *Names,
+                                          IdentifierInfo **Names,
                                           MultiExprArg constraints,
                                           MultiExprArg exprs,
                                           ExprArg asmString,
@@ -1197,7 +1197,11 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
       return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
         << Literal->getSourceRange());
 
-    TargetInfo::ConstraintInfo Info(Literal->getString(), Names[i]);
+    llvm::StringRef OutputName;
+    if (Names[i])
+      OutputName = Names[i]->getName();
+
+    TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
     if (!Context.Target.validateOutputConstraint(Info))
       return StmtError(Diag(Literal->getLocStart(),
                             diag::err_asm_invalid_output_constraint)
@@ -1222,7 +1226,11 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
       return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
         << Literal->getSourceRange());
 
-    TargetInfo::ConstraintInfo Info(Literal->getString(), Names[i]);
+    llvm::StringRef InputName;
+    if (Names[i])
+      InputName = Names[i]->getName();
+
+    TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
     if (!Context.Target.validateInputConstraint(OutputConstraintInfos.data(),
                                                 NumOutputs, Info)) {
       return StmtError(Diag(Literal->getLocStart(),
index 90b5365f04b8054ed976cf81db8d9593a00c1127..b23a69860b7351c33aab50ee073fa1f80bdd702d 100644 (file)
@@ -785,7 +785,7 @@ public:
                                   bool IsVolatile,
                                   unsigned NumOutputs,
                                   unsigned NumInputs,
-                                  const std::string *Names,
+                                  IdentifierInfo **Names,
                                   MultiExprArg Constraints,
                                   MultiExprArg Exprs,
                                   ExprArg AsmString,
@@ -3352,7 +3352,7 @@ TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
   
   ASTOwningVector<&ActionBase::DeleteExpr> Constraints(getSema());
   ASTOwningVector<&ActionBase::DeleteExpr> Exprs(getSema());
-  llvm::SmallVector<std::string, 4> Names;
+  llvm::SmallVector<IdentifierInfo *, 4> Names;
 
   OwningExprResult AsmString(SemaRef);
   ASTOwningVector<&ActionBase::DeleteExpr> Clobbers(getSema());
@@ -3361,7 +3361,7 @@ TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
   
   // Go through the outputs.
   for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
-    Names.push_back(S->getOutputName(I));
+    Names.push_back(S->getOutputIdentifier(I));
     
     // No need to transform the constraint literal.
     Constraints.push_back(S->getOutputConstraintLiteral(I)->Retain());
@@ -3379,7 +3379,7 @@ TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
   
   // Go through the inputs.
   for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
-    Names.push_back(S->getInputName(I));
+    Names.push_back(S->getInputIdentifier(I));
     
     // No need to transform the constraint literal.
     Constraints.push_back(S->getInputConstraintLiteral(I)->Retain());