[llvm] r209076 - Use create methods since msvc doesn't handle delegating constructors.

Rafael Espindola rafael.espindola at gmail.com
Sat May 17 14:29:58 PDT 2014


Author: rafael
Date: Sat May 17 16:29:57 2014
New Revision: 209076

URL: http://llvm.org/viewvc/llvm-project?rev=209076&view=rev
Log:
Use create methods since msvc doesn't handle delegating constructors.

Modified:
    llvm/trunk/include/llvm/IR/GlobalAlias.h
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/IR/Core.cpp
    llvm/trunk/lib/IR/Globals.cpp
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
    llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
    llvm/trunk/unittests/IR/ConstantsTest.cpp
    llvm/trunk/unittests/IR/VerifierTest.cpp
    llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp

Modified: llvm/trunk/include/llvm/IR/GlobalAlias.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalAlias.h?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalAlias.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalAlias.h Sat May 17 16:29:57 2014
@@ -33,29 +33,37 @@ class GlobalAlias : public GlobalValue,
 
   void setParent(Module *parent);
 
+  GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
+              const Twine &Name, GlobalObject *Aliasee, Module *Parent);
+
 public:
   // allocate space for exactly one operand
   void *operator new(size_t s) {
     return User::operator new(s, 1);
   }
+
   /// If a parent module is specified, the alias is automatically inserted into
   /// the end of the specified module's alias list.
-  GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
-              const Twine &Name, GlobalObject *Aliasee, Module *Parent);
+  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
+                             LinkageTypes Linkage, const Twine &Name,
+                             GlobalObject *Aliasee, Module *Parent);
 
   // Without the Aliasee.
-  GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
-              const Twine &Name, Module *Parent);
+  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
+                             LinkageTypes Linkage, const Twine &Name,
+                             Module *Parent);
 
   // The module is taken from the Aliasee.
-  GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
-              const Twine &Name, GlobalObject *Aliasee);
+  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
+                             LinkageTypes Linkage, const Twine &Name,
+                             GlobalObject *Aliasee);
 
   // Type, Parent and AddressSpace taken from the Aliasee.
-  GlobalAlias(LinkageTypes Linkage, const Twine &Name, GlobalObject *Aliasee);
+  static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name,
+                             GlobalObject *Aliasee);
 
   // Linkage, Type, Parent and AddressSpace taken from the Aliasee.
-  GlobalAlias(const Twine &Name, GlobalObject *Aliasee);
+  static GlobalAlias *create(const Twine &Name, GlobalObject *Aliasee);
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Sat May 17 16:29:57 2014
@@ -697,8 +697,8 @@ bool LLParser::ParseAlias(const std::str
 
   // Okay, create the alias but do not insert it into the module yet.
   std::unique_ptr<GlobalAlias> GA(
-      new GlobalAlias(Ty, AddrSpace, (GlobalValue::LinkageTypes)Linkage, Name,
-                      Aliasee, /*Parent*/ nullptr));
+      GlobalAlias::create(Ty, AddrSpace, (GlobalValue::LinkageTypes)Linkage,
+                          Name, Aliasee, /*Parent*/ nullptr));
   GA->setVisibility((GlobalValue::VisibilityTypes)Visibility);
   GA->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass);
 

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sat May 17 16:29:57 2014
@@ -2004,8 +2004,8 @@ error_code BitcodeReader::ParseModule(bo
         return Error(InvalidTypeForValue);
 
       auto *NewGA =
-          new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(),
-                          GetDecodedLinkage(Record[2]), "", TheModule);
+          GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
+                              GetDecodedLinkage(Record[2]), "", TheModule);
       // Old bitcode files didn't have visibility field.
       // Local linkage must have default visibility.
       if (Record.size() > 3 && !NewGA->hasLocalLinkage())

Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Sat May 17 16:29:57 2014
@@ -1489,9 +1489,9 @@ void LLVMSetExternallyInitialized(LLVMVa
 LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee,
                           const char *Name) {
   auto *PTy = cast<PointerType>(unwrap(Ty));
-  return wrap(new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(),
-                              GlobalValue::ExternalLinkage, Name,
-                              unwrap<GlobalObject>(Aliasee), unwrap(M)));
+  return wrap(GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
+                                  GlobalValue::ExternalLinkage, Name,
+                                  unwrap<GlobalObject>(Aliasee), unwrap(M)));
 }
 
 /*--.. Operations on functions .............................................--*/

Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Sat May 17 16:29:57 2014
@@ -225,22 +225,34 @@ GlobalAlias::GlobalAlias(Type *Ty, unsig
     ParentModule->getAliasList().push_back(this);
 }
 
-GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
-                         const Twine &Name, Module *Parent)
-    : GlobalAlias(Ty, AddressSpace, Linkage, Name, nullptr, Parent) {}
-
-GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
-                         const Twine &Name, GlobalObject *Aliasee)
-    : GlobalAlias(Ty, AddressSpace, Linkage, Name, Aliasee,
-                  Aliasee->getParent()) {}
-
-GlobalAlias::GlobalAlias(LinkageTypes Link, const Twine &Name,
-                         GlobalObject *Aliasee)
-    : GlobalAlias(Aliasee->getType()->getElementType(),
-                  Aliasee->getType()->getAddressSpace(), Link, Name, Aliasee) {}
+GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
+                                 LinkageTypes Link, const Twine &Name,
+                                 GlobalObject *Aliasee, Module *ParentModule) {
+  return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
+}
+
+GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
+                                 LinkageTypes Linkage, const Twine &Name,
+                                 Module *Parent) {
+  return create(Ty, AddressSpace, Linkage, Name, nullptr, Parent);
+}
+
+GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
+                                 LinkageTypes Linkage, const Twine &Name,
+                                 GlobalObject *Aliasee) {
+  return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->getParent());
+}
+
+GlobalAlias *GlobalAlias::create(LinkageTypes Link, const Twine &Name,
+                                 GlobalObject *Aliasee) {
+  PointerType *PTy = Aliasee->getType();
+  return create(PTy->getElementType(), PTy->getAddressSpace(), Link, Name,
+                Aliasee);
+}
 
-GlobalAlias::GlobalAlias(const Twine &Name, GlobalObject *Aliasee)
-    : GlobalAlias(Aliasee->getLinkage(), Name, Aliasee) {}
+GlobalAlias *GlobalAlias::create(const Twine &Name, GlobalObject *Aliasee) {
+  return create(Aliasee->getLinkage(), Name, Aliasee);
+}
 
 void GlobalAlias::setParent(Module *parent) {
   if (getParent())

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Sat May 17 16:29:57 2014
@@ -922,8 +922,9 @@ bool ModuleLinker::linkAliasProto(Global
   // If there is no linkage to be performed or we're linking from the source,
   // bring over SGA.
   auto *PTy = cast<PointerType>(TypeMap.get(SGA->getType()));
-  auto *NewDA = new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(),
-                                SGA->getLinkage(), SGA->getName(), DstM);
+  auto *NewDA =
+      GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
+                          SGA->getLinkage(), SGA->getName(), DstM);
   copyGVAttributes(NewDA, SGA);
   if (NewVisibility)
     NewDA->setVisibility(*NewVisibility);

Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Sat May 17 16:29:57 2014
@@ -1328,8 +1328,8 @@ void MergeFunctions::writeThunk(Function
 // Replace G with an alias to F and delete G.
 void MergeFunctions::writeAlias(Function *F, Function *G) {
   PointerType *PTy = G->getType();
-  auto *GA = new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(),
-                             G->getLinkage(), "", F);
+  auto *GA = GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
+                                 G->getLinkage(), "", F);
   F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
   GA->takeName(G);
   GA->setVisibility(G->getVisibility());

Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Sat May 17 16:29:57 2014
@@ -68,8 +68,9 @@ Module *llvm::CloneModule(const Module *
   for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
        I != E; ++I) {
     auto *PTy = cast<PointerType>(I->getType());
-    auto *GA = new GlobalAlias(PTy->getElementType(), PTy->getAddressSpace(),
-                               I->getLinkage(), I->getName(), New);
+    auto *GA =
+        GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
+                            I->getLinkage(), I->getName(), New);
     GA->copyAttributesFrom(I);
     VMap[I] = GA;
   }

Modified: llvm/trunk/unittests/IR/ConstantsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/ConstantsTest.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/ConstantsTest.cpp (original)
+++ llvm/trunk/unittests/IR/ConstantsTest.cpp Sat May 17 16:29:57 2014
@@ -274,7 +274,7 @@ TEST(ConstantsTest, ReplaceInAliasTest)
 
   Type *Int32Ty = Type::getInt32Ty(getGlobalContext());
   auto *Global = cast<GlobalObject>(M->getOrInsertGlobal("dummy", Int32Ty));
-  auto *GA = new GlobalAlias(GlobalValue::ExternalLinkage, "alias", Global);
+  auto *GA = GlobalAlias::create(GlobalValue::ExternalLinkage, "alias", Global);
   EXPECT_DEATH(Global->replaceAllUsesWith(GA),
                "replaceAliasUseWith cannot form an alias cycle");
 }

Modified: llvm/trunk/unittests/IR/VerifierTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/VerifierTest.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/VerifierTest.cpp (original)
+++ llvm/trunk/unittests/IR/VerifierTest.cpp Sat May 17 16:29:57 2014
@@ -52,7 +52,7 @@ TEST(VerifierTest, AliasUnnamedAddr) {
   GlobalVariable *Aliasee = new GlobalVariable(M, Ty, true,
                                                GlobalValue::ExternalLinkage,
                                                Init, "foo");
-  auto *GA = new GlobalAlias(GlobalValue::ExternalLinkage, "bar", Aliasee);
+  auto *GA = GlobalAlias::create(GlobalValue::ExternalLinkage, "bar", Aliasee);
   GA->setUnnamedAddr(true);
   std::string Error;
   raw_string_ostream ErrorOS(Error);

Modified: llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp?rev=209076&r1=209075&r2=209076&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/SpecialCaseList.cpp Sat May 17 16:29:57 2014
@@ -35,7 +35,7 @@ protected:
   }
 
   GlobalAlias *makeAlias(StringRef Name, GlobalObject *Aliasee) {
-    return new GlobalAlias(GlobalValue::ExternalLinkage, Name, Aliasee);
+    return GlobalAlias::create(GlobalValue::ExternalLinkage, Name, Aliasee);
   }
 
   SpecialCaseList *makeSpecialCaseList(StringRef List, std::string &Error) {





More information about the llvm-commits mailing list