summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-05-17 21:29:57 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-05-17 21:29:57 +0000
commitc86235f4eb3ee71272aed492d3faa18360d54bbc (patch)
tree457375892b6c914a95ac0dc0d8bd5442b484e869
parente7a6c2f1dfca147cdedb9683f7193882b548753d (diff)
downloadllvm-c86235f4eb3ee71272aed492d3faa18360d54bbc.tar.gz
llvm-c86235f4eb3ee71272aed492d3faa18360d54bbc.tar.bz2
llvm-c86235f4eb3ee71272aed492d3faa18360d54bbc.tar.xz
Use create methods since msvc doesn't handle delegating constructors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209076 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/IR/GlobalAlias.h24
-rw-r--r--lib/AsmParser/LLParser.cpp4
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp4
-rw-r--r--lib/IR/Core.cpp6
-rw-r--r--lib/IR/Globals.cpp44
-rw-r--r--lib/Linker/LinkModules.cpp5
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp4
-rw-r--r--lib/Transforms/Utils/CloneModule.cpp5
-rw-r--r--unittests/IR/ConstantsTest.cpp2
-rw-r--r--unittests/IR/VerifierTest.cpp2
-rw-r--r--unittests/Transforms/Utils/SpecialCaseList.cpp2
11 files changed, 62 insertions, 40 deletions
diff --git a/include/llvm/IR/GlobalAlias.h b/include/llvm/IR/GlobalAlias.h
index f5181ab6aa..d9f0b4a89b 100644
--- a/include/llvm/IR/GlobalAlias.h
+++ b/include/llvm/IR/GlobalAlias.h
@@ -33,29 +33,37 @@ class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
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);
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index b463d49af5..4c020c1bfc 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -697,8 +697,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
// 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);
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 478103f982..fe5d57262e 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2004,8 +2004,8 @@ error_code BitcodeReader::ParseModule(bool Resume) {
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())
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index dc3d6f34c8..27ce503e1c 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -1489,9 +1489,9 @@ void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit) {
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 .............................................--*/
diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp
index dae3bad5ea..c905cfe31e 100644
--- a/lib/IR/Globals.cpp
+++ b/lib/IR/Globals.cpp
@@ -225,22 +225,34 @@ GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
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(const Twine &Name, GlobalObject *Aliasee)
- : GlobalAlias(Aliasee->getLinkage(), 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::create(const Twine &Name, GlobalObject *Aliasee) {
+ return create(Aliasee->getLinkage(), Name, Aliasee);
+}
void GlobalAlias::setParent(Module *parent) {
if (getParent())
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 518b681046..45f2d4e03a 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -922,8 +922,9 @@ bool ModuleLinker::linkAliasProto(GlobalAlias *SGA) {
// 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);
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index bcc2835d3d..c3a2b1205c 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -1328,8 +1328,8 @@ void MergeFunctions::writeThunk(Function *F, Function *G) {
// 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());
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
index 4ccdd9c2b8..eb67db1f85 100644
--- a/lib/Transforms/Utils/CloneModule.cpp
+++ b/lib/Transforms/Utils/CloneModule.cpp
@@ -68,8 +68,9 @@ Module *llvm::CloneModule(const Module *M, ValueToValueMapTy &VMap) {
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;
}
diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp
index abab122022..c11729c08f 100644
--- a/unittests/IR/ConstantsTest.cpp
+++ b/unittests/IR/ConstantsTest.cpp
@@ -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");
}
diff --git a/unittests/IR/VerifierTest.cpp b/unittests/IR/VerifierTest.cpp
index 3499bc315e..252bdd333c 100644
--- a/unittests/IR/VerifierTest.cpp
+++ b/unittests/IR/VerifierTest.cpp
@@ -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);
diff --git a/unittests/Transforms/Utils/SpecialCaseList.cpp b/unittests/Transforms/Utils/SpecialCaseList.cpp
index 190167d0c1..fd00687f89 100644
--- a/unittests/Transforms/Utils/SpecialCaseList.cpp
+++ b/unittests/Transforms/Utils/SpecialCaseList.cpp
@@ -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) {