Tidy up CGCXXABI creation

'create' functions conventionally return a pointer, not a reference.

Also use an OwningPtr to get replace the delete of a reference member.

No functional change.

llvm-svn: 198126
This commit is contained in:
Alp Toker 2013-12-28 21:58:40 +00:00
parent 3ca67d6404
commit 82862258e3
2 changed files with 6 additions and 7 deletions

View File

@ -55,15 +55,15 @@ using namespace CodeGen;
static const char AnnotationSection[] = "llvm.metadata";
static CGCXXABI &createCXXABI(CodeGenModule &CGM) {
static CGCXXABI *createCXXABI(CodeGenModule &CGM) {
switch (CGM.getTarget().getCXXABI().getKind()) {
case TargetCXXABI::GenericAArch64:
case TargetCXXABI::GenericARM:
case TargetCXXABI::iOS:
case TargetCXXABI::GenericItanium:
return *CreateItaniumCXXABI(CGM);
return CreateItaniumCXXABI(CGM);
case TargetCXXABI::Microsoft:
return *CreateMicrosoftCXXABI(CGM);
return CreateMicrosoftCXXABI(CGM);
}
llvm_unreachable("invalid C++ ABI kind");
@ -117,7 +117,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
if (SanOpts.Thread ||
(!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0))
TBAA = new CodeGenTBAA(Context, VMContext, CodeGenOpts, getLangOpts(),
ABI.getMangleContext());
getCXXABI().getMangleContext());
// If debug info or coverage generation is enabled, create the CGDebugInfo
// object.
@ -138,7 +138,6 @@ CodeGenModule::~CodeGenModule() {
delete OpenCLRuntime;
delete CUDARuntime;
delete TheTargetCodeGenInfo;
delete &ABI;
delete TBAA;
delete DebugInfo;
delete ARCData;

View File

@ -236,7 +236,7 @@ class CodeGenModule : public CodeGenTypeCache {
DiagnosticsEngine &Diags;
const llvm::DataLayout &TheDataLayout;
const TargetInfo &Target;
CGCXXABI &ABI;
llvm::OwningPtr<CGCXXABI> ABI;
llvm::LLVMContext &VMContext;
CodeGenTBAA *TBAA;
@ -535,7 +535,7 @@ public:
DiagnosticsEngine &getDiags() const { return Diags; }
const llvm::DataLayout &getDataLayout() const { return TheDataLayout; }
const TargetInfo &getTarget() const { return Target; }
CGCXXABI &getCXXABI() { return ABI; }
CGCXXABI &getCXXABI() const { return *ABI; }
llvm::LLVMContext &getLLVMContext() { return VMContext; }
bool shouldUseTBAA() const { return TBAA != 0; }