Fix a bug that mergeCases table does not match the merge constants.

MergeCases table should not have an entry for MergeContents because atoms with
MergeContents attribute should never have name. This issue was not caught by a
test because getting a value of 6th element of an array of array actually gets
the first element's value of the next array, and that happened to be a valid
value. Added asserts to catch that error.

llvm-svn: 203322
This commit is contained in:
Rui Ueyama 2014-03-08 00:44:01 +00:00
parent bc28340573
commit 7caea31189
2 changed files with 3 additions and 1 deletions

View File

@ -98,8 +98,8 @@ public:
// by linker
mergeAsWeakAndAddressUsed, // Is C++ definition inline definition whose
// address was taken.
mergeByContent, // Merge with other constants with same content
mergeSameNameAndSize, // Another atom with different size is error
mergeByContent, // Merge with other constants with same content.
};
enum ContentType {

View File

@ -113,6 +113,8 @@ static MergeResolution mergeCases[][5] = {
static MergeResolution mergeSelect(DefinedAtom::Merge first,
DefinedAtom::Merge second) {
assert(first != DefinedAtom::mergeByContent);
assert(second != DefinedAtom::mergeByContent);
return mergeCases[first][second];
}