From: Chris Lattner Date: Thu, 19 Feb 2009 17:31:02 +0000 (+0000) Subject: Fix PR3619 by properly considering size modifiers and type quals when X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0be2ef2321b1283ead38ebeb83b451335d90e0fe;p=clang 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 6da1027453..bf36f7f6ed 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -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: diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 024fbf8968..5c02100ec4 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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 =