[OpaquePtr] Remove uses of CreateStructGEP() without element type
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 17 Jul 2021 16:44:56 +0000 (18:44 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 17 Jul 2021 16:48:21 +0000 (18:48 +0200)
Remove uses of to-be-deprecated API.

clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGObjCGNU.cpp

index 769501a..f39a56f 100644 (file)
@@ -1375,7 +1375,7 @@ static llvm::Constant *buildGlobalBlock(CodeGenModule &CGM,
     llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), "entry",
           Init));
     b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(),
-                         b.CreateStructGEP(literal, 0),
+                         b.CreateStructGEP(literal->getValueType(), literal, 0),
                          CGM.getPointerAlign().getAsAlign());
     b.CreateRetVoid();
     // We can't use the normal LLVM global initialisation array, because we
index 9e47dbf..3f361f4 100644 (file)
@@ -945,7 +945,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
   /// Generate the name of a symbol for a reference to a class.  Accesses to
   /// classes should be indirected via this.
 
-  typedef std::pair<std::string, std::pair<llvm::Constant*, int>> EarlyInitPair;
+  typedef std::pair<std::string, std::pair<llvm::GlobalVariable*, int>>
+      EarlyInitPair;
   std::vector<EarlyInitPair> EarlyInitList;
 
   std::string SymbolForClassRef(StringRef Name, bool isWeak) {
@@ -1096,7 +1097,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
         }
       }
     }
-    auto *ObjCStrGV =
+    llvm::GlobalVariable *ObjCStrGV =
       Fields.finishAndCreateGlobal(
           isNamed ? StringRef(StringName) : ".objc_string",
           Align, false, isNamed ? llvm::GlobalValue::LinkOnceODRLinkage
@@ -1107,7 +1108,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
       ObjCStrGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
     }
     if (CGM.getTriple().isOSBinFormatCOFF()) {
-      std::pair<llvm::Constant*, int> v{ObjCStrGV, 0};
+      std::pair<llvm::GlobalVariable*, int> v{ObjCStrGV, 0};
       EarlyInitList.emplace_back(Sym, v);
     }
     llvm::Constant *ObjCStr = llvm::ConstantExpr::getBitCast(ObjCStrGV, IdTy);
@@ -1654,9 +1655,10 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
       for (const auto &lateInit : EarlyInitList) {
         auto *global = TheModule.getGlobalVariable(lateInit.first);
         if (global) {
+          llvm::GlobalVariable *GV = lateInit.second.first;
           b.CreateAlignedStore(
               global,
-              b.CreateStructGEP(lateInit.second.first, lateInit.second.second),
+              b.CreateStructGEP(GV->getValueType(), GV, lateInit.second.second),
               CGM.getPointerAlign().getAsAlign());
         }
       }
@@ -1938,7 +1940,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
     // struct objc_property_list *properties
     classFields.add(GeneratePropertyList(OID, classDecl));
 
-    auto *classStruct =
+    llvm::GlobalVariable *classStruct =
       classFields.finishAndCreateGlobal(SymbolForClass(className),
         CGM.getPointerAlign(), false, llvm::GlobalValue::ExternalLinkage);
 
@@ -1949,12 +1951,12 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
     if (IsCOFF) {
       // we can't import a class struct.
       if (OID->getClassInterface()->hasAttr<DLLExportAttr>()) {
-        cast<llvm::GlobalValue>(classStruct)->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+        classStruct->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
         cast<llvm::GlobalValue>(classRefSymbol)->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
       }
 
       if (SuperClass) {
-        std::pair<llvm::Constant*, int> v{classStruct, 1};
+        std::pair<llvm::GlobalVariable*, int> v{classStruct, 1};
         EarlyInitList.emplace_back(std::string(SuperClass->getName()),
                                    std::move(v));
       }