PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients

are updated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84447 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-10-18 21:17:35 +00:00
Родитель fa4f55067b
Коммит 01eb9b9683
24 изменённых файлов: 41 добавлений и 45 удалений

Просмотреть файл

@ -101,7 +101,7 @@ public:
/// identifier. /// identifier.
llvm::StringRef getName() const { llvm::StringRef getName() const {
assert(getIdentifier() && "Name is not a simple identifier"); assert(getIdentifier() && "Name is not a simple identifier");
return getIdentifier()->getNameStr(); return getIdentifier()->getName();
} }
/// getNameAsCString - Get the name of identifier for this declaration as a /// getNameAsCString - Get the name of identifier for this declaration as a

Просмотреть файл

@ -104,13 +104,8 @@ public:
return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
} }
// FIXME: Deprecated. /// getName - Return the actual identifier string.
const char *getName() const { llvm::StringRef getName() const {
return getNameStart();
}
/// getNameStr - Return the actual identifier string.
llvm::StringRef getNameStr() const {
return llvm::StringRef(getNameStart(), getLength()); return llvm::StringRef(getNameStart(), getLength());
} }
@ -477,7 +472,7 @@ public:
const IdentifierInfo *Name) { const IdentifierInfo *Name) {
llvm::SmallString<100> SelectorName; llvm::SmallString<100> SelectorName;
SelectorName = "set"; SelectorName = "set";
SelectorName += Name->getNameStr(); SelectorName += Name->getName();
SelectorName[3] = toupper(SelectorName[3]); SelectorName[3] = toupper(SelectorName[3]);
IdentifierInfo *SetterName = IdentifierInfo *SetterName =
&Idents.get(SelectorName.data(), &Idents.get(SelectorName.data(),

Просмотреть файл

@ -2924,6 +2924,7 @@ static void EncodeBitField(const ASTContext *Context, std::string& S,
S += llvm::utostr(N); S += llvm::utostr(N);
} }
// FIXME: Use SmallString for accumulating string.
void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
bool ExpandPointedToStructures, bool ExpandPointedToStructures,
bool ExpandStructures, bool ExpandStructures,

Просмотреть файл

@ -51,7 +51,7 @@ public:
bool operator<(DeclarationName LHS, DeclarationName RHS) { bool operator<(DeclarationName LHS, DeclarationName RHS) {
if (IdentifierInfo *LhsId = LHS.getAsIdentifierInfo()) if (IdentifierInfo *LhsId = LHS.getAsIdentifierInfo())
if (IdentifierInfo *RhsId = RHS.getAsIdentifierInfo()) if (IdentifierInfo *RhsId = RHS.getAsIdentifierInfo())
return LhsId->getNameStr() < RhsId->getNameStr(); return LhsId->getName() < RhsId->getName();
return LHS.getAsOpaqueInteger() < RHS.getAsOpaqueInteger(); return LHS.getAsOpaqueInteger() < RHS.getAsOpaqueInteger();
} }

Просмотреть файл

@ -1754,7 +1754,7 @@ unsigned ExtVectorElementExpr::getNumElements() const {
bool ExtVectorElementExpr::containsDuplicateElements() const { bool ExtVectorElementExpr::containsDuplicateElements() const {
// FIXME: Refactor this code to an accessor on the AST node which returns the // FIXME: Refactor this code to an accessor on the AST node which returns the
// "type" of component access, and share with code below and in Sema. // "type" of component access, and share with code below and in Sema.
llvm::StringRef Comp = Accessor->getNameStr(); llvm::StringRef Comp = Accessor->getName();
// Halving swizzles do not contain duplicate elements. // Halving swizzles do not contain duplicate elements.
if (Comp == "hi" || Comp == "lo" || Comp == "even" || Comp == "odd") if (Comp == "hi" || Comp == "lo" || Comp == "even" || Comp == "odd")

Просмотреть файл

@ -1254,7 +1254,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
void TypedefType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const { void TypedefType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'. if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'.
InnerString = ' ' + InnerString; InnerString = ' ' + InnerString;
InnerString = getDecl()->getIdentifier()->getNameStr().str() + InnerString; InnerString = getDecl()->getIdentifier()->getName().str() + InnerString;
} }
void TemplateTypeParmType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const { 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) + '-' + InnerString = "type-parameter-" + llvm::utostr_32(Depth) + '-' +
llvm::utostr_32(Index) + InnerString; llvm::utostr_32(Index) + InnerString;
else else
InnerString = Name->getNameStr().str() + InnerString; InnerString = Name->getName().str() + InnerString;
} }
void SubstTemplateTypeParmType::getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const { 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.getFlatArgumentList(),
TemplateArgs.flat_size(), TemplateArgs.flat_size(),
Policy); Policy);
MyPart = Spec->getIdentifier()->getNameStr().str() + TemplateArgsStr; MyPart = Spec->getIdentifier()->getName().str() + TemplateArgsStr;
} else if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) { } else if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) {
if (TypedefDecl *Typedef = Tag->getTypedefForAnonDecl()) if (TypedefDecl *Typedef = Tag->getTypedefForAnonDecl())
MyPart = Typedef->getIdentifier()->getName(); MyPart = Typedef->getIdentifier()->getName();

Просмотреть файл

@ -115,7 +115,7 @@ bool BasicObjCFoundationChecks::Audit(ExplodedNode* N,
return false; return false;
if (isNSString(ReceiverType, if (isNSString(ReceiverType,
ReceiverType->getDecl()->getIdentifier()->getNameStr())) ReceiverType->getDecl()->getIdentifier()->getName()))
return AuditNSString(N, ME); return AuditNSString(N, ME);
return false; return false;

Просмотреть файл

@ -213,7 +213,7 @@ static bool isRefType(QualType RetTy, const char* prefix,
// Recursively walk the typedef stack, allowing typedefs of reference types. // Recursively walk the typedef stack, allowing typedefs of reference types.
while (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) { while (TypedefType* TD = dyn_cast<TypedefType>(RetTy.getTypePtr())) {
llvm::StringRef TDName = TD->getDecl()->getIdentifier()->getNameStr(); llvm::StringRef TDName = TD->getDecl()->getIdentifier()->getName();
if (TDName.startswith(prefix) && TDName.endswith("Ref")) if (TDName.startswith(prefix) && TDName.endswith("Ref"))
return true; return true;

Просмотреть файл

@ -207,7 +207,7 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) {
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
// Precondition: the first argument of 'main' is an integer guaranteed // Precondition: the first argument of 'main' is an integer guaranteed
// to be > 0. // to be > 0.
if (FD->getIdentifier()->getNameStr() == "main" && if (FD->getIdentifier()->getName() == "main" &&
FD->getNumParams() > 0) { FD->getNumParams() > 0) {
const ParmVarDecl *PD = FD->getParamDecl(0); const ParmVarDecl *PD = FD->getParamDecl(0);
QualType T = PD->getType(); QualType T = PD->getType();

Просмотреть файл

@ -339,7 +339,7 @@ void LiveVariables::dumpLiveness(const ValTy& V, SourceManager& SM) const {
for (AnalysisDataTy::decl_iterator I = AD.begin_decl(), for (AnalysisDataTy::decl_iterator I = AD.begin_decl(),
E = AD.end_decl(); I!=E; ++I) E = AD.end_decl(); I!=E; ++I)
if (V.getDeclBit(I->second)) { if (V.getDeclBit(I->second)) {
llvm::errs() << " " << I->first->getIdentifier()->getNameStr() << " <"; llvm::errs() << " " << I->first->getIdentifier()->getName() << " <";
I->first->getLocation().dump(SM); I->first->getLocation().dump(SM);
llvm::errs() << ">\n"; llvm::errs() << ">\n";
} }

Просмотреть файл

@ -794,7 +794,7 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
continue; continue;
} }
llvm::raw_svector_ostream(OutStr) << '\'' << II->getNameStr() << '\''; llvm::raw_svector_ostream(OutStr) << '\'' << II->getName() << '\'';
break; break;
} }
case Diagnostic::ak_qualtype: case Diagnostic::ak_qualtype:

Просмотреть файл

@ -306,7 +306,7 @@ std::string MultiKeywordSelector::getName() const {
llvm::raw_svector_ostream OS(Str); llvm::raw_svector_ostream OS(Str);
for (keyword_iterator I = keyword_begin(), E = keyword_end(); I != E; ++I) { for (keyword_iterator I = keyword_begin(), E = keyword_end(); I != E; ++I) {
if (*I) if (*I)
OS << (*I)->getNameStr(); OS << (*I)->getName();
OS << ':'; OS << ':';
} }
@ -322,12 +322,12 @@ std::string Selector::getAsString() const {
// If the number of arguments is 0 then II is guaranteed to not be null. // If the number of arguments is 0 then II is guaranteed to not be null.
if (getNumArgs() == 0) if (getNumArgs() == 0)
return II->getNameStr(); return II->getName();
if (!II) if (!II)
return ":"; return ":";
return II->getNameStr().str() + ":"; return II->getName().str() + ":";
} }
// We have a multiple keyword selector (no embedded flags). // We have a multiple keyword selector (no embedded flags).

Просмотреть файл

@ -3502,11 +3502,11 @@ void CGObjCMac::FinishModule() {
llvm::raw_svector_ostream OS(Asm); llvm::raw_svector_ostream OS(Asm);
for (llvm::SetVector<IdentifierInfo*>::iterator I = LazySymbols.begin(), for (llvm::SetVector<IdentifierInfo*>::iterator I = LazySymbols.begin(),
e = LazySymbols.end(); I != e; ++I) e = LazySymbols.end(); I != e; ++I)
OS << "\t.lazy_reference .objc_class_name_" << (*I)->getNameStr() << "\n"; OS << "\t.lazy_reference .objc_class_name_" << (*I)->getName() << "\n";
for (llvm::SetVector<IdentifierInfo*>::iterator I = DefinedSymbols.begin(), for (llvm::SetVector<IdentifierInfo*>::iterator I = DefinedSymbols.begin(),
e = DefinedSymbols.end(); I != e; ++I) e = DefinedSymbols.end(); I != e; ++I)
OS << "\t.objc_class_name_" << (*I)->getNameStr() << "=0\n" OS << "\t.objc_class_name_" << (*I)->getName() << "=0\n"
<< "\t.globl .objc_class_name_" << (*I)->getNameStr() << "\n"; << "\t.globl .objc_class_name_" << (*I)->getName() << "\n";
CGM.getModule().setModuleInlineAsm(OS.str()); CGM.getModule().setModuleInlineAsm(OS.str());
} }
@ -5673,7 +5673,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
llvm::GlobalValue::ExternalLinkage, llvm::GlobalValue::ExternalLinkage,
0, 0,
("OBJC_EHTYPE_$_" + ("OBJC_EHTYPE_$_" +
ID->getIdentifier()->getNameStr())); ID->getIdentifier()->getName()));
} }
// Otherwise we need to either make a new entry or fill in the // Otherwise we need to either make a new entry or fill in the
@ -5705,7 +5705,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
llvm::GlobalValue::WeakAnyLinkage, llvm::GlobalValue::WeakAnyLinkage,
Init, Init,
("OBJC_EHTYPE_$_" + ("OBJC_EHTYPE_$_" +
ID->getIdentifier()->getNameStr())); ID->getIdentifier()->getName()));
} }
if (CGM.getLangOptions().getVisibilityMode() == LangOptions::Hidden) if (CGM.getLangOptions().getVisibilityMode() == LangOptions::Hidden)

