clang
10.0.0git
|
#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 | |
llvm | |
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion. | |
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. More... | |
static bool | AvailabilityAttrsMatch (Attr *At1, Attr *At2) |
AvailabilityAttrsMatch - This routine checks that if comparing two availability attributes, all their components match. More... | |
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. More... | |
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. More... | |
static bool | hasSuperInitCall (const ObjCMethodDecl *MD) |
static std::vector< std::string > | getWhiteListFilenames (StringRef DirPath) |
static bool | reportDiag (const Twine &Err, DiagnosticsEngine &Diag) |
static std::string | applyEditsToTemp (const FileEntry *FE, ArrayRef< EditEntry > Edits, FileManager &FileMgr, DiagnosticsEngine &Diag) |
|
static |
Definition at line 394 of file ObjCMT.cpp.
Referenced by rewriteToObjCProperty().
|
static |
Definition at line 2172 of file ObjCMT.cpp.
References clang::edit::EditedSource::applyRewrites(), clang::SrcMgr::C_User, clang::edit::EditedSource::commit(), clang::SourceManager::createFileID(), Diag(), clang::CharSourceRange::getCharRange(), clang::SourceManager::getLocForStartOfFile(), clang::SourceLocation::getLocWithOffset(), clang::FileEntry::getName(), clang::Rewriter::getRewriteBufferFor(), clang::CharSourceRange::isInvalid(), clang::ento::OS, reportDiag(), SM, and clang::RewriteBuffer::write().
Referenced by clang::arcmt::getFileRemappingsFromFileList().
|
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 1140 of file ObjCMT.cpp.
References clang::Decl::getAttrs(), clang::Decl::hasAttrs(), clang::ast_matchers::match(), and MatchTwoAttributeLists().
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 1383 of file ObjCMT.cpp.
References clang::ento::DecRef, clang::Decl::getBeginLoc(), clang::ObjCMethodDecl::getEndLoc(), clang::Decl::getEndLoc(), clang::SourceManager::getFileID(), clang::ento::ArgEffect::getKind(), clang::Token::getLocation(), clang::Decl::getLocation(), clang::Preprocessor::getLocForEndOfToken(), clang::ObjCMethodDecl::getMethodFamily(), clang::ObjCMessageExpr::getMethodFamily(), clang::FunctionDecl::getNumParams(), clang::ento::ArgEffect::getObjKind(), clang::ento::RetEffect::getObjKind(), clang::Preprocessor::getRawToken(), clang::ObjCMessageExpr::getReceiverKind(), clang::ObjCMethodDecl::getReturnType(), clang::FunctionDecl::getReturnType(), clang::Preprocessor::getSourceManager(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::ObjCMethodDecl::hasBody(), clang::FunctionDecl::hasBody(), clang::ento::IncRef, clang::edit::Commit::insertAfterToken(), clang::edit::Commit::insertBefore(), clang::Type::isAnyPointerType(), clang::Type::isBlockPointerType(), clang::ento::coreFoundation::isCFObjectRef(), clang::Decl::isDeprecated(), clang::Decl::isImplicit(), clang::FileID::isInvalid(), clang::Type::isObjCBuiltinType(), clang::Type::isObjCObjectPointerType(), clang::ento::RetEffect::isOwned(), IsVoidStarType(), clang::ObjCContainerDecl::methods(), clang::ento::RetEffect::notOwned(), clang::ObjC, clang::OMF_alloc, clang::OMF_copy, clang::OMF_init, clang::OMF_mutableCopy, clang::OMF_new, clang::OMF_release, clang::ObjCMethodDecl::param_begin(), clang::FunctionDecl::param_begin(), clang::ObjCMethodDecl::param_end(), clang::FunctionDecl::param_end(), Ret(), clang::ObjCMessageExpr::SuperInstance, and clang::format::Tok.
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 1091 of file ObjCMT.cpp.
References versionsMatch().
Referenced by MatchTwoAttributeLists().
|
static |
Definition at line 610 of file ObjCMT.cpp.
References clang::ObjCImplDecl::FindPropertyImplDecl(), clang::ObjCProtocolDecl::getDefinition(), clang::ASTContext::hasSameType(), clang::DeclContext::lookup(), clang::ast_matchers::match(), clang::ASTContext::ObjCMethodsAreEqual(), clang::ObjCMethodDecl::Optional, clang::ObjCPropertyDecl::Optional, clang::Property, and clang::DeclContextLookupResult::size().
Referenced by UseNSOptionsMacro().
|
static |
Definition at line 705 of file ObjCMT.cpp.
Referenced by rewriteToNSEnumDecl().
|
static |
Definition at line 2000 of file ObjCMT.cpp.
Referenced by clang::arcmt::MigrateSourceAction::CreateASTConsumer().
|
static |
Definition at line 1705 of file ObjCMT.cpp.
References Begin, clang::DeclContext::decls_begin(), clang::DeclContext::decls_end(), End, clang::DiagnosticsEngine::Error, clang::FileManager::FixupRelativePath(), clang::arcmt::FileRemapper::flushToDisk(), clang::arcmt::FileRemapper::flushToFile(), clang::IdentifierTable::get(), clang::CharSourceRange::getBegin(), clang::ObjCMethodDecl::getBody(), clang::ObjCImplDecl::getClassInterface(), clang::DiagnosticsEngine::getCustomDiagID(), clang::SourceManager::getDecomposedLoc(), clang::ASTContext::getDiagnostics(), clang::CharSourceRange::getEnd(), clang::ObjCMethodDecl::getEndLoc(), clang::SourceManager::getFileEntryForID(), clang::SourceManager::getFileID(), clang::ASTContext::getLangOpts(), clang::Preprocessor::getMacroDefinitionAtLoc(), clang::ObjCContainerDecl::getMethod(), clang::FileEntry::getName(), clang::Rewriter::getRangeSize(), clang::ASTContext::getSourceManager(), clang::Preprocessor::getSourceManager(), clang::ASTContext::getTranslationUnitDecl(), clang::ObjCInterfaceDecl::hasDesignatedInitializers(), clang::ASTContext::Idents, clang::edit::Commit::insert(), clang::Rewriter::InsertText(), clang::ObjCContainerDecl::instance_methods(), clang::CharSourceRange::isCharRange(), clang::SourceLocation::isInvalid(), clang::FileID::isValid(), clang::FrontendOptions::ObjCMT_Annotation, clang::FrontendOptions::ObjCMT_DesignatedInitializer, clang::FrontendOptions::ObjCMT_Instancetype, clang::FrontendOptions::ObjCMT_MigrateDecls, clang::FrontendOptions::ObjCMT_NsMacros, clang::FrontendOptions::ObjCMT_ProtocolConformance, Offset, clang::OMF_init, clang::ento::OS, clang::transformer::range(), clang::arcmt::FileRemapper::remap(), clang::Rewriter::ReplaceText(), clang::DiagnosticsEngine::Report(), SM, clang::comments::tok::text, Text, and clang::RewriteBuffer::write().
|
static |
Definition at line 574 of file ObjCMT.cpp.
|
static |
Definition at line 1155 of file ObjCMT.cpp.
Definition at line 1366 of file ObjCMT.cpp.
References clang::Type::castAs(), clang::PointerType::getPointeeType(), clang::QualType::getTypePtr(), clang::QualType::getUnqualifiedType(), clang::Type::isPointerType(), and clang::Type::isVoidType().
Referenced by AuditedType().
|
static |
Definition at line 1111 of file ObjCMT.cpp.
References AvailabilityAttrsMatch(), getKind(), and clang::ast_matchers::match().
Referenced by AttributesMatch().
|
static |
Definition at line 406 of file ObjCMT.cpp.
References clang::transformer::name().
Referenced by rewriteToObjCProperty().
|
static |
Definition at line 437 of file ObjCMT.cpp.
References clang::IdentifierTable::get(), clang::Type::getAs(), clang::QualType::getObjCLifetime(), clang::ASTContext::Idents, clang::Type::isBlockPointerType(), clang::Type::isObjCRetainableType(), clang::ObjCInterfaceDecl::lookupNestedProtocol(), clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, and clang::Qualifiers::OCL_Weak.
Referenced by rewriteToObjCProperty().
|
static |
Definition at line 989 of file ObjCMT.cpp.
References clang::IdentifierTable::get(), clang::TypeLoc::getBeginLoc(), clang::ObjCMethodDecl::getBeginLoc(), clang::ObjCMethodDecl::getClassInterface(), clang::ObjCImplDecl::getClassInterface(), clang::TypeLoc::getEndLoc(), clang::Selector::getInstTypeMethodFamily(), clang::NamedDecl::getName(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCMethodDecl::getReturnTypeSourceInfo(), clang::ObjCMethodDecl::getSelector(), clang::ASTContext::Idents, clang::Type::isObjCIdType(), clang::ObjCInterfaceDecl::lookupInheritedClass(), clang::OIT_Array, clang::OIT_Dictionary, clang::OIT_Init, clang::OIT_None, clang::OIT_ReturnsSelf, clang::OIT_Singleton, clang::edit::Commit::replace(), and ReplaceWithInstancetype().
|
static |
Definition at line 966 of file ObjCMT.cpp.
References clang::TypeLoc::getBeginLoc(), clang::ObjCMethodDecl::getBeginLoc(), clang::TypeLoc::getEndLoc(), clang::ASTContext::getObjCInstanceType(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCMethodDecl::getReturnTypeSourceInfo(), clang::ObjCMethodDecl::isInstanceMethod(), and clang::edit::Commit::replace().
Referenced by ReplaceWithClasstype().
|
static |
Definition at line 2166 of file ObjCMT.cpp.
References clang::DiagnosticsEngine::Error, clang::DiagnosticsEngine::getCustomDiagID(), and clang::DiagnosticsEngine::Report().
Referenced by applyEditsToTemp().
|
static |
Definition at line 716 of file ObjCMT.cpp.
References clang::arcmt::trans::findLocationAfterSemi(), clang::arcmt::trans::findSemiAfterLocation(), clang::NSAPI::getASTContext(), clang::TypeDecl::getBeginLoc(), clang::Decl::getEndLoc(), clang::NamedDecl::getIdentifier(), clang::SourceLocation::getLocWithOffset(), clang::IdentifierInfo::getName(), GetUnsignedName(), clang::edit::Commit::insertFromRange(), clang::SourceLocation::isValid(), clang::edit::Commit::remove(), and clang::edit::Commit::replace().
Referenced by UseNSOptionsMacro().
|
static |
Definition at line 770 of file ObjCMT.cpp.
References clang::QualType::getAsString(), clang::SourceRange::getBegin(), clang::TypeDecl::getBeginLoc(), clang::TagDecl::getBraceRange(), clang::CharSourceRange::getCharRange(), clang::Decl::getEndLoc(), clang::NamedDecl::getIdentifier(), clang::EnumDecl::getIntegerType(), clang::SourceLocation::getLocWithOffset(), clang::IdentifierInfo::getName(), clang::ASTContext::getPrintingPolicy(), clang::SourceLocation::isInvalid(), clang::QualType::isNull(), clang::edit::Commit::remove(), and clang::edit::Commit::replace().
Referenced by UseNSOptionsMacro().
|
static |
Definition at line 673 of file ObjCMT.cpp.
References clang::ObjCListBase::empty(), clang::Decl::getLocation(), clang::ObjCInterfaceDecl::getReferencedProtocols(), clang::ObjCInterfaceDecl::getSuperClass(), clang::ObjCInterfaceDecl::getSuperClassLoc(), clang::edit::Commit::insertAfterToken(), and clang::ObjCInterfaceDecl::protocol_loc_end().
Referenced by UseNSOptionsMacro().
|
static |
Definition at line 463 of file ObjCMT.cpp.
References append_attr(), clang::QualType::getAsString(), clang::NSAPI::getASTContext(), clang::ObjCMethodDecl::getBeginLoc(), clang::ASTContext::getCanonicalType(), clang::CharSourceRange::getCharRange(), clang::ObjCMethodDecl::getDeclaratorEndLoc(), clang::SourceLocation::getLocWithOffset(), clang::NamedDecl::getNameAsString(), clang::Selector::getNameForSlot(), clang::ASTContext::getPrintingPolicy(), clang::ASTContext::getQualifiedType(), clang::QualType::getQualifiers(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCMethodDecl::getSelector(), clang::ObjCMethodDecl::getSelectorStartLoc(), clang::ValueDecl::getType(), clang::QualType::getUnqualifiedType(), clang::Qualifiers::hasObjCLifetime(), clang::Type::isBlockPointerType(), clang::Type::isFunctionPointerType(), clang::NSAPI::isMacroDefined(), clang::Type::isRealType(), clang::isUppercase(), MigrateBlockOrFunctionPointerTypeVariable(), clang::ObjCMethodDecl::param_begin(), PropertyMemoryAttribute(), clang::edit::Commit::remove(), clang::Qualifiers::removeObjCLifetime(), clang::edit::Commit::replace(), clang::PrintingPolicy::SuppressStrongLifetime, and clang::toLowercase().
Definition at line 1057 of file ObjCMT.cpp.
References clang::Type::getAs(), clang::RecordType::getDecl(), clang::PointerType::getPointeeType(), clang::QualType::getTypePtr(), clang::QualType::getUnqualifiedType(), clang::Type::isAnyPointerType(), clang::Type::isBlockPointerType(), clang::ento::coreFoundation::isCFObjectRef(), clang::TagDecl::isCompleteDefinition(), clang::Type::isFunctionPointerType(), clang::Type::isObjCBuiltinType(), clang::Type::isObjCObjectPointerType(), and clang::Type::isPointerType().
|
static |
Definition at line 801 of file ObjCMT.cpp.
References ClassImplementsAllMethodsAndProperties(), clang::ASTContext::CollectInheritedProtocols(), clang::EnumDecl::enumerators(), clang::Type::getAs(), clang::DeclarationName::getAsIdentifierInfo(), clang::TypeDecl::getBeginLoc(), clang::ObjCImplDecl::getClassInterface(), clang::NamedDecl::getDeclName(), clang::SourceManager::getFileID(), clang::NamedDecl::getIdentifier(), clang::Token::getLength(), clang::Token::getLiteralData(), clang::Decl::getLocation(), clang::Preprocessor::getRawToken(), clang::Preprocessor::getSourceManager(), clang::TypeSourceInfo::getType(), clang::TypedefNameDecl::getTypeSourceInfo(), clang::Expr::IgnoreParenCasts(), clang::TagDecl::isCompleteDefinition(), clang::Decl::isDeprecated(), clang::Token::isLiteral(), clang::ObjCProtocolDecl::lookupProtocolNamed(), rewriteToNSEnumDecl(), rewriteToNSMacroDecl(), rewriteToObjCInterfaceDecl(), clang::format::Tok, and clang::toLowercase().
|
static |
Check whether the two versions match.
Definition at line 1082 of file ObjCMT.cpp.
Referenced by AvailabilityAttrsMatch().