clang 19.0.0git
Classes | Namespaces | Functions
ObjCMT.cpp File Reference
#include "Transforms.h"
#include "clang/Analysis/RetainSummaryManager.h"
#include "clang/ARCMigrate/ARCMT.h"
#include "clang/ARCMigrate/ARCMTActions.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/NSAPI.h"
#include "clang/AST/ParentMap.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
#include "clang/Basic/FileManager.h"
#include "clang/Edit/Commit.h"
#include "clang/Edit/EditedSource.h"
#include "clang/Edit/EditsReceiver.h"
#include "clang/Edit/Rewriters.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/MultiplexConsumer.h"
#include "clang/Lex/PPConditionalDirectiveRecord.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/YAMLParser.h"

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< EditEntry >
 

Namespaces

namespace  llvm
 YAML serialization mapping.
 

Functions

static void append_attr (std::string &PropertyString, const char *attr, bool &LParenAdded)
 
static void MigrateBlockOrFunctionPointerTypeVariable (std::string &PropertyString, const std::string &TypeString, const char *name)
 
static const char * PropertyMemoryAttribute (ASTContext &Context, QualType ArgType)
 
static void rewriteToObjCProperty (const ObjCMethodDecl *Getter, const ObjCMethodDecl *Setter, const NSAPI &NS, edit::Commit &commit, unsigned LengthOfPrefix, bool Atomic, bool UseNsIosOnlyMacro, bool AvailabilityArgsMatch)
 
static bool IsCategoryNameWithDeprecatedSuffix (ObjCContainerDecl *D)
 
static bool ClassImplementsAllMethodsAndProperties (ASTContext &Ctx, const ObjCImplementationDecl *ImpDecl, const ObjCInterfaceDecl *IDecl, ObjCProtocolDecl *Protocol)
 
static bool rewriteToObjCInterfaceDecl (const ObjCInterfaceDecl *IDecl, llvm::SmallVectorImpl< ObjCProtocolDecl * > &ConformingProtocols, const NSAPI &NS, edit::Commit &commit)
 
static StringRef GetUnsignedName (StringRef NSIntegerName)
 
static bool rewriteToNSEnumDecl (const EnumDecl *EnumDcl, const TypedefDecl *TypedefDcl, const NSAPI &NS, edit::Commit &commit, StringRef NSIntegerName, bool NSOptions)
 
static void rewriteToNSMacroDecl (ASTContext &Ctx, const EnumDecl *EnumDcl, const TypedefDecl *TypedefDcl, const NSAPI &NS, edit::Commit &commit, bool IsNSIntegerType)
 
static bool UseNSOptionsMacro (Preprocessor &PP, ASTContext &Ctx, const EnumDecl *EnumDcl)
 
static void ReplaceWithInstancetype (ASTContext &Ctx, const ObjCMigrateASTConsumer &ASTC, ObjCMethodDecl *OM)
 
static void ReplaceWithClasstype (const ObjCMigrateASTConsumer &ASTC, ObjCMethodDecl *OM)
 
static bool TypeIsInnerPointer (QualType T)
 
static bool versionsMatch (const VersionTuple &X, const VersionTuple &Y)
 Check whether the two versions match.
 
static bool AvailabilityAttrsMatch (Attr *At1, Attr *At2)
 AvailabilityAttrsMatch - This routine checks that if comparing two availability attributes, all their components match.
 
static bool MatchTwoAttributeLists (const AttrVec &Attrs1, const AttrVec &Attrs2, bool &AvailabilityArgsMatch)
 
static bool AttributesMatch (const Decl *Decl1, const Decl *Decl2, bool &AvailabilityArgsMatch)
 AttributesMatch - This routine checks list of attributes for two decls.
 
static bool IsValidIdentifier (ASTContext &Ctx, const char *Name)
 
static bool IsVoidStarType (QualType Ty)
 
static bool AuditedType (QualType AT)
 AuditedType - This routine audits the type AT and returns false if it is one of known CF object types or of the "void *" variety.
 
static bool hasSuperInitCall (const ObjCMethodDecl *MD)
 
static std::vector< std::string > getAllowListFilenames (StringRef DirPath)
 
static bool reportDiag (const Twine &Err, DiagnosticsEngine &Diag)
 
static std::string applyEditsToTemp (FileEntryRef FE, ArrayRef< EditEntry > Edits, FileManager &FileMgr, DiagnosticsEngine &Diag)
 

Function Documentation

◆ append_attr()

static void append_attr ( std::string &  PropertyString,
const char *  attr,
bool LParenAdded 
)
static

Definition at line 383 of file ObjCMT.cpp.

References clang::ast_matchers::attr.

Referenced by rewriteToObjCProperty().

◆ applyEditsToTemp()

static std::string applyEditsToTemp ( FileEntryRef  FE,
ArrayRef< EditEntry >  Edits,
FileManager FileMgr,
DiagnosticsEngine Diag 
)
static

◆ AttributesMatch()

static bool AttributesMatch ( const Decl Decl1,
const Decl Decl2,
bool AvailabilityArgsMatch 
)
static

AttributesMatch - This routine checks list of attributes for two decls.

It returns false, if there is a mismatch in kind of attributes seen in the decls. It returns true if the two decls have list of same kind of attributes. Furthermore, when there are availability attributes in the two decls, it sets the AvailabilityArgsMatch to false if availability attributes have different versions, etc.

Definition at line 1126 of file ObjCMT.cpp.

References clang::Decl::getAttrs(), clang::Decl::hasAttrs(), clang::ast_matchers::match(), and MatchTwoAttributeLists().

◆ AuditedType()

static bool AuditedType ( QualType  AT)
static

AuditedType - This routine audits the type AT and returns false if it is one of known CF object types or of the "void *" variety.

