Move clients to use IdentifierInfo::getNameStart() instead of getName()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84436 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 0c413f6..d270a95 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -231,6 +231,8 @@
 }
 
 std::string NamedDecl::getQualifiedNameAsString(const PrintingPolicy &P) const {
+  // FIXME: Collect contexts, then accumulate names to avoid unnecessary
+  // std::string thrashing.
   std::vector<std::string> Names;
   std::string QualName;
   const DeclContext *Ctx = getDeclContext();
@@ -252,7 +254,7 @@
                                            TemplateArgs.getFlatArgumentList(),
                                            TemplateArgs.flat_size(),
                                            P);
-      Names.push_back(Spec->getIdentifier()->getName() + TemplateArgsStr);
+      Names.push_back(Spec->getIdentifier()->getNameStart() + TemplateArgsStr);
     } else if (const NamedDecl *ND = dyn_cast<NamedDecl>(Ctx))
       Names.push_back(ND->getNameAsString());
     else
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 3a838fa..6e0da47 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -117,7 +117,7 @@
 }
 
 const char *LabelStmt::getName() const {
-  return getID()->getName();
+  return getID()->getNameStart();
 }
 
 // This is defined here to avoid polluting Stmt.h with importing Expr.h
diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp
index 0465999..cf71d6b 100644
--- a/lib/AST/StmtDumper.cpp
+++ b/lib/AST/StmtDumper.cpp
@@ -244,7 +244,7 @@
     // print a free standing tag decl (e.g. "struct x;").
     const char *tagname;
     if (const IdentifierInfo *II = TD->getIdentifier())
-      tagname = II->getName();
+      tagname = II->getNameStart();
     else
       tagname = "<anonymous>";
     fprintf(F, "\"%s %s;\"", TD->getKindName(), tagname);
@@ -253,7 +253,7 @@
     // print using-directive decl (e.g. "using namespace x;")
     const char *ns;
     if (const IdentifierInfo *II = UD->getNominatedNamespace()->getIdentifier())
-      ns = II->getName();
+      ns = II->getNameStart();
     else
       ns = "<anonymous>";
     fprintf(F, "\"%s %s;\"",UD->getDeclKindName(), ns);
