#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"
usingnamespaceclang;
usingnamespacearcmt;
usingnamespaceento;
RewriteBuffer;
namespace {
class ObjCMigrateASTConsumer : public ASTConsumer { … };
}
ObjCMigrateAction::ObjCMigrateAction(
std::unique_ptr<FrontendAction> WrappedAction, StringRef migrateDir,
unsigned migrateAction)
: … { … }
std::unique_ptr<ASTConsumer>
ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { … }
bool ObjCMigrateAction::BeginInvocation(CompilerInstance &CI) { … }
namespace {
bool subscriptOperatorNeedsParens(const Expr *FullExpr) { … }
bool rewriteToPropertyDotSyntax(const ObjCMessageExpr *Msg,
Preprocessor &PP,
const NSAPI &NS, edit::Commit &commit,
const ParentMap *PMap) { … }
class ObjCMigrator : public RecursiveASTVisitor<ObjCMigrator> { … };
class BodyMigrator : public RecursiveASTVisitor<BodyMigrator> { … };
}
void ObjCMigrateASTConsumer::migrateDecl(Decl *D) { … }
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) { … }
void ObjCMigrateASTConsumer::migrateObjCContainerDecl(ASTContext &Ctx,
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) { … }
void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
const ObjCImplementationDecl *ImpDecl) { … }
void ObjCMigrateASTConsumer::CacheObjCNSIntegerTypedefed(
const TypedefDecl *TypedefDcl) { … }
bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
const EnumDecl *EnumDcl,
const TypedefDecl *TypedefDcl) { … }
static void ReplaceWithInstancetype(ASTContext &Ctx,
const ObjCMigrateASTConsumer &ASTC,
ObjCMethodDecl *OM) { … }
static void ReplaceWithClasstype(const ObjCMigrateASTConsumer &ASTC,
ObjCMethodDecl *OM) { … }
void ObjCMigrateASTConsumer::migrateMethodInstanceType(ASTContext &Ctx,
ObjCContainerDecl *CDecl,
ObjCMethodDecl *OM) { … }
static bool TypeIsInnerPointer(QualType T) { … }
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y) { … }
static bool AvailabilityAttrsMatch(Attr *At1, Attr *At2) { … }
static bool MatchTwoAttributeLists(const AttrVec &Attrs1, const AttrVec &Attrs2,
bool &AvailabilityArgsMatch) { … }
static bool AttributesMatch(const Decl *Decl1, const Decl *Decl2,
bool &AvailabilityArgsMatch) { … }
static bool IsValidIdentifier(ASTContext &Ctx,
const char *Name) { … }
bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
ObjCContainerDecl *D,
ObjCMethodDecl *Method) { … }
void ObjCMigrateASTConsumer::migrateNsReturnsInnerPointer(ASTContext &Ctx,
ObjCMethodDecl *OM) { … }
void ObjCMigrateASTConsumer::migratePropertyNsReturnsInnerPointer(ASTContext &Ctx,
ObjCPropertyDecl *P) { … }
void ObjCMigrateASTConsumer::migrateAllMethodInstaceType(ASTContext &Ctx,
ObjCContainerDecl *CDecl) { … }
void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
ObjCContainerDecl *CDecl,
ObjCMethodDecl *OM,
ObjCInstanceTypeFamily OIT_Family) { … }
static bool IsVoidStarType(QualType Ty) { … }
static bool AuditedType (QualType AT) { … }
void ObjCMigrateASTConsumer::AnnotateImplicitBridging(ASTContext &Ctx) { … }
void ObjCMigrateASTConsumer::migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl) { … }
void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
const RetainSummary *RS,
const FunctionDecl *FuncDecl,
bool ResultAnnotated) { … }
ObjCMigrateASTConsumer::CF_BRIDGING_KIND
ObjCMigrateASTConsumer::migrateAddFunctionAnnotation(
ASTContext &Ctx,
const FunctionDecl *FuncDecl) { … }
void ObjCMigrateASTConsumer::migrateARCSafeAnnotation(ASTContext &Ctx,
ObjCContainerDecl *CDecl) { … }
void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
const RetainSummary *RS,
const ObjCMethodDecl *MethodDecl,
bool ResultAnnotated) { … }
void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
ASTContext &Ctx,
const ObjCMethodDecl *MethodDecl) { … }
namespace {
class SuperInitChecker : public RecursiveASTVisitor<SuperInitChecker> { … };
}
static bool hasSuperInitCall(const ObjCMethodDecl *MD) { … }
void ObjCMigrateASTConsumer::inferDesignatedInitializers(
ASTContext &Ctx,
const ObjCImplementationDecl *ImplD) { … }
bool ObjCMigrateASTConsumer::InsertFoundation(ASTContext &Ctx,
SourceLocation Loc) { … }
namespace {
class RewritesReceiver : public edit::EditsReceiver { … };
class JSONEditWriter : public edit::EditsReceiver { … };
}
void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { … }
bool MigrateSourceAction::BeginInvocation(CompilerInstance &CI) { … }
static std::vector<std::string> getAllowListFilenames(StringRef DirPath) { … }
std::unique_ptr<ASTConsumer>
MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { … }
namespace {
struct EditEntry { … };
}
namespace llvm {
template<> struct DenseMapInfo<EditEntry> { … };
}
namespace {
class RemapFileParser { … };
}
static bool reportDiag(const Twine &Err, DiagnosticsEngine &Diag) { … }
static std::string applyEditsToTemp(FileEntryRef FE,
ArrayRef<EditEntry> Edits,
FileManager &FileMgr,
DiagnosticsEngine &Diag) { … }
bool arcmt::getFileRemappingsFromFileList(
std::vector<std::pair<std::string,std::string> > &remap,
ArrayRef<StringRef> remapFiles,
DiagnosticConsumer *DiagClient) { … }