Fix -Wnon-virtual-dtor warning introduced in r217982.
[oota-llvm.git] / lib / Transforms / ObjCARC / ARCRuntimeEntryPoints.h
index 7055c10df378d99ed72c7c28cfc5c5a848744798..e286dbc64a86ff713549b6280106120193bd65df 100644 (file)
@@ -1,4 +1,4 @@
-//===- ARCRuntimeEntryPoints.h - ObjC ARC Optimization --*- mode: c++ -*---===//
+//===- ARCRuntimeEntryPoints.h - ObjC ARC Optimization --*- C++ -*---------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -19,8 +19,8 @@
 ///
 //===----------------------------------------------------------------------===//
 
-#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"
 
@@ -43,25 +43,34 @@ public:
     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:
@@ -77,21 +86,23 @@ public:
       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;
@@ -117,15 +128,14 @@ private:
     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,
@@ -134,18 +144,17 @@ private:
     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,
@@ -153,21 +162,20 @@ private:
     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
@@ -175,4 +183,4 @@ private:
 } // namespace objcarc
 } // namespace llvm
 
-#endif // LLVM_TRANSFORMS_SCALAR_ARCRUNTIMEENTRYPOINTS_H
+#endif