It returns true if we don't care about the type such as a non-pointer or pointers which have no ownership issues (such as "int *").

Definition at line 1366 of file ObjCMT.cpp.

References clang::Type::isAnyPointerType(), clang::Type::isBlockPointerType(), clang::ento::coreFoundation::isCFObjectRef(), clang::Type::isObjCBuiltinType(), clang::Type::isObjCObjectPointerType(), and IsVoidStarType().

◆ AvailabilityAttrsMatch()

static bool AvailabilityAttrsMatch ( Attr At1,
Attr At2 
)
static

AvailabilityAttrsMatch - This routine checks that if comparing two availability attributes, all their components match.

It returns true, if not dealing with availability or when all components of availability attributes match. This routine is only called when the attributes are of the same kind.

Definition at line 1077 of file ObjCMT.cpp.

References versionsMatch().

Referenced by MatchTwoAttributeLists().

◆ ClassImplementsAllMethodsAndProperties()

static bool ClassImplementsAllMethodsAndProperties ( ASTContext Ctx,
const ObjCImplementationDecl ImpDecl,
const ObjCInterfaceDecl IDecl,
ObjCProtocolDecl Protocol 
)
static

◆ getAllowListFilenames()

static std::vector< std::string > getAllowListFilenames ( StringRef  DirPath)
static

Definition at line 1984 of file ObjCMT.cpp.

Referenced by clang::arcmt::MigrateSourceAction::CreateASTConsumer().

◆ GetUnsignedName()

static StringRef GetUnsignedName ( StringRef  NSIntegerName)
static

Definition at line 691 of file ObjCMT.cpp.

Referenced by rewriteToNSEnumDecl().

◆ hasSuperInitCall()

static bool hasSuperInitCall ( const ObjCMethodDecl MD)
static

Definition at line 1688 of file ObjCMT.cpp.

References clang::ObjCMethodDecl::getBody().

◆ IsCategoryNameWithDeprecatedSuffix()

static bool IsCategoryNameWithDeprecatedSuffix ( ObjCContainerDecl D)
static

Definition at line 562 of file ObjCMT.cpp.

◆ IsValidIdentifier()

static bool IsValidIdentifier ( ASTContext Ctx,
const char *  Name 
)
static

◆ IsVoidStarType()

static bool IsVoidStarType ( QualType  Ty)
static

◆ MatchTwoAttributeLists()

static bool MatchTwoAttributeLists ( const AttrVec Attrs1,
const AttrVec Attrs2,
bool AvailabilityArgsMatch 
)
static

Definition at line 1097 of file ObjCMT.cpp.

References AvailabilityAttrsMatch(), getKind(), and clang::ast_matchers::match().

Referenced by AttributesMatch().

◆ MigrateBlockOrFunctionPointerTypeVariable()

static void MigrateBlockOrFunctionPointerTypeVariable ( std::string &  PropertyString,
const std::string &  TypeString,
const char *  name 
)
static

Definition at line 395 of file ObjCMT.cpp.

Referenced by rewriteToObjCProperty().

◆ PropertyMemoryAttribute()

static const char * PropertyMemoryAttribute ( ASTContext Context,
QualType  ArgType 
)
static

◆ ReplaceWithClasstype()

static void ReplaceWithClasstype ( const ObjCMigrateASTConsumer &  ASTC,
ObjCMethodDecl OM 
)
static

◆ ReplaceWithInstancetype()

static void ReplaceWithInstancetype ( ASTContext Ctx,
const ObjCMigrateASTConsumer &  ASTC,
ObjCMethodDecl OM 
)
static

◆ reportDiag()

static bool reportDiag ( const Twine &  Err,
DiagnosticsEngine Diag 
)
static

Definition at line 2143 of file ObjCMT.cpp.

References Diag(), and clang::DiagnosticsEngine::Error.

Referenced by applyEditsToTemp().

◆ rewriteToNSEnumDecl()

static bool rewriteToNSEnumDecl ( const EnumDecl EnumDcl,
const TypedefDecl TypedefDcl,
const NSAPI NS,
edit::Commit commit,
StringRef  NSIntegerName,
bool  NSOptions 
)
static

◆ rewriteToNSMacroDecl()

static void rewriteToNSMacroDecl ( ASTContext Ctx,
const EnumDecl EnumDcl,
const TypedefDecl TypedefDcl,
const NSAPI NS,
edit::Commit commit,
bool  IsNSIntegerType 
)
static

◆ rewriteToObjCInterfaceDecl()

static bool rewriteToObjCInterfaceDecl ( const ObjCInterfaceDecl IDecl,
llvm::SmallVectorImpl< ObjCProtocolDecl * > &  ConformingProtocols,
const NSAPI NS,
edit::Commit commit 
)
static

◆ rewriteToObjCProperty()

static void rewriteToObjCProperty ( const ObjCMethodDecl Getter,
const ObjCMethodDecl Setter,
const NSAPI NS,
edit::Commit commit,
unsigned  LengthOfPrefix,
bool  Atomic,
bool  UseNsIosOnlyMacro,
bool  AvailabilityArgsMatch 
)
static

◆ TypeIsInnerPointer()

static bool TypeIsInnerPointer ( QualType  T)
static

◆ UseNSOptionsMacro()

static bool UseNSOptionsMacro ( Preprocessor PP,
ASTContext Ctx,
const EnumDecl EnumDcl 
)
static

◆ versionsMatch()

static bool versionsMatch ( const VersionTuple &  X,
const VersionTuple &  Y 
)
static

Check whether the two versions match.

Definition at line 1068 of file ObjCMT.cpp.

References X.

Referenced by AvailabilityAttrsMatch(), and clang::Sema::mergeAvailabilityAttr().