]> granicus.if.org Git - clang/commitdiff
PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients
authorDaniel Dunbar <daniel@zuster.org>
Sun, 18 Oct 2009 21:17:35 +0000 (21:17 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 18 Oct 2009 21:17:35 +0000 (21:17 +0000)
are updated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84447 91177308-0d34-0410-b5e6-96231b3b80d8

24 files changed:
include/clang/AST/Decl.h
include/clang/Basic/IdentifierTable.h
lib/AST/ASTContext.cpp
lib/AST/DeclarationName.cpp
lib/AST/Expr.cpp
lib/AST/Type.cpp
lib/Analysis/BasicObjCFoundationChecks.cpp
lib/Analysis/CFRefCount.cpp
lib/Analysis/GRExprEngine.cpp
lib/Analysis/LiveVariables.cpp
lib/Basic/Diagnostic.cpp
lib/Basic/IdentifierTable.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/Mangle.cpp
lib/Frontend/AnalysisConsumer.cpp
lib/Frontend/CacheTokens.cpp
lib/Frontend/PrintPreprocessedOutput.cpp
lib/Frontend/RewriteMacros.cpp
lib/Frontend/RewriteObjC.cpp
lib/Parse/AttributeList.cpp
lib/Parse/ParseInit.cpp
lib/Parse/ParseStmt.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp

index 1d4450910619767f19dca8cb3742c177d90c46ce..48ec888a376b5d623dd11743aa49c69b2a9eefe2 100644 (file)
@@ -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
index 0328d3f63d4ef875d6d7fd6420e0e536dfd12bee..e06dfbb2cf1beec685dd2243f0b13033053aecc3 100644 (file)
@@ -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(),
index c7e5752ec3c03ac67efb408df6b7aad0f1334e22..d96f5fbf1cb6be667ec0287239746b73339bb812 100644 (file)
@@ -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,
index 3ab9fa19045cd59254a2580c09d880f742393efb..56a597570dd09a6315edb574ed77beadc988b0e7 100644 (file)
@@ -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();
 }
index 55d1d2bc111504aa3b0cd1cca1e7792e7962cf5e..a4de3e5b0f7af0cc9a3a9e1fa24c0294a6431cb6 100644 (file)
@@ -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")
index 205974b9305e559ba597e2db65212fb37ced5a9e..daa2bc04f1c961954bfb12befcea00881a7738ad 100644 (file)
@@ -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<TagDecl>(DC)) {
         if (TypedefDecl *Typedef = Tag->getTypedefForAnonDecl())
           MyPart = Typedef->getIdentifier()->getName();
index ea7f82f3955c0cbd5f38e99694aa730e4f47c21d..aa2d0ab5a7635bc08f9bf793e7d9c7e68cc029dd 100644 (file)
@@ -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;
index 1affad0da3728fbac57d4b7030052e02c28fdc53..50ddbba5b2c52b42ef199151ec263e9e8969433f 100644 (file)
@@ -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<TypedefType>(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;
 
index a31260d4dde85d35b5f503aff055fe93b16853dc..bfa917b73848526a49a288a9f6852f41b01e65d7 100644 (file)
@@ -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 (FD->getIdentifier()->getNameStr() == "main" &&
+    if (FD->getIdentifier()->getName() == "main" &&
         FD->getNumParams() > 0) {
       const ParmVarDecl *PD = FD->getParamDecl(0);
       QualType T = PD->getType();
index 96c9e69d1af04d489719dfc35754a9e35ebb3fae..ae78d1f35ff646be3bdb8c7f43e4104707a5bc56 100644 (file)
@@ -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";
     }
index f964423a221a3a2c6f44f6876f7dbf7fb2157561..d3bb9d5496cb8dd50a37f25520ac925bfce06189 100644 (file)
@@ -794,7 +794,7 @@ FormatDiagnostic(llvm::SmallVectorImpl<char> &OutStr) const {
         continue;
       }
 
-      llvm::raw_svector_ostream(OutStr) << '\'' << II->getNameStr() << '\'';
+      llvm::raw_svector_ostream(OutStr) << '\'' << II->getName() << '\'';
       break;
     }
     case Diagnostic::ak_qualtype:
index a3c5c4a408d8df982eb7e1819816832b14f5f606..16aa0c54846ac6ba04a5bb8d5d036eae0710d458 100644 (file)
@@ -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).
index 64e965df94d877d04b68e2c27a5b812fac4c8854..db32f174ffc0f6be97799994d095368a1f8c8ac1 100644 (file)
@@ -3502,11 +3502,11 @@ void CGObjCMac::FinishModule() {
     llvm::raw_svector_ostream OS(Asm);
     for (llvm::SetVector<IdentifierInfo*>::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<IdentifierInfo*>::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)
index e4416ab42c3b8b17f456dfaaed9012779a9f3c90..155f87a41d396fe6fba22a7aa63d761ba112773e 100644 (file)
@@ -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) {
index 276599470b78e9d815132f364746650976a8bf6a..dbf9364f8722092c5b912b2369aeb25b22ff9892 100644 (file)
@@ -196,7 +196,7 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
     case Decl::Function: {
       FunctionDecl* FD = cast<FunctionDecl>(D);
 
-      if (Opts.AnalyzeSpecificFunction.size() > 0 &&
+      if (!Opts.AnalyzeSpecificFunction.empty() &&
           Opts.AnalyzeSpecificFunction != FD->getIdentifier()->getName())
         break;
 
index 2761c6f38c4d45e2c32d8b751245ec2ac7efaa03..339a1c466bc967613072c55e4d6e27af299dc98f 100644 (file)
@@ -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<unsigned,unsigned>
index 38832282245c06783a7c372c131e9f29160b8ce5..f3cb20619ed5f5178621b209279e0500cab2dda8 100644 (file)
@@ -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<IdentifierInfo*, MacroInfo*> 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();
     }
   };
 }
index 846d4767fac68071efb5c538b09232b475f67318..b5d59c0aa401102e4cc80a710a44754a78a77f3d 100644 (file)
@@ -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()), "//");
index f3ce9cda9f0af7e0d140b2070932b54e1b6cc54c..0ea0a58d523952bd45c90ed8ffa3b15a0c211953 100644 (file)
@@ -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;
index 29e44caba64079c74584878a675c994158c740a4..224a31cd5a5ef2301f554e6573dbad66351fa383 100644 (file)
@@ -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("__"))
index 71e9dee56135aa9239f542d938b6f40d220483a9..c4e79cae3f54dcf06c69a6e130f2f9db53d3cf78 100644 (file)
@@ -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.
index 6ef8d0db06562bb83b4f1f881a1ac67f6a22ab7f..272be2f660173c882f2ff77f636b2af8b9e07a5a 100644 (file)
@@ -1283,7 +1283,7 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &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());
index 531b6f344d5c5c990277bdcd92331c483c68fec6..735b0b6a2ef1854118fa0d4aef01275c87fb6a5e 100644 (file)
@@ -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;
index 98c90b2c7443f10826fbdd6c69f85880c1da5d17..341d49ead418aa5161d0861c53938b872ab9c55f 100644 (file)
@@ -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("__"))