diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index fd54bcbf7c35..1f40db785981 100644 --- a/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/contrib/llvm-project/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -24,6 +24,7 @@ #include "clang/Lex/Lexer.h" #include "clang/Rewrite/Core/Rewriter.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/MemoryBuffer.h" @@ -599,8 +600,8 @@ namespace { StringLiteral *getStringLiteral(StringRef Str) { QualType StrType = Context->getConstantArrayType( Context->CharTy, llvm::APInt(32, Str.size() + 1), nullptr, - ArrayType::Normal, 0); - return StringLiteral::Create(*Context, Str, StringLiteral::Ascii, + ArraySizeModifier::Normal, 0); + return StringLiteral::Create(*Context, Str, StringLiteralKind::Ordinary, /*Pascal=*/false, StrType, SourceLocation()); } }; @@ -633,7 +634,7 @@ static bool IsHeaderFile(const std::string &Filename) { return false; } - std::string Ext = std::string(Filename.begin()+DotPos+1, Filename.end()); + std::string Ext = Filename.substr(DotPos + 1); // C header: .h // C++ header: .hh or .H; return Ext == "h" || Ext == "hh" || Ext == "H"; @@ -852,7 +853,7 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) { if (D->isBitField()) IvarT = GetGroupRecordTypeForObjCIvarBitfield(D); - if (!isa<TypedefType>(IvarT) && IvarT->isRecordType()) { + if (!IvarT->getAs<TypedefType>() && IvarT->isRecordType()) { RecordDecl *RD = IvarT->castAs<RecordType>()->getDecl(); RD = RD->getDefinition(); if (RD && !RD->getDeclName().getAsIdentifierInfo()) { @@ -863,9 +864,9 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) { CDecl = CatDecl->getClassInterface(); std::string RecName = std::string(CDecl->getName()); RecName += "_IMPL"; - RecordDecl *RD = - RecordDecl::Create(*Context, TTK_Struct, TUDecl, SourceLocation(), - SourceLocation(), &Context->Idents.get(RecName)); + RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, + SourceLocation(), SourceLocation(), + &Context->Idents.get(RecName)); QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD)); unsigned UnsignedIntSize = static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy)); @@ -1957,15 +1958,15 @@ Stmt *RewriteModernObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) { // @try -> try ReplaceText(startLoc, 1, ""); - for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) { - ObjCAtCatchStmt *Catch = S->getCatchStmt(I); + for (ObjCAtCatchStmt *Catch : S->catch_stmts()) { VarDecl *catchDecl = Catch->getCatchParamDecl(); startLoc = Catch->getBeginLoc(); bool AtRemoved = false; if (catchDecl) { QualType t = catchDecl->getType(); - if (const ObjCObjectPointerType *Ptr = t->getAs<ObjCObjectPointerType>()) { + if (const ObjCObjectPointerType *Ptr = + t->getAs<ObjCObjectPointerType>()) { // Should be a pointer to a class. ObjCInterfaceDecl *IDecl = Ptr->getObjectType()->getInterface(); if (IDecl) { @@ -2977,9 +2978,9 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral // }; QualType RewriteModernObjC::getSuperStructType() { if (!SuperStructDecl) { - SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - &Context->Idents.get("__rw_objc_super")); + SuperStructDecl = RecordDecl::Create( + *Context, TagTypeKind::Struct, TUDecl, SourceLocation(), + SourceLocation(), &Context->Idents.get("__rw_objc_super")); QualType FieldTypes[2]; // struct objc_object *object; @@ -3005,9 +3006,9 @@ QualType RewriteModernObjC::getSuperStructType() { QualType RewriteModernObjC::getConstantStringStructType() { if (!ConstantStringDecl) { - ConstantStringDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - &Context->Idents.get("__NSConstantStringImpl")); + ConstantStringDecl = RecordDecl::Create( + *Context, TagTypeKind::Struct, TUDecl, SourceLocation(), + SourceLocation(), &Context->Idents.get("__NSConstantStringImpl")); QualType FieldTypes[4]; // struct objc_object *receiver; @@ -3628,7 +3629,7 @@ bool RewriteModernObjC::IsTagDefinedInsideClass(ObjCContainerDecl *IDecl, /// It handles elaborated types, as well as enum types in the process. bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type, std::string &Result) { - if (isa<TypedefType>(Type)) { + if (Type->getAs<TypedefType>()) { Result += "\t"; return false; } @@ -3723,7 +3724,7 @@ void RewriteModernObjC::RewriteObjCFieldDecl(FieldDecl *fieldDecl, void RewriteModernObjC::RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDecl, std::string &Result) { QualType Type = fieldDecl->getType(); - if (isa<TypedefType>(Type)) + if (Type->getAs<TypedefType>()) return; if (Type->isArrayType()) Type = Context->getBaseElementType(Type); @@ -3781,10 +3782,9 @@ QualType RewriteModernObjC::SynthesizeBitfieldGroupStructType( SmallVectorImpl<ObjCIvarDecl *> &IVars) { std::string StructTagName; ObjCIvarBitfieldGroupType(IV, StructTagName); - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, - Context->getTranslationUnitDecl(), - SourceLocation(), SourceLocation(), - &Context->Idents.get(StructTagName)); + RecordDecl *RD = RecordDecl::Create( + *Context, TagTypeKind::Struct, Context->getTranslationUnitDecl(), + SourceLocation(), SourceLocation(), &Context->Idents.get(StructTagName)); for (unsigned i=0, e = IVars.size(); i < e; i++) { ObjCIvarDecl *Ivar = IVars[i]; RD->addDecl(FieldDecl::Create(*Context, RD, SourceLocation(), SourceLocation(), @@ -4587,7 +4587,7 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT); // FTP will be null for closures that don't take arguments. - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, + RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, SourceLocation(), SourceLocation(), &Context->Idents.get("__block_impl")); QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD)); @@ -5346,9 +5346,9 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, RewriteByRefString(RecName, Name, ND, true); IdentifierInfo *II = &Context->Idents.get(RecName.c_str() + sizeof("struct")); - RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl, - SourceLocation(), SourceLocation(), - II); + RecordDecl *RD = + RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl, + SourceLocation(), SourceLocation(), II); assert(RD && "SynthBlockInitExpr(): Can't find RecordDecl"); QualType castT = Context->getPointerType(Context->getTagDeclType(RD)); @@ -5356,16 +5356,15 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp, Exp = new (Context) DeclRefExpr(*Context, FD, false, FD->getType(), VK_LValue, SourceLocation()); bool isNestedCapturedVar = false; - if (block) - for (const auto &CI : block->captures()) { - const VarDecl *variable = CI.getVariable(); - if (variable == ND && CI.isNested()) { - assert (CI.isByRef() && - "SynthBlockInitExpr - captured block variable is not byref"); - isNestedCapturedVar = true; - break; - } + for (const auto &CI : block->captures()) { + const VarDecl *variable = CI.getVariable(); + if (variable == ND && CI.isNested()) { + assert(CI.isByRef() && + "SynthBlockInitExpr - captured block variable is not byref"); + isNestedCapturedVar = true; + break; } + } // captured nested byref variable has its address passed. Do not take // its address again. if (!isNestedCapturedVar) @@ -6723,7 +6722,7 @@ static void Write_IvarOffsetVar(RewriteModernObjC &RewriteObj, std::string &Result, ArrayRef<ObjCIvarDecl *> Ivars, ObjCInterfaceDecl *CDecl) { - // FIXME. visibilty of offset symbols may have to be set; for Darwin + // FIXME. visibility of offset symbols may have to be set; for Darwin // this is what happens: /** if (Ivar->getAccessControl() == ObjCIvarDecl::Private || @@ -6855,7 +6854,7 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, std::vector<ObjCMethodDecl *> InstanceMethods, ClassMethods; std::vector<ObjCMethodDecl *> OptInstanceMethods, OptClassMethods; for (auto *MD : PDecl->instance_methods()) { - if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { + if (MD->getImplementationControl() == ObjCImplementationControl::Optional) { OptInstanceMethods.push_back(MD); } else { InstanceMethods.push_back(MD); @@ -6863,7 +6862,7 @@ void RewriteModernObjC::RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, } for (auto *MD : PDecl->class_methods()) { - if (MD->getImplementationControl() == ObjCMethodDecl::Optional) { + if (MD->getImplementationControl() == ObjCImplementationControl::Optional) { OptClassMethods.push_back(MD); } else { ClassMethods.push_back(MD); @@ -7496,7 +7495,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { if (D->isBitField()) IvarT = GetGroupRecordTypeForObjCIvarBitfield(D); - if (!isa<TypedefType>(IvarT) && IvarT->isRecordType()) { + if (!IvarT->getAs<TypedefType>() && IvarT->isRecordType()) { RecordDecl *RD = IvarT->castAs<RecordType>()->getDecl(); RD = RD->getDefinition(); if (RD && !RD->getDeclName().getAsIdentifierInfo()) { @@ -7508,8 +7507,8 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { std::string RecName = std::string(CDecl->getName()); RecName += "_IMPL"; RecordDecl *RD = RecordDecl::Create( - *Context, TTK_Struct, TUDecl, SourceLocation(), SourceLocation(), - &Context->Idents.get(RecName)); + *Context, TagTypeKind::Struct, TUDecl, SourceLocation(), + SourceLocation(), &Context->Idents.get(RecName)); QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD)); unsigned UnsignedIntSize = static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy)); |