@@ -403,7 +403,7 @@
 }
 void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) {
   DumpExpr(Node);
-  fprintf(F, " %s", Node->getAccessor().getName());
+  fprintf(F, " %s", Node->getAccessor().getNameStart());
 }
 void StmtDumper::VisitBinaryOperator(BinaryOperator *Node) {
   DumpExpr(Node);
@@ -495,7 +495,7 @@
   DumpExpr(Node);
   fprintf(F, " selector=%s", Node->getSelector().getAsString().c_str());
   IdentifierInfo* clsName = Node->getClassName();
-  if (clsName) fprintf(F, " class=%s", clsName->getName());
+  if (clsName) fprintf(F, " class=%s", clsName->getNameStart());
 }
 
 void StmtDumper::VisitObjCEncodeExpr(ObjCEncodeExpr *Node) {
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 0922538..cbd0691 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1502,11 +1502,11 @@
   const char *Kind = Policy.SuppressTagKind? 0 : getDecl()->getKindName();
   const char *ID;
   if (const IdentifierInfo *II = getDecl()->getIdentifier())
-    ID = II->getName();
+    ID = II->getNameStart();
   else if (TypedefDecl *Typedef = getDecl()->getTypedefForAnonDecl()) {
     Kind = 0;
     assert(Typedef->getIdentifier() && "Typedef without identifier?");
-    ID = Typedef->getIdentifier()->getName();
+    ID = Typedef->getIdentifier()->getNameStart();
   } else
     ID = "<anonymous>";
 
diff --git a/lib/Analysis/BasicObjCFoundationChecks.cpp b/lib/Analysis/BasicObjCFoundationChecks.cpp
index c4d73ab..ea7f82f 100644
--- a/lib/Analysis/BasicObjCFoundationChecks.cpp
+++ b/lib/Analysis/BasicObjCFoundationChecks.cpp
@@ -45,9 +45,9 @@
 }
 
 static const char* GetReceiverNameType(const ObjCMessageExpr* ME) {
-  const ObjCInterfaceType *ReceiverType = GetReceiverType(ME);
-  return ReceiverType ? ReceiverType->getDecl()->getIdentifier()->getName()
-                      : NULL;
+  if (const ObjCInterfaceType *ReceiverType = GetReceiverType(ME))
+    return ReceiverType->getDecl()->getIdentifier()->getNameStart();
+  return NULL;
 }
 
 namespace {
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 7379b67..1affad0 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -931,7 +931,7 @@
     // [PR 3337] Use 'getAs<FunctionType>' to strip away any typedefs on the
     // function's type.
     const FunctionType* FT = FD->getType()->getAs<FunctionType>();
-    const char* FName = FD->getIdentifier()->getName();
+    const char* FName = FD->getIdentifier()->getNameStart();
 
     // Strip away preceding '_'.  Doing this here will effect all the checks
     // down below.
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 5079ace..46c5749 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -1445,10 +1445,9 @@
     // HACK: Some functions are not marked noreturn, and don't return.
     //  Here are a few hardwired ones.  If this takes too long, we can
     //  potentially cache these results.
-    const char* s = FD->getIdentifier()->getName();
-    unsigned n = strlen(s);
+    const char* s = FD->getIdentifier()->getNameStart();
 
-    switch (n) {
+    switch (FD->getIdentifier()->getLength()) {
     default:
       break;
 
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 4763b7f..ea84829 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -825,7 +825,7 @@
 CodeGenModule::CreateRuntimeFunction(const llvm::FunctionType *FTy,
                                      const char *Name) {
   // Convert Name to be a uniqued string from the IdentifierInfo table.
-  Name = getContext().Idents.get(Name).getName();
+  Name = getContext().Idents.get(Name).getNameStart();
   return GetOrCreateLLVMFunction(Name, FTy, GlobalDecl());
 }
 
@@ -911,7 +911,7 @@
 CodeGenModule::CreateRuntimeVariable(const llvm::Type *Ty,
                                      const char *Name) {
   // Convert Name to be a uniqued string from the IdentifierInfo table.
-  Name = getContext().Idents.get(Name).getName();
+  Name = getContext().Idents.get(Name).getNameStart();
   return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 0);
 }
 
@@ -1254,7 +1254,7 @@
 
   // Unique the name through the identifier table.
   const char *AliaseeName = AA->getAliasee().c_str();
-  AliaseeName = getContext().Idents.get(AliaseeName).getName();
+  AliaseeName = getContext().Idents.get(AliaseeName).getNameStart();
 
   // Create a reference to the named value.  This ensures that it is emitted
   // if a deferred decl.
@@ -1341,7 +1341,7 @@
     cast<llvm::FunctionType>(getTypes().ConvertType(Type));
 
   // Unique the name through the identifier table.
-  Name = getContext().Idents.get(Name).getName();
+  Name = getContext().Idents.get(Name).getNameStart();
   return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl(FD));
 }
 
diff --git a/lib/Frontend/CacheTokens.cpp b/lib/Frontend/CacheTokens.cpp
index afab2c2..2761c6f 100644
--- a/lib/Frontend/CacheTokens.cpp
+++ b/lib/Frontend/CacheTokens.cpp
@@ -591,7 +591,7 @@
 
   static std::pair<unsigned,unsigned>
   EmitKeyDataLength(llvm::raw_ostream& Out, const PTHIdKey* key, uint32_t) {
-    unsigned n = strlen(key->II->getName()) + 1;
+    unsigned n = key->II->getLength() + 1;
     ::Emit16(Out, n);
     return std::make_pair(n, sizeof(uint32_t));
   }
@@ -600,7 +600,7 @@
     // Record the location of the key data.  This is used when generating
     // the mapping from persistent IDs to strings.
     key->FileOffset = Out.tell();
