Use IdentifierInfo * instead of std::string for the AsmStmt names.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94925 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index c94fe15..7a251b1 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -1121,7 +1121,7 @@
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 @@
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 @@
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 @@
return Constraints[i];
}
-
Expr *getOutputExpr(unsigned i);
const Expr *getOutputExpr(unsigned i) const {
@@ -1246,10 +1252,17 @@
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 @@
}
void setOutputsAndInputsAndClobbers(ASTContext &C,
- const std::string *Names,
+ IdentifierInfo **Names,
StringLiteral **Constraints,
Stmt **Exprs,
unsigned NumOutputs,
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 4854fe6..3d470e6 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -902,7 +902,7 @@
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
- const std::string *Names,
+ IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index e7cb0a2..33f653d 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -1009,9 +1009,9 @@
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
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 28f7371..c2c2f0a 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -158,7 +158,7 @@
void AsmStmt::setOutputsAndInputsAndClobbers(ASTContext &C,
- const std::string *Names,
+ IdentifierInfo **Names,
StringLiteral **Constraints,
Stmt **Exprs,
unsigned NumOutputs,
@@ -335,7 +335,7 @@
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)
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index 4c80c87..aa80b36 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -317,11 +317,11 @@
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++]);
}
diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp
index fdfdfef..13ca8cd 100644
--- a/lib/Frontend/PCHWriterStmt.cpp
+++ b/lib/Frontend/PCHWriterStmt.cpp
@@ -287,15 +287,15 @@
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));
}
diff --git a/lib/Frontend/PrintParserCallbacks.cpp b/lib/Frontend/PrintParserCallbacks.cpp
index 8f706e0..6af33c2 100644
--- a/lib/Frontend/PrintParserCallbacks.cpp
+++ b/lib/Frontend/PrintParserCallbacks.cpp
@@ -391,7 +391,7 @@
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
- const std::string *Names,
+ IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 88481e8..157e8b1 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -1171,7 +1171,6 @@
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 @@
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 @@
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 @@
///
//
// 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 @@
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()) {
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index b6f477f..86dbff3 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1478,7 +1478,7 @@
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
- const std::string *Names,
+ IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 1662360..fc0fc4f 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -1170,7 +1170,7 @@
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
- const std::string *Names,
+ IdentifierInfo **Names,
MultiExprArg constraints,
MultiExprArg exprs,
ExprArg asmString,
@@ -1197,7 +1197,11 @@
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 @@
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(),
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 90b5365..b23a698 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -785,7 +785,7 @@
bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
- const std::string *Names,
+ IdentifierInfo **Names,
MultiExprArg Constraints,
MultiExprArg Exprs,
ExprArg AsmString,
@@ -3352,7 +3352,7 @@
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 @@
// 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 @@
// 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());