Special case aliases in GlobalValue::getSection.

This is similar to the getAlignment patch, but is done just for
completeness. It looks like we never call getSection on an alias. All the
tests still pass if the if is replaced with an assert.

llvm-svn: 208139
This commit is contained in:
Rafael Espindola 2014-05-06 22:44:30 +00:00
parent 0c4833f07e
commit 8d8f100c57
3 changed files with 8 additions and 3 deletions

View File

@ -106,8 +106,8 @@ public:
}
void setDLLStorageClass(DLLStorageClassTypes C) { DllStorageClass = C; }
bool hasSection() const { return !Section.empty(); }
const std::string &getSection() const { return Section; }
bool hasSection() const { return !getSection().empty(); }
const std::string &getSection() const;
void setSection(StringRef S);
/// getType - Global values are always pointers.

View File

@ -80,6 +80,12 @@ void GlobalValue::setAlignment(unsigned Align) {
assert(getAlignment() == Align && "Alignment representation error!");
}
const std::string &GlobalValue::getSection() const {
if (auto *GA = dyn_cast<GlobalAlias>(this))
return GA->getAliasedGlobal()->getSection();
return Section;
}
void GlobalValue::setSection(StringRef S) {
assert(!isa<GlobalAlias>(this) && "GlobalAlias should not have a section!");
Section = S;

View File

@ -476,7 +476,6 @@ void Verifier::visitGlobalAlias(const GlobalAlias &GA) {
Assert1(GA.getType() == GA.getAliasee()->getType(),
"Alias and aliasee types should match!", &GA);
Assert1(!GA.hasUnnamedAddr(), "Alias cannot have unnamed_addr!", &GA);
Assert1(!GA.hasSection(), "Alias cannot have a section!", &GA);
const Constant *Aliasee = GA.getAliasee();
const GlobalValue *GV = dyn_cast<GlobalValue>(Aliasee);