forked from OSchip/llvm-project
Move misc clients to IdentifierInfo StringRef API.
- strcmp -> == - OS.write(II->getName() ...) -> OS << II->getNameStr() - Avoid std::string concatenation - Use getNameStr().str() when an std::string is really needed. llvm-svn: 84437
This commit is contained in:
parent
2c422dc9ca
commit
70e7eadd15
|
@ -51,7 +51,7 @@ public:
|
|||
bool operator<(DeclarationName LHS, DeclarationName RHS) {
|
||||
if (IdentifierInfo *LhsId = LHS.getAsIdentifierInfo())
|
||||
if (IdentifierInfo *RhsId = RHS.getAsIdentifierInfo())
|
||||
return strcmp(LhsId->getName(), RhsId->getName()) < 0;
|
||||
return LhsId->getNameStr() < RhsId->getNameStr();
|
||||
|
||||
return LHS.getAsOpaqueInteger() < RHS.getAsOpaqueInteger();
|
||||
}
|
||||
|
|
|
@ -1254,7 +1254,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
|
|||
void TypedefType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
|
||||
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
|
||||
InnerString = ' ' + InnerString;
|
||||
InnerString = getDecl()->getIdentifier()->getName() + InnerString;
|
||||
InnerString = getDecl()->getIdentifier()->getNameStr().str() + InnerString;
|
||||
}
|
||||
|
||||
void TemplateTypeParmType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
|
||||
|
@ -1265,7 +1265,7 @@ void TemplateTypeParmType::getAsStringInternal(std::string &InnerString, const P
|
|||
InnerString = "type-parameter-" + llvm::utostr_32(Depth) + '-' +
|
||||
llvm::utostr_32(Index) + InnerString;
|
||||
else
|
||||
InnerString = Name->getName() + InnerString;
|
||||
InnerString = Name->getNameStr().str() + InnerString;
|
||||
}
|
||||
|
||||
void SubstTemplateTypeParmType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
|
||||
|
@ -1541,7 +1541,7 @@ void TagType::getAsStringInternal(std::string &InnerString, const PrintingPolicy
|
|||
TemplateArgs.getFlatArgumentList(),
|
||||
TemplateArgs.flat_size(),
|
||||
Policy);
|
||||
MyPart = Spec->getIdentifier()->getName() + TemplateArgsStr;
|
||||
MyPart = Spec->getIdentifier()->getNameStr().str() + TemplateArgsStr;
|
||||
} else if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) {
|
||||
if (TypedefDecl *Typedef = Tag->getTypedefForAnonDecl())
|
||||
MyPart = Typedef->getIdentifier()->getName();
|
||||
|
|
|
@ -207,7 +207,7 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) {
|
|||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
|
||||
// Precondition: the first argument of 'main' is an integer guaranteed
|
||||
// to be > 0.
|
||||
if (strcmp(FD->getIdentifier()->getName(), "main") == 0 &&
|
||||
if (FD->getIdentifier()->getNameStr() == "main" &&
|
||||
FD->getNumParams() > 0) {
|
||||
const ParmVarDecl *PD = FD->getParamDecl(0);
|
||||
QualType T = PD->getType();
|
||||
|
|
|
@ -1236,10 +1236,7 @@ static bool isCharSpecialization(QualType T, const char *Name) {
|
|||
if (!isCharType(TemplateArgs[0].getAsType()))
|
||||
return false;
|
||||
|
||||
if (strcmp(SD->getIdentifier()->getName(), Name) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return SD->getIdentifier()->getNameStr() == Name;
|
||||
}
|
||||
|
||||
bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) {
|
||||
|
|
|
@ -399,7 +399,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
|
|||
}
|
||||
|
||||
if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
|
||||
OS.write(II->getName(), II->getLength());
|
||||
OS << II->getNameStr();
|
||||
} else if (Tok.isLiteral() && !Tok.needsCleaning() &&
|
||||
Tok.getLiteralData()) {
|
||||
OS.write(Tok.getLiteralData(), Tok.getLength());
|
||||
|
@ -434,7 +434,7 @@ namespace {
|
|||
struct SortMacrosByID {
|
||||
typedef std::pair<IdentifierInfo*, MacroInfo*> id_macro_pair;
|
||||
bool operator()(const id_macro_pair &LHS, const id_macro_pair &RHS) const {
|
||||
return strcmp(LHS.first->getName(), RHS.first->getName()) < 0;
|
||||
return LHS.first->getNameStr() < RHS.first->getNameStr();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -128,13 +128,13 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
|
|||
// comment the line out.
|
||||
if (RawTokens[CurRawTok].is(tok::identifier)) {
|
||||
const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo();
|
||||
if (!strcmp(II->getName(), "warning")) {
|
||||
if (II->getNameStr() == "warning") {
|
||||
// Comment out #warning.
|
||||
RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");
|
||||
} else if (!strcmp(II->getName(), "pragma") &&
|
||||
} else if (II->getNameStr() == "pragma" &&
|
||||
RawTokens[CurRawTok+1].is(tok::identifier) &&
|
||||
!strcmp(RawTokens[CurRawTok+1].getIdentifierInfo()->getName(),
|
||||
"mark")){
|
||||
(RawTokens[CurRawTok+1].getIdentifierInfo()->getNameStr() ==
|
||||
"mark")) {
|
||||
// Comment out #pragma mark.
|
||||
RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");
|
||||
}
|
||||
|
|
|
@ -675,7 +675,7 @@ static std::string getIvarAccessString(ObjCInterfaceDecl *ClassDecl,
|
|||
S = "((struct ";
|
||||
S += ClassDecl->getIdentifier()->getName();
|
||||
S += "_IMPL *)self)->";
|
||||
S += OID->getNameAsCString();
|
||||
S += OID->getName();
|
||||
return S;
|
||||
}
|
||||
|
||||
|
@ -2265,7 +2265,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
|
|||
if (clsName) { // class message.
|
||||
// FIXME: We need to fix Sema (and the AST for ObjCMessageExpr) to handle
|
||||
// the 'super' idiom within a class method.
|
||||
if (!strcmp(clsName->getName(), "super")) {
|
||||
if (clsName->getNameStr() == "super") {
|
||||
MsgSendFlavor = MsgSendSuperFunctionDecl;
|
||||
if (MsgSendStretFlavor)
|
||||
MsgSendStretFlavor = MsgSendSuperStretFunctionDecl;
|
||||
|
|
|
@ -1256,6 +1256,8 @@ Parser::OwningStmtResult Parser::ParseAsmStatement(bool &msAsm) {
|
|||
/// asm-string-literal '(' expression ')'
|
||||
/// '[' identifier ']' asm-string-literal '(' expression ')'
|
||||
///
|
||||
//
|
||||
// FIXME: Avoid unnecessary std::string trashing.
|
||||
bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
|
||||
llvm::SmallVectorImpl<ExprTy*> &Constraints,
|
||||
llvm::SmallVectorImpl<ExprTy*> &Exprs) {
|
||||
|
@ -1281,7 +1283,7 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
|
|||
IdentifierInfo *II = Tok.getIdentifierInfo();
|
||||
ConsumeToken();
|
||||
|
||||
Names.push_back(std::string(II->getName(), II->getLength()));
|
||||
Names.push_back(II->getNameStr());
|
||||
MatchRHSPunctuation(tok::r_square, Loc);
|
||||
} else
|
||||
Names.push_back(std::string());
|
||||
|
|
|
@ -3727,12 +3727,13 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
|
|||
for (int i = FTI.NumArgs; i != 0; /* decrement in loop */) {
|
||||
--i;
|
||||
if (FTI.ArgInfo[i].Param == 0) {
|
||||
std::string Code = " int ";
|
||||
Code += FTI.ArgInfo[i].Ident->getName();
|
||||
Code += ";\n";
|
||||
llvm::SmallString<256> Code;
|
||||
llvm::raw_svector_ostream(Code) << " int "
|
||||
<< FTI.ArgInfo[i].Ident->getNameStr()
|
||||
<< ";\n";
|
||||
Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared)
|
||||
<< FTI.ArgInfo[i].Ident
|
||||
<< CodeModificationHint::CreateInsertion(LocAfterDecls, Code);
|
||||
<< CodeModificationHint::CreateInsertion(LocAfterDecls, Code.str());
|
||||
|
||||
// Implicitly declare the argument as type 'int' for lack of a better
|
||||
// type.
|
||||
|
|
Loading…
Reference in New Issue