-//===- ARCRuntimeEntryPoints.h - ObjC ARC Optimization --*- mode: c++ -*---===//
+//===- ARCRuntimeEntryPoints.h - ObjC ARC Optimization --*- C++ -*---------===//
//
// The LLVM Compiler Infrastructure
//
///
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TRANSFORMS_SCALAR_ARCRUNTIMEENTRYPOINTS_H
-#define LLVM_TRANSFORMS_SCALAR_ARCRUNTIMEENTRYPOINTS_H
+#ifndef LLVM_LIB_TRANSFORMS_OBJCARC_ARCRUNTIMEENTRYPOINTS_H
+#define LLVM_LIB_TRANSFORMS_OBJCARC_ARCRUNTIMEENTRYPOINTS_H
#include "ObjCARC.h"
EPT_RetainAutoreleaseRV
};
- ARCRuntimeEntryPoints() : Module(0),
- AutoreleaseRV(0),
- Release(0),
- Retain(0),
- RetainBlock(0),
- Autorelease(0),
- StoreStrong(0),
- RetainRV(0),
- RetainAutorelease(0),
- RetainAutoreleaseRV(0) { }
+ ARCRuntimeEntryPoints() : TheModule(nullptr),
+ AutoreleaseRV(nullptr),
+ Release(nullptr),
+ Retain(nullptr),
+ RetainBlock(nullptr),
+ Autorelease(nullptr),
+ StoreStrong(nullptr),
+ RetainRV(nullptr),
+ RetainAutorelease(nullptr),
+ RetainAutoreleaseRV(nullptr) { }
~ARCRuntimeEntryPoints() { }
void Initialize(Module *M) {
- Module = M;
+ TheModule = M;
+ AutoreleaseRV = nullptr;
+ Release = nullptr;
+ Retain = nullptr;
+ RetainBlock = nullptr;
+ Autorelease = nullptr;
+ StoreStrong = nullptr;
+ RetainRV = nullptr;
+ RetainAutorelease = nullptr;
+ RetainAutoreleaseRV = nullptr;
}
Constant *get(const EntryPointType entry) {
- assert(Module != 0 && "Not initialized.");
+ assert(TheModule != nullptr && "Not initialized.");
switch (entry) {
case EPT_AutoreleaseRV:
return getI8XRetI8XEntryPoint(Autorelease, "objc_autorelease", true);
case EPT_StoreStrong:
return getI8XRetI8XXI8XEntryPoint(StoreStrong, "objc_storeStrong");
+ case EPT_RetainRV:
+ return getI8XRetI8XEntryPoint(RetainRV,
+ "objc_retainAutoreleasedReturnValue", true);
case EPT_RetainAutorelease:
return getI8XRetI8XEntryPoint(RetainAutorelease, "objc_retainAutorelease",
true);
case EPT_RetainAutoreleaseRV:
return getI8XRetI8XEntryPoint(RetainAutoreleaseRV,
"objc_retainAutoreleaseReturnValue", true);
- case EPT_RetainRV:
- return getI8XRetI8XEntryPoint(RetainRV,
- "objc_retainAutoreleasedReturnValue", true);
}
+
+ llvm_unreachable("Switch should be a covered switch.");
}
private:
/// Cached reference to the module which we will insert declarations into.
- Module *Module;
+ Module *TheModule;
/// Declaration for ObjC runtime function objc_autoreleaseReturnValue.
Constant *AutoreleaseRV;
if (Decl)
return Decl;
- LLVMContext &C = Module->getContext();
+ LLVMContext &C = TheModule->getContext();
Type *Params[] = { PointerType::getUnqual(Type::getInt8Ty(C)) };
AttributeSet Attr =
- AttributeSet().addAttribute(Module->getContext(),
- AttributeSet::FunctionIndex,
+ AttributeSet().addAttribute(C, AttributeSet::FunctionIndex,
Attribute::NoUnwind);
FunctionType *Fty = FunctionType::get(Type::getVoidTy(C), Params,
/*isVarArg=*/false);
- return Decl = Module->getOrInsertFunction(Name, Fty, Attr);
+ return Decl = TheModule->getOrInsertFunction(Name, Fty, Attr);
}
Constant *getI8XRetI8XEntryPoint(Constant *& Decl,
if (Decl)
return Decl;
- LLVMContext &C = Module->getContext();
+ LLVMContext &C = TheModule->getContext();
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *Params[] = { I8X };
FunctionType *Fty = FunctionType::get(I8X, Params, /*isVarArg=*/false);
AttributeSet Attr = AttributeSet();
if (NoUnwind)
- Attr = Attr.addAttribute(Module->getContext(),
- AttributeSet::FunctionIndex,
+ Attr = Attr.addAttribute(C, AttributeSet::FunctionIndex,
Attribute::NoUnwind);
- return Decl = Module->getOrInsertFunction(Name, Fty, Attr);
+ return Decl = TheModule->getOrInsertFunction(Name, Fty, Attr);
}
Constant *getI8XRetI8XXI8XEntryPoint(Constant *&Decl,
if (Decl)
return Decl;
- LLVMContext &C = Module->getContext();
+ LLVMContext &C = TheModule->getContext();
Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C));
Type *I8XX = PointerType::getUnqual(I8X);
Type *Params[] = { I8XX, I8X };
AttributeSet Attr =
- AttributeSet().addAttribute(Module->getContext(),
- AttributeSet::FunctionIndex,
+ AttributeSet().addAttribute(C, AttributeSet::FunctionIndex,
Attribute::NoUnwind);
- Attr = Attr.addAttribute(Module->getContext(), 1, Attribute::NoCapture);
+ Attr = Attr.addAttribute(C, 1, Attribute::NoCapture);
FunctionType *Fty = FunctionType::get(Type::getVoidTy(C), Params,
/*isVarArg=*/false);
- return Decl = Module->getOrInsertFunction(Name, Fty, Attr);
+ return Decl = TheModule->getOrInsertFunction(Name, Fty, Attr);
}
}; // class ARCRuntimeEntryPoints
} // namespace objcarc
} // namespace llvm
-#endif // LLVM_TRANSFORMS_SCALAR_ARCRUNTIMEENTRYPOINTS_H
+#endif