зеркало из https://github.com/microsoft/clang-1.git
Fix double-free error with sizeof applied to VLA types.
- PR2727. Also, fix warning in CodeGenTypes for new BlockPointer type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55479 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
4ef1c99433
Коммит
9048891ff9
|
@ -540,6 +540,8 @@ public:
|
|||
Expr(SizeOfAlignOfTypeExprClass, resultType),
|
||||
isSizeof(issizeof), Ty(argType), OpLoc(op), RParenLoc(rp) {}
|
||||
|
||||
virtual void Destroy(ASTContext& C);
|
||||
|
||||
bool isSizeOf() const { return isSizeof; }
|
||||
QualType getArgumentType() const { return Ty; }
|
||||
|
||||
|
|
|
@ -1236,6 +1236,11 @@ int64_t UnaryOperator::evaluateOffsetOf(ASTContext& C) const
|
|||
return ::evaluateOffsetOf(C, cast<Expr>(Val)) / CharSize;
|
||||
}
|
||||
|
||||
void SizeOfAlignOfTypeExpr::Destroy(ASTContext& C) {
|
||||
// Override default behavior of traversing children. We do not want
|
||||
// to delete the type.
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Child Iterators for iterating over subexpressions/substatements
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -352,6 +352,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
|
|||
TheModule.addTypeName(TypeName, Res);
|
||||
return Res;
|
||||
}
|
||||
|
||||
case Type::BlockPointer: {
|
||||
assert(0 && "FIXME: Cannot get type of block pointer.");
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: implement.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
int f (int x)
|
||||
{
|
||||
// sizeof applied to a type should not delete the type.
|
||||
return sizeof (int[x]);
|
||||
}
|
Загрузка…
Ссылка в новой задаче