#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/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>
#if CLANG_ENABLE_OBJC_REWRITER
usingnamespaceclang;
RewriteBuffer;
utostr;
namespace {
class RewriteObjC : public ASTConsumer { … };
class RewriteObjCFragileABI : public RewriteObjC { … };
}
void RewriteObjC::RewriteBlocksInFunctionProtoType(QualType funcType,
NamedDecl *D) { … }
void RewriteObjC::CheckFunctionPointerDecl(QualType funcType, NamedDecl *ND) { … }
static bool IsHeaderFile(const std::string &Filename) { … }
RewriteObjC::RewriteObjC(std::string inFile, std::unique_ptr<raw_ostream> OS,
DiagnosticsEngine &D, const LangOptions &LOpts,
bool silenceMacroWarn)
: … { … }
std::unique_ptr<ASTConsumer>
clang::CreateObjCRewriter(const std::string &InFile,
std::unique_ptr<raw_ostream> OS,
DiagnosticsEngine &Diags, const LangOptions &LOpts,
bool SilenceRewriteMacroWarning) { … }
void RewriteObjC::InitializeCommon(ASTContext &context) { … }
void RewriteObjC::HandleTopLevelSingleDecl(Decl *D) { … }
void RewriteObjC::RewriteInclude() { … }
static std::string getIvarAccessString(ObjCIvarDecl *OID) { … }
void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
ObjCImplementationDecl *IMD,
ObjCCategoryImplDecl *CID) { … }
static void RewriteOneForwardClassDecl(ObjCInterfaceDecl *ForwardDecl,
std::string &typedefString) { … }
void RewriteObjC::RewriteForwardClassEpilogue(ObjCInterfaceDecl *ClassDecl,
const std::string &typedefString) { … }
void RewriteObjC::RewriteForwardClassDecl(DeclGroupRef D) { … }
void RewriteObjC::RewriteForwardClassDecl(const SmallVectorImpl<Decl *> &D) { … }
void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) { … }
void RewriteObjC::RewriteProperty(ObjCPropertyDecl *prop) { … }
void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { … }
void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { … }
void RewriteObjC::RewriteForwardProtocolDecl(DeclGroupRef D) { … }
void
RewriteObjC::RewriteForwardProtocolDecl(const SmallVectorImpl<Decl *> &DG) { … }
void RewriteObjC::RewriteTypeIntoString(QualType T, std::string &ResultStr,
const FunctionType *&FPRetType) { … }
void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
ObjCMethodDecl *OMD,
std::string &ResultStr) { … }
void RewriteObjC::RewriteImplementationDecl(Decl *OID) { … }
void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) { … }
Stmt *RewriteObjC::RewritePropertyOrImplicitSetter(PseudoObjectExpr *PseudoOp) { … }
Stmt *RewriteObjC::RewritePropertyOrImplicitGetter(PseudoObjectExpr *PseudoOp) { … }
void RewriteObjC::SynthCountByEnumWithState(std::string &buf) { … }
Stmt *RewriteObjC::RewriteBreakStmt(BreakStmt *S) { … }
Stmt *RewriteObjC::RewriteContinueStmt(ContinueStmt *S) { … }
Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
SourceLocation OrigEnd) { … }
Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) { … }
void RewriteObjC::WarnAboutReturnGotoStmts(Stmt *S)
{ … }
void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns)
{ … }
void RewriteObjC::RewriteTryReturnStmts(Stmt *S) { … }
void RewriteObjC::RewriteSyncReturnStmts(Stmt *S, std::string syncExitBuf) { … }
Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) { … }
Stmt *RewriteObjC::RewriteObjCThrowStmt(ObjCAtThrowStmt *S) { … }
Stmt *RewriteObjC::RewriteAtEncode(ObjCEncodeExpr *Exp) { … }
Stmt *RewriteObjC::RewriteAtSelector(ObjCSelectorExpr *Exp) { … }
CallExpr *
RewriteObjC::SynthesizeCallToFunctionDecl(FunctionDecl *FD,
ArrayRef<Expr *> Args,
SourceLocation StartLoc,
SourceLocation EndLoc) { … }
static bool scanForProtocolRefs(const char *startBuf, const char *endBuf,
const char *&startRef, const char *&endRef) { … }
static void scanToNextArgument(const char *&argRef) { … }
bool RewriteObjC::needToScanForQualifiers(QualType T) { … }
void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) { … }
void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Decl *Dcl) { … }
void RewriteObjC::RewriteTypeOfDecl(VarDecl *ND) { … }
void RewriteObjC::SynthSelGetUidFunctionDecl() { … }
void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) { … }
void RewriteObjC::RewriteBlockPointerType(std::string& Str, QualType Type) { … }
void RewriteObjC::RewriteBlockPointerTypeVariable(std::string& Str,
ValueDecl *VD) { … }
void RewriteObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) { … }
void RewriteObjC::SynthSuperConstructorFunctionDecl() { … }
void RewriteObjC::SynthMsgSendFunctionDecl() { … }
void RewriteObjC::SynthMsgSendSuperFunctionDecl() { … }
void RewriteObjC::SynthMsgSendStretFunctionDecl() { … }
void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() { … }
void RewriteObjC::SynthMsgSendFpretFunctionDecl() { … }
void RewriteObjC::SynthGetClassFunctionDecl() { … }
void RewriteObjC::SynthGetSuperClassFunctionDecl() { … }
void RewriteObjC::SynthGetMetaClassFunctionDecl() { … }
Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { … }
QualType RewriteObjC::getSuperStructType() { … }
QualType RewriteObjC::getConstantStringStructType() { … }
CallExpr *RewriteObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFlavor,
QualType msgSendType,
QualType returnType,
SmallVectorImpl<QualType> &ArgTypes,
SmallVectorImpl<Expr*> &MsgExprs,
ObjCMethodDecl *Method) { … }
Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp,
SourceLocation StartLoc,
SourceLocation EndLoc) { … }
Stmt *RewriteObjC::RewriteMessageExpr(ObjCMessageExpr *Exp) { … }
QualType RewriteObjC::getProtocolType() { … }
Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) { … }
bool RewriteObjC::BufferContainsPPDirectives(const char *startBuf,
const char *endBuf) { … }
void RewriteObjC::RewriteObjCInternalStruct(ObjCInterfaceDecl *CDecl,
std::string &Result) { … }
void RewriteObjC::RewriteImplementations() { … }
void RewriteObjC::RewriteByRefString(std::string &ResultStr,
const std::string &Name,
ValueDecl *VD, bool def) { … }
static bool HasLocalVariableExternalStorage(ValueDecl *VD) { … }
std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
StringRef funcName,
std::string Tag) { … }
std::string RewriteObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
StringRef funcName,
std::string Tag) { … }
std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
std::string Desc) { … }
std::string RewriteObjC::SynthesizeBlockDescriptor(std::string DescTag,
std::string ImplTag, int i,
StringRef FunName,
unsigned hasCopy) { … }
void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
StringRef FunName) { … }
void RewriteObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) { … }
static void BuildUniqueMethodName(std::string &Name,
ObjCMethodDecl *MD) { … }
void RewriteObjC::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) { … }
void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) { … }
void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S,
SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs,
llvm::SmallPtrSetImpl<const DeclContext *> &InnerContexts) { … }
QualType RewriteObjC::convertFunctionTypeOfBlocks(const FunctionType *FT) { … }
Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { … }
Stmt *RewriteObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) { … }
Stmt *RewriteObjC::RewriteLocalVariableExternalStorage(DeclRefExpr *DRE) { … }
void RewriteObjC::RewriteCastExpr(CStyleCastExpr *CE) { … }
void RewriteObjC::RewriteBlockPointerFunctionArgs(FunctionDecl *FD) { … }
bool RewriteObjC::PointerTypeTakesAnyBlockArguments(QualType QT) { … }
bool RewriteObjC::PointerTypeTakesAnyObjCQualifiedType(QualType QT) { … }
void RewriteObjC::GetExtentOfArgList(const char *Name, const char *&LParen,
const char *&RParen) { … }
void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) { … }
std::string RewriteObjC::SynthesizeByrefCopyDestroyHelper(VarDecl *VD,
int flag) { … }
void RewriteObjC::RewriteByRefVar(VarDecl *ND) { … }
void RewriteObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) { … }
FunctionDecl *RewriteObjC::SynthBlockInitFunctionDecl(StringRef name) { … }
Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
const SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs) { … }
bool RewriteObjC::IsDeclStmtInForeachHeader(DeclStmt *DS) { … }
Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) { … }
void RewriteObjC::RewriteRecordBody(RecordDecl *RD) { … }
void RewriteObjC::HandleDeclInMainFile(Decl *D) { … }
void RewriteObjC::HandleTranslationUnit(ASTContext &C) { … }
void RewriteObjCFragileABI::Initialize(ASTContext &context) { … }
void RewriteObjCFragileABI::RewriteIvarOffsetComputation(ObjCIvarDecl *ivar,
std::string &Result) { … }
void RewriteObjCFragileABI::RewriteObjCProtocolMetaData(
ObjCProtocolDecl *PDecl, StringRef prefix,
StringRef ClassName, std::string &Result) { … }
void RewriteObjCFragileABI::RewriteObjCProtocolListMetaData(
const ObjCList<ObjCProtocolDecl> &Protocols,
StringRef prefix, StringRef ClassName,
std::string &Result) { … }
void RewriteObjCFragileABI::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
std::string &Result) { … }
void RewriteObjCFragileABI::RewriteMetaDataIntoBuffer(std::string &Result) { … }
void RewriteObjCFragileABI::RewriteObjCCategoryImplDecl(ObjCCategoryImplDecl *IDecl,
std::string &Result) { … }
template<typename MethodIterator>
void RewriteObjCFragileABI::RewriteObjCMethodsMetaData(MethodIterator MethodBegin,
MethodIterator MethodEnd,
bool IsInstanceMethod,
StringRef prefix,
StringRef ClassName,
std::string &Result) { … }
Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { … }
#endif