diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 1d44509106..48ec888a37 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -101,7 +101,7 @@ public: /// identifier. llvm::StringRef getName() const { 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 diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index 0328d3f63d..e06dfbb2cf 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -104,13 +104,8 @@ public: return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1; } - // FIXME: Deprecated. - const char *getName() const { - return getNameStart(); - } - - /// getNameStr - Return the actual identifier string. - llvm::StringRef getNameStr() const { + /// getName - Return the actual identifier string. + llvm::StringRef getName() const { return llvm::StringRef(getNameStart(), getLength()); } @@ -477,7 +472,7 @@ public: const IdentifierInfo *Name) { llvm::SmallString<100> SelectorName; SelectorName = "set"; - SelectorName += Name->getNameStr(); + SelectorName += Name->getName(); SelectorName[3] = toupper(SelectorName[3]); IdentifierInfo *SetterName = &Idents.get(SelectorName.data(), diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c7e5752ec3..d96f5fbf1c 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2924,6 +2924,7 @@ static void EncodeBitField(const ASTContext *Context, std::string& S, S += llvm::utostr(N); } +// FIXME: Use SmallString for accumulating string. void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, bool ExpandPointedToStructures, bool ExpandStructures, diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp index 3ab9fa1904..56a597570d 100644 --- a/lib/AST/DeclarationName.cpp +++ b/lib/AST/DeclarationName.cpp @@ -51,7 +51,7 @@ public: bool operator<(DeclarationName LHS, DeclarationName RHS) { if (IdentifierInfo *LhsId = LHS.getAsIdentifierInfo()) if (IdentifierInfo *RhsId = RHS.getAsIdentifierInfo()) - return LhsId->getNameStr() < RhsId->getNameStr(); + return LhsId->getName() < RhsId->getName(); return LHS.getAsOpaqueInteger() < RHS.getAsOpaqueInteger(); } diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 55d1d2bc11..a4de3e5b0f 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1754,7 +1754,7 @@ unsigned ExtVectorElementExpr::getNumElements() const { bool ExtVectorElementExpr::containsDuplicateElements() const { // 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. - llvm::StringRef Comp = Accessor->getNameStr(); + llvm::StringRef Comp = Accessor->getName(); // Halving swizzles do not contain duplicate elements. if (Comp == "hi" || Comp == "lo" || Comp == "even" || Comp == "odd") diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 205974b930..daa2bc04f1 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -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()->getNameStr().str() + InnerString; + InnerString = getDecl()->getIdentifier()->getName().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->getNameStr().str() + InnerString; + InnerString = Name->getName().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()->getNameStr().str() + TemplateArgsStr; + MyPart = Spec->getIdentifier()->getName().str() + TemplateArgsStr; } else if (TagDecl *Tag = dyn_cast(DC)) { if (TypedefDecl *Typedef = Tag->getTypedefForAnonDecl()) MyPart = Typedef->getIdentifier()->getName(); diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp index ea7f82f395..aa2d0ab5a7 100644 --- a/lib/Analysis/BasicObjCFoundationChecks.cpp +++ b/lib/Analysis/BasicObjCFoundationChecks.cpp @@ -115,7 +115,7 @@ bool BasicObjCFoundationChecks::Audit(ExplodedNode* N, return false; if (isNSString(ReceiverType, - ReceiverType->getDecl()->getIdentifier()->getNameStr())) + ReceiverType->getDecl()->getIdentifier()->getName())) return AuditNSString(N, ME); return false; diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index 1affad0da3..50ddbba5b2 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -213,7 +213,7 @@ static bool isRefType(QualType RetTy, const char* prefix, // Recursively walk the typedef stack, allowing typedefs of reference types. while (TypedefType* TD = dyn_cast(RetTy.getTypePtr())) { - llvm::StringRef TDName = TD->getDecl()->getIdentifier()->getNameStr(); + llvm::StringRef TDName = TD->getDecl()->getIdentifier()->getName(); if (TDName.startswith(prefix) && TDName.endswith("Ref")) return true; diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index a31260d4dd..bfa917b738 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -207,7 +207,7 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { if (const FunctionDecl *FD = dyn_cast(D)) { // Precondition: the first argument of 'main' is an integer guaranteed // to be > 0. - if (FD->getIdentifier()->getNameStr() == "main" && + if (FD->getIdentifier()->getName() == "main" && FD->getNumParams() > 0) { const ParmVarDecl *PD = FD->getParamDecl(0); QualType T = PD->getType(); diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 96c9e69d1a..ae78d1f35f 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -339,7 +339,7 @@ void LiveVariables::dumpLiveness(const ValTy& V, SourceManager& SM) const { for (AnalysisDataTy::decl_iterator I = AD.begin_decl(), E = AD.end_decl(); I!=E; ++I) if (V.getDeclBit(I->second)) { - llvm::errs() << " " << I->first->getIdentifier()->getNameStr() << " <"; + llvm::errs() << " " << I->first->getIdentifier()->getName() << " <"; I->first->getLocation().dump(SM); llvm::errs() << ">\n"; } diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index f964423a22..d3bb9d5496 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -794,7 +794,7 @@ FormatDiagnostic(llvm::SmallVectorImpl &OutStr) const { continue; } - llvm::raw_svector_ostream(OutStr) << '\'' << II->getNameStr() << '\''; + llvm::raw_svector_ostream(OutStr) << '\'' << II->getName() << '\''; break; } case Diagnostic::ak_qualtype: diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index a3c5c4a408..16aa0c5484 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -306,7 +306,7 @@ std::string MultiKeywordSelector::getName() const { llvm::raw_svector_ostream OS(Str); for (keyword_iterator I = keyword_begin(), E = keyword_end(); I != E; ++I) { if (*I) - OS << (*I)->getNameStr(); + OS << (*I)->getName(); 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 (getNumArgs() == 0) - return II->getNameStr(); + return II->getName(); if (!II) return ":"; - return II->getNameStr().str() + ":"; + return II->getName().str() + ":"; } // We have a multiple keyword selector (no embedded flags). diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 64e965df94..db32f174ff 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -3502,11 +3502,11 @@ void CGObjCMac::FinishModule() { llvm::raw_svector_ostream OS(Asm); for (llvm::SetVector::iterator I = LazySymbols.begin(), 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::iterator I = DefinedSymbols.begin(), e = DefinedSymbols.end(); I != e; ++I) - OS << "\t.objc_class_name_" << (*I)->getNameStr() << "=0\n" - << "\t.globl .objc_class_name_" << (*I)->getNameStr() << "\n"; + OS << "\t.objc_class_name_" << (*I)->getName() << "=0\n" + << "\t.globl .objc_class_name_" << (*I)->getName() << "\n"; CGM.getModule().setModuleInlineAsm(OS.str()); } @@ -5673,7 +5673,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, llvm::GlobalValue::ExternalLinkage, 0, ("OBJC_EHTYPE_$_" + - ID->getIdentifier()->getNameStr())); + ID->getIdentifier()->getName())); } // 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, Init, ("OBJC_EHTYPE_$_" + - ID->getIdentifier()->getNameStr())); + ID->getIdentifier()->getName())); } if (CGM.getLangOptions().getVisibilityMode() == LangOptions::Hidden) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index e4416ab42c..155f87a41d 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -1236,7 +1236,7 @@ static bool isCharSpecialization(QualType T, const char *Name) { if (!isCharType(TemplateArgs[0].getAsType())) return false; - return SD->getIdentifier()->getNameStr() == Name; + return SD->getIdentifier()->getName() == Name; } bool CXXNameMangler::mangleStandardSubstitution(const NamedDecl *ND) { diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp index 276599470b..dbf9364f87 100644 --- a/lib/Frontend/AnalysisConsumer.cpp +++ b/lib/Frontend/AnalysisConsumer.cpp @@ -196,7 +196,7 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) { case Decl::Function: { FunctionDecl* FD = cast(D); - if (Opts.AnalyzeSpecificFunction.size() > 0 && + if (!Opts.AnalyzeSpecificFunction.empty() && Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName()) break; diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp index 2761c6f38c..339a1c466b 100644 --- a/lib/Frontend/CacheTokens.cpp +++ b/lib/Frontend/CacheTokens.cpp @@ -586,7 +586,7 @@ public: typedef data_type data_type_ref; static unsigned ComputeHash(PTHIdKey* key) { - return llvm::HashString(key->II->getNameStr()); + return llvm::HashString(key->II->getName()); } static std::pair diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index 3883228224..f3cb20619e 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -399,7 +399,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok, } if (IdentifierInfo *II = Tok.getIdentifierInfo()) { - OS << II->getNameStr(); + OS << II->getName(); } else if (Tok.isLiteral() && !Tok.needsCleaning() && Tok.getLiteralData()) { OS.write(Tok.getLiteralData(), Tok.getLength()); @@ -434,7 +434,7 @@ namespace { struct SortMacrosByID { typedef std::pair id_macro_pair; 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(); } }; } diff --git a/lib/Frontend/RewriteMacros.cpp b/lib/Frontend/RewriteMacros.cpp index 846d4767fa..b5d59c0aa4 100644 --- a/lib/Frontend/RewriteMacros.cpp +++ b/lib/Frontend/RewriteMacros.cpp @@ -128,12 +128,12 @@ 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 (II->getNameStr() == "warning") { + if (II->getName() == "warning") { // Comment out #warning. 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].getIdentifierInfo()->getNameStr() == + (RawTokens[CurRawTok+1].getIdentifierInfo()->getName() == "mark")) { // Comment out #pragma mark. RB.InsertTextAfter(SM.getFileOffset(RawTok.getLocation()), "//"); diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index f3ce9cda9f..0ea0a58d52 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -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 (clsName->getNameStr() == "super") { + if (clsName->getName() == "super") { MsgSendFlavor = MsgSendSuperFunctionDecl; if (MsgSendStretFlavor) MsgSendStretFlavor = MsgSendSuperStretFunctionDecl; diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index 29e44caba6..224a31cd5a 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -45,7 +45,7 @@ AttributeList::~AttributeList() { } AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { - llvm::StringRef AttrName = Name->getNameStr(); + llvm::StringRef AttrName = Name->getName(); // Normalize the attribute name, __foo__ becomes foo. if (AttrName.startswith("__") && AttrName.endswith("__")) diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp index 71e9dee561..c4e79cae3f 100644 --- a/lib/Parse/ParseInit.cpp +++ b/lib/Parse/ParseInit.cpp @@ -67,7 +67,7 @@ Parser::OwningExprResult Parser::ParseInitializerWithPotentialDesignator() { const IdentifierInfo *FieldName = Tok.getIdentifierInfo(); llvm::SmallString<256> NewSyntax; - llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getNameStr() + llvm::raw_svector_ostream(NewSyntax) << '.' << FieldName->getName() << " = "; SourceLocation NameLoc = ConsumeToken(); // Eat the identifier. diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 6ef8d0db06..272be2f660 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1283,7 +1283,7 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl &Names, IdentifierInfo *II = Tok.getIdentifierInfo(); ConsumeToken(); - Names.push_back(II->getNameStr()); + Names.push_back(II->getName()); MatchRHSPunctuation(tok::r_square, Loc); } else Names.push_back(std::string()); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 531b6f344d..735b0b6a2e 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -218,7 +218,7 @@ bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II, << &II << DC << SS->getRange(); else if (isDependentScopeSpecifier(*SS)) { Diag(SS->getRange().getBegin(), diag::err_typename_missing) - << (NestedNameSpecifier *)SS->getScopeRep() << II.getName() + << (NestedNameSpecifier *)SS->getScopeRep() << II.getName() << SourceRange(SS->getRange().getBegin(), IILoc) << CodeModificationHint::CreateInsertion(SS->getRange().getBegin(), "typename "); @@ -3729,7 +3729,7 @@ void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, if (FTI.ArgInfo[i].Param == 0) { llvm::SmallString<256> Code; llvm::raw_svector_ostream(Code) << " int " - << FTI.ArgInfo[i].Ident->getNameStr() + << FTI.ArgInfo[i].Ident->getName() << ";\n"; Diag(FTI.ArgInfo[i].IdentLoc, diag::ext_param_not_declared) << FTI.ArgInfo[i].Ident @@ -3996,7 +3996,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, } // 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; else if (getLangOptions().C99) Diag(Loc, diag::ext_implicit_function_decl) << &II; diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 98c90b2c74..341d49ead4 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1255,7 +1255,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) { unsigned NumArgs = getFunctionOrMethodNumArgs(d); unsigned FirstIdx = 1; - llvm::StringRef Format = Attr.getParameterName()->getNameStr(); + llvm::StringRef Format = Attr.getParameterName()->getName(); // Normalize the argument, __foo__ becomes foo. if (Format.startswith("__") && Format.endswith("__")) @@ -1265,7 +1265,7 @@ static void HandleFormatAttr(Decl *d, const AttributeList &Attr, Sema &S) { FormatAttrKind Kind = getFormatAttrKind(Format); if (Kind == InvalidFormat) { S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported) - << "format" << Attr.getParameterName()->getNameStr(); + << "format" << Attr.getParameterName()->getName(); return; } @@ -1503,7 +1503,7 @@ static void HandleModeAttr(Decl *D, const AttributeList &Attr, Sema &S) { return; } - llvm::StringRef Str = Attr.getParameterName()->getNameStr(); + llvm::StringRef Str = Attr.getParameterName()->getName(); // Normalize the attribute name, __foo__ becomes foo. if (Str.startswith("__") && Str.endswith("__"))