aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authoryronglin <yronglin777@gmail.com>2025-04-16 20:53:25 +0800
committerGitHub <noreply@github.com>2025-04-16 20:53:25 +0800
commitd3153ad66c539ad146062b6e65741901e5b5e1cc (patch)
tree2e2340c0ef9215149ec7f46256830437e5e547fb /clang/lib/Sema/SemaDeclObjC.cpp
parentfe4a31d59db7b18dc45c3593bf100c101e725b79 (diff)
downloadllvm-d3153ad66c539ad146062b6e65741901e5b5e1cc.zip
llvm-d3153ad66c539ad146062b6e65741901e5b5e1cc.tar.gz
llvm-d3153ad66c539ad146062b6e65741901e5b5e1cc.tar.bz2
[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (#135808)
I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - `std::pair<IdentifierInfo *, SourceLocation>`. - Element type of `ModuleIdPath`. - `IdentifierLocPair`. - `IdentifierLoc`. This PR unify these data structures to `IdentifierLoc`, moved `IdentifierLoc` definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index ba9d3dc..0a14ce2 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1310,24 +1310,26 @@ static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl,
/// protocol declarations in its 'Protocols' argument.
void SemaObjC::FindProtocolDeclaration(bool WarnOnDeclarations,
bool ForObjCContainer,
- ArrayRef<IdentifierLocPair> ProtocolId,
+ ArrayRef<IdentifierLoc> ProtocolId,
SmallVectorImpl<Decl *> &Protocols) {
- for (const IdentifierLocPair &Pair : ProtocolId) {
- ObjCProtocolDecl *PDecl = LookupProtocol(Pair.first, Pair.second);
+ for (const IdentifierLoc &Pair : ProtocolId) {
+ ObjCProtocolDecl *PDecl =
+ LookupProtocol(Pair.getIdentifierInfo(), Pair.getLoc());
if (!PDecl) {
DeclFilterCCC<ObjCProtocolDecl> CCC{};
- TypoCorrection Corrected =
- SemaRef.CorrectTypo(DeclarationNameInfo(Pair.first, Pair.second),
- Sema::LookupObjCProtocolName, SemaRef.TUScope,
- nullptr, CCC, Sema::CTK_ErrorRecovery);
+ TypoCorrection Corrected = SemaRef.CorrectTypo(
+ DeclarationNameInfo(Pair.getIdentifierInfo(), Pair.getLoc()),
+ Sema::LookupObjCProtocolName, SemaRef.TUScope, nullptr, CCC,
+ Sema::CTK_ErrorRecovery);
if ((PDecl = Corrected.getCorrectionDeclAs<ObjCProtocolDecl>()))
SemaRef.diagnoseTypo(Corrected,
PDiag(diag::err_undeclared_protocol_suggest)
- << Pair.first);
+ << Pair.getIdentifierInfo());
}
if (!PDecl) {
- Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
+ Diag(Pair.getLoc(), diag::err_undeclared_protocol)
+ << Pair.getIdentifierInfo();
continue;
}
// If this is a forward protocol declaration, get its definition.
@@ -1337,7 +1339,7 @@ void SemaObjC::FindProtocolDeclaration(bool WarnOnDeclarations,
// For an objc container, delay protocol reference checking until after we
// can set the objc decl as the availability context, otherwise check now.
if (!ForObjCContainer) {
- (void)SemaRef.DiagnoseUseOfDecl(PDecl, Pair.second);
+ (void)SemaRef.DiagnoseUseOfDecl(PDecl, Pair.getLoc());
}
// If this is a forward declaration and we are supposed to warn in this
@@ -1347,7 +1349,8 @@ void SemaObjC::FindProtocolDeclaration(bool WarnOnDeclarations,
if (WarnOnDeclarations &&
NestedProtocolHasNoDefinition(PDecl, UndefinedProtocol)) {
- Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
+ Diag(Pair.getLoc(), diag::warn_undef_protocolref)
+ << Pair.getIdentifierInfo();
Diag(UndefinedProtocol->getLocation(), diag::note_protocol_decl_undefined)
<< UndefinedProtocol;
}
@@ -1784,17 +1787,17 @@ void SemaObjC::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
/// ActOnForwardProtocolDeclaration - Handle \@protocol foo;
SemaObjC::DeclGroupPtrTy SemaObjC::ActOnForwardProtocolDeclaration(
- SourceLocation AtProtocolLoc, ArrayRef<IdentifierLocPair> IdentList,
+ SourceLocation AtProtocolLoc, ArrayRef<IdentifierLoc> IdentList,
const ParsedAttributesView &attrList) {
ASTContext &Context = getASTContext();
SmallVector<Decl *, 8> DeclsInGroup;
- for (const IdentifierLocPair &IdentPair : IdentList) {
- IdentifierInfo *Ident = IdentPair.first;
+ for (const IdentifierLoc &IdentPair : IdentList) {
+ IdentifierInfo *Ident = IdentPair.getIdentifierInfo();
ObjCProtocolDecl *PrevDecl = LookupProtocol(
- Ident, IdentPair.second, SemaRef.forRedeclarationInCurContext());
+ Ident, IdentPair.getLoc(), SemaRef.forRedeclarationInCurContext());
ObjCProtocolDecl *PDecl =
ObjCProtocolDecl::Create(Context, SemaRef.CurContext, Ident,
- IdentPair.second, AtProtocolLoc, PrevDecl);
+ IdentPair.getLoc(), AtProtocolLoc, PrevDecl);
SemaRef.PushOnScopeChains(PDecl, SemaRef.TUScope);
CheckObjCDeclScope(PDecl);