Fix PR3619 by properly considering size modifiers and type quals when

uniquing array types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65046 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-02-19 17:31:02 +00:00
Родитель d8895f64c4
Коммит 0be2ef2321
2 изменённых файлов: 15 добавлений и 8 удалений

Просмотреть файл

@ -838,21 +838,25 @@ public:
class ConstantArrayType : public ArrayType {
llvm::APInt Size; // Allows us to unique the type.
ConstantArrayType(QualType et, QualType can, llvm::APInt sz,
ConstantArrayType(QualType et, QualType can, const llvm::APInt &size,
ArraySizeModifier sm, unsigned tq)
: ArrayType(ConstantArray, et, can, sm, tq), Size(sz) {}
: ArrayType(ConstantArray, et, can, sm, tq), Size(size) {}
friend class ASTContext; // ASTContext creates these.
public:
const llvm::APInt &getSize() const { return Size; }
virtual void getAsStringInternal(std::string &InnerString) const;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType(), getSize());
Profile(ID, getElementType(), getSize(),
getSizeModifier(), getIndexTypeQualifier());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET,
llvm::APInt ArraySize) {
const llvm::APInt &ArraySize, ArraySizeModifier SizeMod,
unsigned TypeQuals) {
ID.AddPointer(ET.getAsOpaquePtr());
ID.AddInteger(ArraySize.getZExtValue());
ID.AddInteger(SizeMod);
ID.AddInteger(TypeQuals);
}
static bool classof(const Type *T) {
return T->getTypeClass() == ConstantArray;
@ -885,11 +889,14 @@ public:
friend class StmtIteratorBase;
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType());
Profile(ID, getElementType(), getSizeModifier(), getIndexTypeQualifier());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET) {
static void Profile(llvm::FoldingSetNodeID &ID, QualType ET,
ArraySizeModifier SizeMod, unsigned TypeQuals) {
ID.AddPointer(ET.getAsOpaquePtr());
ID.AddInteger(SizeMod);
ID.AddInteger(TypeQuals);
}
protected:

Просмотреть файл

@ -963,7 +963,7 @@ QualType ASTContext::getConstantArrayType(QualType EltTy,
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals) {
llvm::FoldingSetNodeID ID;
ConstantArrayType::Profile(ID, EltTy, ArySize);
ConstantArrayType::Profile(ID, EltTy, ArySize, ASM, EltTypeQuals);
void *InsertPos = 0;
if (ConstantArrayType *ATP =
@ -1031,7 +1031,7 @@ QualType ASTContext::getIncompleteArrayType(QualType EltTy,
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals) {
llvm::FoldingSetNodeID ID;
IncompleteArrayType::Profile(ID, EltTy);
IncompleteArrayType::Profile(ID, EltTy, ASM, EltTypeQuals);
void *InsertPos = 0;
if (IncompleteArrayType *ATP =