clang
7.0.0
|
#include "clang/Rewrite/Frontend/ASTConsumers.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/Attr.h"
#include "clang/AST/ParentMap.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Config/config.h"
#include "clang/Lex/Lexer.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
Go to the source code of this file.
Macros | |
#define | SKIP_BITFIELDS(IX, ENDIX, VEC) |
Enumerations | |
enum | MetaDataDlags { CLS = 0x0, CLS_META = 0x1, CLS_ROOT = 0x2, OBJC2_CLS_HIDDEN = 0x10, CLS_EXCEPTION = 0x20, CLS_HAS_IVAR_RELEASER = 0x40, CLS_COMPILED_BY_ARC = 0x80 } |
Functions | |
static bool | IsHeaderFile (const std::string &Filename) |
static void | WriteInternalIvarName (const ObjCInterfaceDecl *IDecl, ObjCIvarDecl *IvarDecl, std::string &Result) |
static bool | mustSynthesizeSetterGetterMethod (ObjCImplementationDecl *IMP, ObjCPropertyDecl *PD, bool getter) |
mustSynthesizeSetterGetterMethod - returns true if setter or getter has not been found in the class implementation. More... | |
static void | RewriteOneForwardClassDecl (ObjCInterfaceDecl *ForwardDecl, std::string &typedefString) |
static void | Write_RethrowObject (std::string &buf) |
static bool | scanForProtocolRefs (const char *startBuf, const char *endBuf, const char *&startRef, const char *&endRef) |
static void | scanToNextArgument (const char *&argRef) |
static SourceLocation | getFunctionSourceLocation (RewriteModernObjC &R, FunctionDecl *FD) |
getFunctionSourceLocation - returns start location of a function definition. More... | |
static bool | HasLocalVariableExternalStorage (ValueDecl *VD) |
static void | BuildUniqueMethodName (std::string &Name, ObjCMethodDecl *MD) |
static void | Write_ProtocolExprReferencedMetadata (ASTContext *Context, ObjCProtocolDecl *PDecl, std::string &Result) |
Write_ProtocolExprReferencedMetadata - This routine writer out the protocol reference symbols in the for of: struct _protocol_t *PROTOCOL_REF = &PROTOCOL_METADATA. More... | |
static void | WriteModernMetadataDeclarations (ASTContext *Context, std::string &Result) |
WriteModernMetadataDeclarations - Writes out metadata declarations for modern ABI. More... | |
static void | Write_protocol_list_t_TypeDecl (std::string &Result, long super_protocol_count) |
static void | Write_method_list_t_TypeDecl (std::string &Result, unsigned int method_count) |
static void | Write__prop_list_t_TypeDecl (std::string &Result, unsigned int property_count) |
static void | Write__ivar_list_t_TypeDecl (std::string &Result, unsigned int ivar_count) |
static void | Write_protocol_list_initializer (ASTContext *Context, std::string &Result, ArrayRef< ObjCProtocolDecl *> SuperProtocols, StringRef VarName, StringRef ProtocolName) |
static void | Write_method_list_t_initializer (RewriteModernObjC &RewriteObj, ASTContext *Context, std::string &Result, ArrayRef< ObjCMethodDecl *> Methods, StringRef VarName, StringRef TopLevelDeclName, bool MethodImpl) |
static void | Write_prop_list_t_initializer (RewriteModernObjC &RewriteObj, ASTContext *Context, std::string &Result, ArrayRef< ObjCPropertyDecl *> Properties, const Decl *Container, StringRef VarName, StringRef ProtocolName) |
static void | Write__class_ro_t_initializer (ASTContext *Context, std::string &Result, unsigned int flags, const std::string &InstanceStart, const std::string &InstanceSize, ArrayRef< ObjCMethodDecl *>baseMethods, ArrayRef< ObjCProtocolDecl *>baseProtocols, ArrayRef< ObjCIvarDecl *>ivars, ArrayRef< ObjCPropertyDecl *>Properties, StringRef VarName, StringRef ClassName) |
static void | Write_class_t (ASTContext *Context, std::string &Result, StringRef VarName, const ObjCInterfaceDecl *CDecl, bool metaclass) |
static void | Write_category_t (RewriteModernObjC &RewriteObj, ASTContext *Context, std::string &Result, ObjCCategoryDecl *CatDecl, ObjCInterfaceDecl *ClassDecl, ArrayRef< ObjCMethodDecl *> InstanceMethods, ArrayRef< ObjCMethodDecl *> ClassMethods, ArrayRef< ObjCProtocolDecl *> RefedProtocols, ArrayRef< ObjCPropertyDecl *> ClassProperties) |
static void | Write__extendedMethodTypes_initializer (RewriteModernObjC &RewriteObj, ASTContext *Context, std::string &Result, ArrayRef< ObjCMethodDecl *> Methods, StringRef VarName, StringRef ProtocolName) |
static void | Write_IvarOffsetVar (RewriteModernObjC &RewriteObj, ASTContext *Context, std::string &Result, ArrayRef< ObjCIvarDecl *> Ivars, ObjCInterfaceDecl *CDecl) |
static void | Write__ivar_list_t_initializer (RewriteModernObjC &RewriteObj, ASTContext *Context, std::string &Result, ArrayRef< ObjCIvarDecl *> OriginalIvars, StringRef VarName, ObjCInterfaceDecl *CDecl) |
static bool | hasObjCExceptionAttribute (ASTContext &Context, const ObjCInterfaceDecl *OID) |
hasObjCExceptionAttribute - Return true if this class or any super class has the objc_exception attribute. More... | |
#define SKIP_BITFIELDS | ( | IX, | |
ENDIX, | |||
VEC | |||
) |
Definition at line 3879 of file RewriteModernObjC.cpp.
Referenced by Write__ivar_list_t_initializer(), and Write_IvarOffsetVar().
enum MetaDataDlags |
Definition at line 6410 of file RewriteModernObjC.cpp.
|
static |
Definition at line 4452 of file RewriteModernObjC.cpp.
References clang::Stmt::children(), clang::Type::getAs(), clang::Selector::getAsString(), clang::ObjCMethodDecl::getClassInterface(), clang::ObjCMethodDecl::getLocStart(), clang::NamedDecl::getName(), clang::PointerType::getPointeeType(), clang::ASTContext::getPointerType(), clang::FunctionType::getReturnType(), clang::ObjCMethodDecl::getSelector(), HasLocalVariableExternalStorage(), and clang::Type::isFunctionPointerType().
|
static |
getFunctionSourceLocation - returns start location of a function definition.
Complication arises when function has declared as extern "C" or extern "C" {...}
Definition at line 3045 of file RewriteModernObjC.cpp.
References clang::FunctionDecl::Create(), clang::IdentifierTable::get(), clang::QualType::getAsString(), clang::Decl::getDeclContext(), clang::PresumedLoc::getFilename(), clang::PresumedLoc::getLine(), clang::Decl::getLocation(), clang::ObjCMethodDecl::getLocStart(), clang::Decl::getLocStart(), clang::ASTContext::getPointerType(), clang::SourceManager::getPresumedLoc(), clang::ASTContext::getPrintingPolicy(), clang::FunctionDecl::getStorageClass(), clang::DeclaratorDecl::getTypeSpecStartLoc(), clang::ASTContext::Idents, clang::FunctionDecl::isExternC(), clang::SourceLocation::isFileID(), clang::FunctionDecl::isMain(), clang::ObjCMethodDecl::isVariadic(), clang::SC_Extern, clang::SC_None, and clang::Lexer::Stringify().
Definition at line 4045 of file RewriteModernObjC.cpp.
References clang::Expr::getExprLoc(), clang::BlockExpr::getFunctionType(), and clang::FunctionType::getReturnType().
Referenced by BuildUniqueMethodName().
|
static |
hasObjCExceptionAttribute - Return true if this class or any super class has the objc_exception attribute.
FIXME. Move this to ASTContext.cpp as it is also used for IRGen.
Definition at line 7010 of file RewriteModernObjC.cpp.
References clang::ObjCInterfaceDecl::all_declared_ivar_begin(), clang::ObjCContainerDecl::class_methods(), clang::ObjCPropertyImplDecl::Dynamic, clang::ObjCImplDecl::getClassInterface(), clang::ObjCPropertyDecl::getGetterMethodDecl(), clang::ObjCImplementationDecl::getNameAsString(), clang::ObjCIvarDecl::getNextIvar(), clang::ObjCInterfaceDecl::getReferencedProtocols(), clang::ObjCPropertyDecl::getSetterMethodDecl(), clang::ObjCInterfaceDecl::getSuperClass(), clang::Decl::hasAttr(), clang::ObjCContainerDecl::instance_methods(), clang::ObjCInterfaceDecl::isImplicitInterfaceDecl(), clang::ObjCPropertyDecl::isReadOnly(), mustSynthesizeSetterGetterMethod(), clang::ObjCImplDecl::property_impls(), Write__ivar_list_t_initializer(), Write_method_list_t_initializer(), and WriteModernMetadataDeclarations().
|
static |
Definition at line 628 of file RewriteModernObjC.cpp.
References clang::DiagnosticsEngine::getCustomDiagID(), and clang::DiagnosticsEngine::Warning.
Referenced by clang::Preprocessor::HandlePragmaOnce(), and ParseFrontendArgs().
|
static |
mustSynthesizeSetterGetterMethod - returns true if setter or getter has not been found in the class implementation.
In this case, it must be synthesized.
Definition at line 911 of file RewriteModernObjC.cpp.
References clang::ObjCPropertyImplDecl::Dynamic, clang::SourceManager::getCharacterData(), clang::ObjCIvarDecl::getContainingInterface(), clang::ObjCPropertyDecl::getGetterMethodDecl(), clang::ObjCPropertyDecl::getGetterName(), clang::ObjCContainerDecl::getInstanceMethod(), getIvarAccessString(), clang::Decl::getLocEnd(), clang::ObjCPropertyImplDecl::getLocStart(), clang::SourceLocation::getLocWithOffset(), clang::NamedDecl::getName(), clang::ASTContext::getPrintingPolicy(), clang::ObjCPropertyDecl::getPropertyAttributes(), clang::ObjCPropertyImplDecl::getPropertyDecl(), clang::ObjCPropertyImplDecl::getPropertyImplementation(), clang::ObjCPropertyImplDecl::getPropertyIvarDecl(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCPropertyDecl::getSetterMethodDecl(), clang::ObjCPropertyDecl::getSetterName(), clang::ObjCPropertyDecl::isReadOnly(), clang::SourceLocation::isValid(), clang::ObjCPropertyDecl::OBJC_PR_copy, clang::ObjCPropertyDecl::OBJC_PR_nonatomic, and clang::ObjCPropertyDecl::OBJC_PR_retain.
Referenced by hasObjCExceptionAttribute().
|
static |
Definition at line 1046 of file RewriteModernObjC.cpp.
References clang::SourceManager::getCharacterData(), clang::Decl::getLocStart(), and clang::NamedDecl::getNameAsString().
|
static |
Definition at line 2117 of file RewriteModernObjC.cpp.
Referenced by scanToNextArgument().
|
static |
Definition at line 2134 of file RewriteModernObjC.cpp.
References clang::Type::getAs(), clang::QualType::getAsString(), clang::ASTContext::getBaseElementType(), clang::SourceManager::getCharacterData(), clang::VarDecl::getInit(), clang::Decl::getLocation(), clang::Stmt::getLocEnd(), clang::Stmt::getLocStart(), clang::SourceLocation::getLocWithOffset(), clang::FunctionProtoType::getNumParams(), clang::FunctionProtoType::getParamType(), clang::Type::getPointeeType(), clang::PointerType::getPointeeType(), clang::ASTContext::getPrintingPolicy(), clang::FunctionType::getReturnType(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::DeclaratorDecl::getTypeSpecStartLoc(), clang::TypeOfExprType::getUnderlyingExpr(), clang::Type::isArrayType(), clang::SourceLocation::isInvalid(), clang::Type::isObjCObjectPointerType(), clang::Type::isObjCQualifiedIdType(), clang::Type::isObjCQualifiedInterfaceType(), and scanForProtocolRefs().
|
static |
Definition at line 6423 of file RewriteModernObjC.cpp.
References CLS_META, clang::ASTContext::getTargetInfo(), and clang::TargetInfo::getTriple().
|
static |
Definition at line 6712 of file RewriteModernObjC.cpp.
References clang::ASTContext::getObjCEncodingForMethodDecl().
|
static |
Definition at line 6782 of file RewriteModernObjC.cpp.
References clang::ObjCProtocolDecl::getCanonicalDecl(), clang::ObjCProtocolDecl::getDefinition(), clang::NamedDecl::getName(), clang::NamedDecl::getNameAsString(), clang::ASTContext::getObjCEncodingForType(), clang::CharUnits::getQuantity(), clang::ValueDecl::getType(), clang::ASTContext::getTypeAlign(), clang::ASTContext::getTypeSizeInChars(), clang::FieldDecl::isBitField(), SKIP_BITFIELDS, Write__ivar_list_t_TypeDecl(), Write_IvarOffsetVar(), WriteInternalIvarName(), and WriteModernMetadataDeclarations().
Referenced by hasObjCExceptionAttribute().
|
static |
Definition at line 6301 of file RewriteModernObjC.cpp.
Referenced by Write__ivar_list_t_initializer().
|
static |
Definition at line 6291 of file RewriteModernObjC.cpp.
|
static |
Definition at line 6630 of file RewriteModernObjC.cpp.
References clang::ObjCInterfaceDecl::getImplementation(), clang::NamedDecl::getName(), and clang::NamedDecl::getNameAsString().
|
static |
Definition at line 6490 of file RewriteModernObjC.cpp.
References clang::ObjCInterfaceDecl::getImplementation(), clang::NamedDecl::getNameAsString(), and clang::ObjCInterfaceDecl::getSuperClass().
|
static |
if (Ivar->getAccessControl() == ObjCIvarDecl::Private || Ivar->getAccessControl() == ObjCIvarDecl::Package || Class->getVisibility() == HiddenVisibility) Visibility should be: HiddenVisibility; else Visibility should be: DefaultVisibility;
Definition at line 6739 of file RewriteModernObjC.cpp.
References clang::ObjCIvarDecl::getAccessControl(), clang::ASTContext::getLangOpts(), clang::ObjCIvarDecl::Package, clang::ObjCIvarDecl::Private, SKIP_BITFIELDS, and WriteInternalIvarName().
Referenced by Write__ivar_list_t_initializer().
|
static |
Definition at line 6334 of file RewriteModernObjC.cpp.
References clang::ASTContext::getObjCEncodingForMethodDecl(), and Write_method_list_t_TypeDecl().
Referenced by hasObjCExceptionAttribute().
|
static |
Definition at line 6281 of file RewriteModernObjC.cpp.
Referenced by Write_method_list_t_initializer().
|
static |
Definition at line 6374 of file RewriteModernObjC.cpp.
|
static |
Definition at line 6311 of file RewriteModernObjC.cpp.
References clang::NamedDecl::getNameAsString(), and Write_protocol_list_t_TypeDecl().
|
static |
Definition at line 6272 of file RewriteModernObjC.cpp.
Referenced by Write_protocol_list_initializer().
|
static |
Write_ProtocolExprReferencedMetadata - This routine writer out the protocol reference symbols in the for of: struct _protocol_t *PROTOCOL_REF = &PROTOCOL_METADATA.
Definition at line 5828 of file RewriteModernObjC.cpp.
References clang::C, clang::ObjCIvarDecl::getContainingInterface(), clang::ASTContext::getLangOpts(), clang::SourceManager::getLocForStartOfFile(), clang::NamedDecl::getNameAsString(), clang::Rewriter::getRewriteBufferFor(), clang::DiagnosticsEngine::hasErrorOccurred(), clang::FieldDecl::isBitField(), and clang::Preamble.
|
static |
Definition at line 1848 of file RewriteModernObjC.cpp.
References clang::Stmt::children(), clang::ObjCAutoreleasePoolStmt::getAtLoc(), clang::ObjCAtSynchronizedStmt::getAtSynchronizedLoc(), clang::ObjCAtTryStmt::getAtTryLoc(), clang::SourceManager::getCharacterData(), clang::ObjCAtTryStmt::getFinallyStmt(), clang::ASTContext::getFullLoc(), clang::CompoundStmt::getLocEnd(), clang::ObjCAtTryStmt::getLocStart(), clang::ObjCAtSynchronizedStmt::getLocStart(), clang::Stmt::getLocStart(), clang::CompoundStmt::getLocStart(), clang::SourceLocation::getLocWithOffset(), clang::ObjCAtTryStmt::getNumCatchStmts(), clang::ObjCAutoreleasePoolStmt::getSubStmt(), clang::ObjCAtSynchronizedStmt::getSynchBody(), and clang::DiagnosticsEngine::Report().
|
static |
Definition at line 831 of file RewriteModernObjC.cpp.
References clang::ObjCIvarDecl::getContainingInterface(), getIvarAccessString(), clang::NamedDecl::getName(), and clang::FieldDecl::isBitField().
Referenced by Write__ivar_list_t_initializer(), and Write_IvarOffsetVar().
|
static |
WriteModernMetadataDeclarations - Writes out metadata declarations for modern ABI.
struct _prop_t { const char *name; char *attributes; } struct _prop_list_t { uint32_t entsize; // sizeof(struct _prop_t) uint32_t count_of_properties; struct _prop_t prop_list[count_of_properties]; } struct _protocol_t; struct _protocol_list_t { long protocol_count; // Note, this is 32/64 bit struct _protocol_t * protocol_list[protocol_count]; } struct _objc_method { SEL _cmd; const char *method_type; char *_imp; } struct _method_list_t { uint32_t entsize; // sizeof(struct _objc_method) uint32_t method_count; struct _objc_method method_list[method_count]; } struct _protocol_t { id isa; // NULL const char *protocol_name; const struct _protocol_list_t * protocol_list; // super protocols const struct method_list_t *instance_methods; const struct method_list_t *class_methods; const struct method_list_t *optionalInstanceMethods; const struct method_list_t *optionalClassMethods; const struct _prop_list_t * properties; const uint32_t size; // sizeof(struct _protocol_t) const uint32_t flags; // = 0 const char ** extendedMethodTypes; } struct _ivar_t { unsigned long int *offset; // pointer to ivar offset location const char *name; const char *type; uint32_t alignment; uint32_t size; } struct _ivar_list_t { uint32 entsize; // sizeof(struct _ivar_t) uint32 count; struct _ivar_t list[count]; } struct _class_ro_t { uint32_t flags; uint32_t instanceStart; uint32_t instanceSize; uint32_t reserved; // only when building for 64bit targets const uint8_t *ivarLayout; const char *name; const struct _method_list_t *baseMethods; const struct _protocol_list_t *baseProtocols; const struct _ivar_list_t *ivars; const uint8_t *weakIvarLayout; const struct _prop_list_t *properties; } struct _class_t { struct _class_t *isa; struct _class_t *superclass; void *cache; IMP *vtable; struct _class_ro_t *ro; } struct _category_t { const char *name; struct _class_t *cls; const struct _method_list_t *instance_methods; const struct _method_list_t *class_methods; const struct _protocol_list_t *protocols; const struct _prop_list_t *properties; } MessageRefTy - LLVM for: struct _message_ref_t { IMP messenger; SEL name; }; SuperMessageRefTy - LLVM for: struct _super_message_ref_t { SUPER_IMP messenger; SEL name; };
Definition at line 6194 of file RewriteModernObjC.cpp.
References clang::ASTContext::getTargetInfo(), and clang::TargetInfo::getTriple().
Referenced by hasObjCExceptionAttribute(), and Write__ivar_list_t_initializer().