-    Out.write(key->II->getName(), n);
+    Out.write(key->II->getNameStart(), n);
   }
 
   static void EmitData(llvm::raw_ostream& Out, PTHIdKey*, uint32_t pID,
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index bd5bbbe..ef73da7 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1505,7 +1505,7 @@
       IdentifierInfo *II = Identifiers[I];
       // Look in the on-disk hash table for an entry for
       PCHIdentifierLookupTrait Info(*this, II);
-      std::pair<const char*, unsigned> Key(II->getName(), II->getLength());
+      std::pair<const char*, unsigned> Key(II->getNameStart(), II->getLength());
       PCHIdentifierLookupTable::iterator Pos = IdTable->find(Key, &Info);
       if (Pos == IdTable->end())
         continue;
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 602f9c9..dbe1e99 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -1594,7 +1594,7 @@
   std::pair<unsigned,unsigned>
     EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II,
                       pch::IdentID ID) {
-    unsigned KeyLen = strlen(II->getName()) + 1;
+    unsigned KeyLen = II->getLength() + 1;
     unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
     if (isInterestingIdentifier(II)) {
       DataLen += 2; // 2 bytes for builtin ID, flags
@@ -1619,7 +1619,7 @@
     // Record the location of the key data.  This is used when generating
     // the mapping from persistent IDs to strings.
     Writer.SetIdentifierOffset(II, Out.tell());
-    Out.write(II->getName(), KeyLen);
+    Out.write(II->getNameStart(), KeyLen);
   }
 
   void EmitData(llvm::raw_ostream& Out, const IdentifierInfo* II,
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 55ab78e..bd3031a 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -2289,9 +2289,9 @@
       llvm::SmallVector<Expr*, 8> ClsExprs;
       QualType argType = Context->getPointerType(Context->CharTy);
       ClsExprs.push_back(StringLiteral::Create(*Context,
-                                        SuperDecl->getIdentifier()->getName(),
-                                        SuperDecl->getIdentifier()->getLength(),
-                                        false, argType, SourceLocation()));
+                                     SuperDecl->getIdentifier()->getNameStart(),
+                                     SuperDecl->getIdentifier()->getLength(),
+                                     false, argType, SourceLocation()));
       CallExpr *Cls = SynthesizeCallToFunctionDecl(GetMetaClassFunctionDecl,
                                                    &ClsExprs[0],
                                                    ClsExprs.size());
@@ -2343,7 +2343,7 @@
       llvm::SmallVector<Expr*, 8> ClsExprs;
       QualType argType = Context->getPointerType(Context->CharTy);
       ClsExprs.push_back(StringLiteral::Create(*Context,
-                                               clsName->getName(),
+                                               clsName->getNameStart(),
                                                clsName->getLength(),
                                                false, argType,
                                                SourceLocation()));
@@ -2375,9 +2375,9 @@
       llvm::SmallVector<Expr*, 8> ClsExprs;
       QualType argType = Context->getPointerType(Context->CharTy);
       ClsExprs.push_back(StringLiteral::Create(*Context,
-                                        SuperDecl->getIdentifier()->getName(),
-                                        SuperDecl->getIdentifier()->getLength(),
-                                        false, argType, SourceLocation()));
+                                     SuperDecl->getIdentifier()->getNameStart(),
+                                     SuperDecl->getIdentifier()->getLength(),
+                                     false, argType, SourceLocation()));
       CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
                                                    &ClsExprs[0],
                                                    ClsExprs.size());
