зеркало из https://github.com/microsoft/clang-1.git
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:
Родитель
fa4f55067b
Коммит
01eb9b9683
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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()), "//");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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("__"))
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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("__"))
|
||||
|
|
Загрузка…
Ссылка в новой задаче