Просмотреть файл

@ -1236,7 +1236,7 @@ static bool isCharSpecialization(QualType T, const char *Name) {
if (!isCharType(TemplateArgs[0].getAsType())) if (!isCharType(TemplateArgs[0].getAsType()))
return false; return false;
return SD->getIdentifier()->getNameStr() == Name; return SD->getIdentifier()->getName() == Name;
} }
bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) {

Просмотреть файл

@ -196,7 +196,7 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
case Decl::Function: { case Decl::Function: {
FunctionDecl* FD = cast<FunctionDecl>(D); FunctionDecl* FD = cast<FunctionDecl>(D);
if (Opts.AnalyzeSpecificFunction.size() > 0 && if (!Opts.AnalyzeSpecificFunction.empty() &&
Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName()) Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName())
break; break;

Просмотреть файл

@ -586,7 +586,7 @@ public:
typedef data_type data_type_ref; typedef data_type data_type_ref;
static unsigned ComputeHash(PTHIdKey* key) { static unsigned ComputeHash(PTHIdKey* key) {
return llvm::HashString(key->II->getNameStr()); return llvm::HashString(key->II->getName());
} }
static std::pair<unsigned,unsigned> static std::pair<unsigned,unsigned>

Просмотреть файл

@ -399,7 +399,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
} }
if (IdentifierInfo *II = Tok.getIdentifierInfo()) { if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
OS << II->getNameStr(); OS << II->getName();
} else if (Tok.isLiteral() && !Tok.needsCleaning() && } else if (Tok.isLiteral() && !Tok.needsCleaning() &&
Tok.getLiteralData()) { Tok.getLiteralData()) {
OS.write(Tok.getLiteralData(), Tok.getLength()); OS.write(Tok.getLiteralData(), Tok.getLength());
@ -434,7 +434,7 @@ namespace {
struct SortMacrosByID { struct SortMacrosByID {
typedef std::pair<IdentifierInfo*, MacroInfo*> id_macro_pair; typedef std::pair<IdentifierInfo*, MacroInfo*> id_macro_pair;
bool operator()(const id_macro_pair &LHS, const id_macro_pair &RHS) const { bool operator()(const id_macro_pair &LHS, const id_macro_pair &RHS) const {
return LHS.first->getNameStr() < RHS.first->getNameStr(); return LHS.first->getName() < RHS.first->getName();
} }
}; };
} }

Просмотреть файл

@ -128,12 +128,12 @@ void clang::RewriteMacrosInInput(Preprocessor &PP, llvm::raw_ostream *OS) {
// comment the line out. // comment the line out.
if (RawTokens[CurRawTok].is(tok::identifier)) { if (RawTokens[CurRawTok].is(tok::identifier)) {
const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo(); const IdentifierInfo *II = RawTokens[CurRawTok].getIdentifierInfo();
if (II->getNameStr() == "warning") { if (II->getName() == "warning") {
// Comment out #warning. // Comment out #warning.
RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//"); RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");
} else if (II->getNameStr() == "pragma" && } else if (II->getName() == "pragma" &&
RawTokens[CurRawTok+1].is(tok::identifier) && RawTokens[CurRawTok+1].is(tok::identifier) &&
(RawTokens[CurRawTok+1].getIdentifierInfo()->getNameStr() == (RawTokens[CurRawTok+1].getIdentifierInfo()->getName() ==
"mark")) { "mark")) {
// Comment out #pragma mark. // Comment out #pragma mark.
RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//"); RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//");

Просмотреть файл

@ -2265,7 +2265,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
if (clsName) { // class message. if (clsName) { // class message.
// FIXME: We need to fix Sema (and the AST for ObjCMessageExpr) to handle // FIXME: We need to fix Sema (and the AST for ObjCMessageExpr) to handle
// the 'super' idiom within a class method. // the 'super' idiom within a class method.
if (clsName->getNameStr() == "super") { if (clsName->getName() == "super") {
MsgSendFlavor = MsgSendSuperFunctionDecl; MsgSendFlavor = MsgSendSuperFunctionDecl;
if (MsgSendStretFlavor) if (MsgSendStretFlavor)
MsgSendStretFlavor = MsgSendSuperStretFunctionDecl; MsgSendStretFlavor = MsgSendSuperStretFunctionDecl;

Просмотреть файл

@ -45,7 +45,7 @@ AttributeList::~AttributeList() {
} }
AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
llvm::StringRef AttrName = Name->getNameStr(); llvm::StringRef AttrName = Name->getName();
// Normalize the attribute name, __foo__ becomes foo. // Normalize the attribute name, __foo__ becomes foo.
if (AttrName.startswith("__") && AttrName.endswith("__")) if (AttrName.startswith("__") && AttrName.endswith("__"))

Просмотреть файл

@ -67,7 +67,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() {
const IdentifierInfo *FieldName = Tok.getIdentifierInfo(); const IdentifierInfo *FieldName = Tok.getIdentifierInfo();
llvm::SmallString<256> NewSyntax; llvm::SmallString<256> NewSyntax;
llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getNameStr() llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getName()
<< " = "; << " = ";
SourceLocation NameLoc = ConsumeToken(); // Eat the identifier. SourceLocation NameLoc = ConsumeToken(); // Eat the identifier.

Просмотреть файл

@ -1283,7 +1283,7 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
IdentifierInfo *II = Tok.getIdentifierInfo(); IdentifierInfo *II = Tok.getIdentifierInfo();
ConsumeToken(); ConsumeToken();
Names.push_back(II->getNameStr()); Names.push_back(II->getName());
MatchRHSPunctuation(tok::r_square, Loc); MatchRHSPunctuation(tok::r_square, Loc);
} else } else
Names.push_back(std::string()); Names.push_back(std::string());

Просмотреть файл

@ -3729,7 +3729,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
if (FTI.ArgInfo[i].Param == 0) { if (FTI.ArgInfo[i].Param == 0) {
llvm::SmallString<256> Code; llvm::SmallString<256> Code;
llvm::raw_svector_ostream(Code) << " int " llvm::raw_svector_ostream(Code) << " int "
<< FTI.ArgInfo[i].Ident->getNameStr() << FTI.ArgInfo[i].Ident->getName()
<< ";\n"; << ";\n";
Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared) Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared)
<< FTI.ArgInfo[i].Ident << FTI.ArgInfo[i].Ident
@ -3996,7 +3996,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
} }
// Extension in C99. Legal in C90, but warn about it. // Extension in C99. Legal in C90, but warn about it.
if (II.getNameStr().startswith("__builtin_")) if (II.getName().startswith("__builtin_"))
Diag(Loc, diag::warn_builtin_unknown) << &II; Diag(Loc, diag::warn_builtin_unknown) << &II;
else if (getLangOptions().C99) else if (getLangOptions().C99)
Diag(Loc, diag::ext_implicit_function_decl) << &II; Diag(Loc, diag::ext_implicit_function_decl) << &II;

Просмотреть файл

@ -1255,7 +1255,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) {
unsigned NumArgs = getFunctionOrMethodNumArgs(d); unsigned NumArgs = getFunctionOrMethodNumArgs(d);
unsigned FirstIdx = 1; unsigned FirstIdx = 1;
llvm::StringRef Format = Attr.getParameterName()->getNameStr(); llvm::StringRef Format = Attr.getParameterName()->getName();
// Normalize the argument, __foo__ becomes foo. // Normalize the argument, __foo__ becomes foo.
if (Format.startswith("__") && Format.endswith("__")) if (Format.startswith("__") && Format.endswith("__"))
@ -1265,7 +1265,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) {
FormatAttrKind Kind = getFormatAttrKind(Format); FormatAttrKind Kind = getFormatAttrKind(Format);
if (Kind == InvalidFormat) { if (Kind == InvalidFormat) {
S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported) S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
<< "format" << Attr.getParameterName()->getNameStr(); << "format" << Attr.getParameterName()->getName();
return; return;
} }
@ -1503,7 +1503,7 @@ static void HandleModeAttr(Decl *D, const AttributeList &Attr, Sema &S) {
return; return;
} }
llvm::StringRef Str = Attr.getParameterName()->getNameStr(); llvm::StringRef Str = Attr.getParameterName()->getName();
// Normalize the attribute name, __foo__ becomes foo. // Normalize the attribute name, __foo__ becomes foo.
if (Str.startswith("__") && Str.endswith("__")) if (Str.startswith("__") && Str.endswith("__"))