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
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 6da1027..bf36f7f 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -838,21 +838,25 @@
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 @@
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:
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 024fbf8..5c02100 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -963,7 +963,7 @@
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 @@
ArrayType::ArraySizeModifier ASM,
unsigned EltTypeQuals) {
llvm::FoldingSetNodeID ID;
- IncompleteArrayType::Profile(ID, EltTy);
+ IncompleteArrayType::Profile(ID, EltTy, ASM, EltTypeQuals);
void *InsertPos = 0;
if (IncompleteArrayType *ATP =