diff options
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 4e061a9fbe..2b307c86e3 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -37,6 +37,18 @@ void Type::Destroy(ASTContext& C) { C.Deallocate(this); } +void ConstantArrayWithExprType::Destroy(ASTContext& C) { + // FIXME: destruction of SizeExpr commented out due to resource contention. + // SizeExpr->Destroy(C); + // See FIXME in SemaDecl.cpp:1536: if we were able to either steal + // or clone the SizeExpr there, then here we could freely delete it. + // Since we do not know how to steal or clone, we keep a pointer to + // a shared resource, but we cannot free it. + // (There probably is a trivial solution ... for people knowing clang!). + this->~ConstantArrayWithExprType(); + C.Deallocate(this); +} + void VariableArrayType::Destroy(ASTContext& C) { if (SizeExpr) SizeExpr->Destroy(C); @@ -163,6 +175,8 @@ bool Type::isDerivedType() const { case Pointer: case VariableArray: case ConstantArray: + case ConstantArrayWithExpr: + case ConstantArrayWithoutExpr: case IncompleteArray: case FunctionProto: case FunctionNoProto: @@ -1339,6 +1353,29 @@ void ConstantArrayType::getAsStringInternal(std::string &S, const PrintingPolicy getElementType().getAsStringInternal(S, Policy); } +void ConstantArrayWithExprType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const { + if (Policy.ConstantArraySizeAsWritten) { + std::string SStr; + llvm::raw_string_ostream s(SStr); + getSizeExpr()->printPretty(s, 0, Policy); + S += '['; + S += s.str(); + S += ']'; + getElementType().getAsStringInternal(S, Policy); + } + else + ConstantArrayType::getAsStringInternal(S, Policy); +} + +void ConstantArrayWithoutExprType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const { + if (Policy.ConstantArraySizeAsWritten) { + S += "[]"; + getElementType().getAsStringInternal(S, Policy); + } + else + ConstantArrayType::getAsStringInternal(S, Policy); +} + void IncompleteArrayType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const { S += "[]"; |