diff --git a/lib/Index/Entity.cpp b/lib/Index/Entity.cpp
index 77d7a84..03fe9f7 100644
--- a/lib/Index/Entity.cpp
+++ b/lib/Index/Entity.cpp
@@ -72,7 +72,8 @@
 
   if (IdentifierInfo *II = LocalName.getAsIdentifierInfo()) {
     IdentifierInfo *GlobII =
-        &ProgImpl.getIdents().get(II->getName(), II->getName() + II->getLength());
+      &ProgImpl.getIdents().get(II->getNameStart(),
+                                II->getNameStart() + II->getLength());
     GlobName = DeclarationName(GlobII);
   } else {
     Selector LocalSel = LocalName.getObjCSelector();
@@ -139,8 +140,9 @@
   DeclarationName LocalName;
 
   if (IdentifierInfo *GlobII = Name.getAsIdentifierInfo()) {
-    IdentifierInfo &II = AST.Idents.get(GlobII->getName(),
-                                       GlobII->getName() + GlobII->getLength());
+    IdentifierInfo &II =
+      AST.Idents.get(GlobII->getNameStart(),
+                     GlobII->getNameStart() + GlobII->getLength());
     LocalName = DeclarationName(&II);
   } else {
     Selector GlobSel = Name.getObjCSelector();
diff --git a/lib/Index/GlobalSelector.cpp b/lib/Index/GlobalSelector.cpp
index f3ec41d..2b2ca6d 100644
--- a/lib/Index/GlobalSelector.cpp
+++ b/lib/Index/GlobalSelector.cpp
@@ -29,8 +29,9 @@
   for (unsigned i = 0, e = GlobSel.isUnarySelector() ? 1 : GlobSel.getNumArgs();
          i != e; ++i) {
     IdentifierInfo *GlobII = GlobSel.getIdentifierInfoForSlot(i);
-    IdentifierInfo *II = &AST.Idents.get(GlobII->getName(),
-                                       GlobII->getName() + GlobII->getLength());
+    IdentifierInfo *II =
+      &AST.Idents.get(GlobII->getNameStart(),
+                      GlobII->getNameStart() + GlobII->getLength());
     Ids.push_back(II);
   }
 
@@ -57,8 +58,9 @@
   for (unsigned i = 0, e = Sel.isUnarySelector() ? 1 : Sel.getNumArgs();
          i != e; ++i) {
     IdentifierInfo *II = Sel.getIdentifierInfoForSlot(i);
-    IdentifierInfo *GlobII = &ProgImpl.getIdents().get(II->getName(),
-                                               II->getName() + II->getLength());
+    IdentifierInfo *GlobII =
+      &ProgImpl.getIdents().get(II->getNameStart(),
+                                II->getNameStart() + II->getLength());
     Ids.push_back(GlobII);
   }
 
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 196a77f..e264efa 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1071,7 +1071,7 @@
   // we allow macros that expand to nothing after the filename, because this
   // falls into the category of "#include pp-tokens new-line" specified in
   // C99 6.10.2p4.
-  CheckEndOfDirective(IncludeTok.getIdentifierInfo()->getName(), true);
+  CheckEndOfDirective(IncludeTok.getIdentifierInfo()->getNameStart(), true);
 
   // Check that we don't have infinite #include recursion.
   if (IncludeMacroStack.size() == MaxAllowedIncludeStackDepth-1) {
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index 8ca1ec0..f17a5d9 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -96,14 +96,6 @@
   //===--------------------------------------==//
   // Process the token.
   //===--------------------------------------==//
-#if 0
-  SourceManager& SM = PP->getSourceManager();
-  llvm::errs() << SM.getFileEntryForID(FileID)->getName()
-    << ':' << SM.getLogicalLineNumber(Tok.getLocation())
-    << ':' << SM.getLogicalColumnNumber(Tok.getLocation())
-    << '\n';
-#endif
-
   if (TKind == tok::eof) {
     // Save the end-of-file token.
     EofToken = Tok;
@@ -563,7 +555,7 @@
 
   // Store the new IdentifierInfo in the cache.
   PerIDCache[PersistentID] = II;
-  assert(II->getName() && II->getName()[0] != '\0');
+  assert(II->getNameStart() && II->getNameStart()[0] != '\0');
   return II;
 }
 
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index e41bc5c..7f3afc6 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -234,7 +234,7 @@
   // If this token is an identifier, just return the string from the identifier
   // table, which is very quick.
   if (const IdentifierInfo *II = Tok.getIdentifierInfo()) {
-    Buffer = II->getName();
+    Buffer = II->getNameStart();
     return II->getLength();
   }
 
diff --git a/lib/Lex/TokenConcatenation.cpp b/lib/Lex/TokenConcatenation.cpp
index ade7f85..0795164 100644
--- a/lib/Lex/TokenConcatenation.cpp
+++ b/lib/Lex/TokenConcatenation.cpp
@@ -95,7 +95,7 @@
 static char GetFirstChar(Preprocessor &PP, const Token &Tok) {
   if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
     // Avoid spelling identifiers, the most common form of token.
-    return II->getName()[0];
+    return II->getNameStart()[0];
   } else if (!Tok.needsCleaning()) {
     if (Tok.isLiteral() && Tok.getLiteralData()) {
       return *Tok.getLiteralData();
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 1d29f31..158cf1b 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -428,7 +428,7 @@
         return;
       }
 
-      if (II->getName()[0] == 's') {
+      if (II->getNameStart()[0] == 's') {
         DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter);
         DS.setSetterName(Tok.getIdentifierInfo());
         ConsumeToken();  // consume method name
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 3981b8d..3811513 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -235,8 +235,10 @@
     
     // Filter out names reserved for the implementation (C99 7.1.3, 
     // C++ [lib.global.names]). Users don't need to see those.
+    //
+    // FIXME: Add predicate for this.
     if (Id->getLength() >= 2) {
-      const char *Name = Id->getName();
+      const char *Name = Id->getNameStart();
       if (Name[0] == '_' &&
           (Name[1] == '_' || (Name[1] >= 'A' && Name[1] <= 'Z')))
         return;
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ad62ae7..8504701 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1885,7 +1885,7 @@
   const ExtVectorType *vecType = baseType->getAs<ExtVectorType>();
 
   // The vector accessor can't exceed the number of elements.
-  const char *compStr = CompName->getName();
+  const char *compStr = CompName->getNameStart();
 
   // This flag determines whether or not the component is one of the four
   // special names that indicate a subset of exactly half the elements are
@@ -1922,7 +1922,7 @@
   // Ensure no component accessor exceeds the width of the vector type it
   // operates on.
   if (!HalvingSwizzle) {
-    compStr = CompName->getName();
+    compStr = CompName->getNameStart();
 
     if (HexSwizzle)
       compStr++;