Be more strict about not calling setAlignment on global aliases.

The fact that GlobalAlias::setAlignment exists at all is a side effect of
how the classes are organized, it should never be used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208094 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-05-06 14:51:36 +00:00
parent 3524723195
commit 55ba6a126f
2 changed files with 15 additions and 6 deletions

View File

@@ -53,15 +53,18 @@ void GlobalValue::destroyConstant() {
/// copyAttributesFrom - copy all additional attributes (those not needed to
/// create a GlobalValue) from the GlobalValue Src to this one.
void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
setAlignment(Src->getAlignment());
setSection(Src->getSection());
if (!isa<GlobalAlias>(this)) {
setAlignment(Src->getAlignment());
setSection(Src->getSection());
}
setVisibility(Src->getVisibility());
setUnnamedAddr(Src->hasUnnamedAddr());
setDLLStorageClass(Src->getDLLStorageClass());
}
void GlobalValue::setAlignment(unsigned Align) {
assert((!isa<GlobalAlias>(this) || !Align) &&
assert((!isa<GlobalAlias>(this)) &&
"GlobalAlias should not have an alignment!");
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
assert(Align <= MaximumAlignment &&