Skip to content

Commit

Permalink
Fixed the destruction of comments another way because this one crashe…
Browse files Browse the repository at this point in the history
…s the OS X build.

See mono#599.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
  • Loading branch information
ddobrev committed Dec 23, 2015
1 parent c05dce7 commit a955116
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
55 changes: 51 additions & 4 deletions src/CppParser/AST.cpp
Expand Up @@ -809,8 +809,6 @@ TranslationUnit* ASTContext::FindOrCreateModule(std::string File)
// Comments
Comment::Comment(CommentKind kind) : Kind(kind) {}

Comment::~Comment() {}

DEF_STRING(RawComment, Text)
DEF_STRING(RawComment, BriefText)

Expand All @@ -827,7 +825,33 @@ FullComment::FullComment() : Comment(CommentKind::FullComment) {}
FullComment::~FullComment()
{
for (auto& block : Blocks)
delete block;
{
// HACK: see https://github.com/mono/CppSharp/issues/599
switch (block->Kind)
{
case CommentKind::BlockCommandComment:
delete static_cast<BlockCommandComment*>(block);
break;
case CommentKind::ParamCommandComment:
delete static_cast<ParamCommandComment*>(block);
break;
case CommentKind::TParamCommandComment:
delete static_cast<TParamCommandComment*>(block);
break;
case CommentKind::VerbatimBlockComment:
delete static_cast<VerbatimBlockComment*>(block);
break;
case CommentKind::VerbatimLineComment:
delete static_cast<VerbatimLineComment*>(block);
break;
case CommentKind::ParagraphComment:
delete static_cast<ParagraphComment*>(block);
break;
default:
delete block;
break;
}
}
}

DEF_VECTOR(FullComment, BlockContentComment*, Blocks)
Expand Down Expand Up @@ -871,7 +895,30 @@ ParagraphComment::ParagraphComment() : BlockContentComment(CommentKind::Paragrap
ParagraphComment::~ParagraphComment()
{
for (auto& content : Content)
delete content;
{
// HACK: see https://github.com/mono/CppSharp/issues/599
switch (content->Kind)
{
case CommentKind::InlineCommandComment:
delete static_cast<InlineCommandComment*>(content);
break;
case CommentKind::HTMLTagComment:
delete static_cast<HTMLTagComment*>(content);
break;
case CommentKind::HTMLStartTagComment:
delete static_cast<HTMLStartTagComment*>(content);
break;
case CommentKind::HTMLEndTagComment:
delete static_cast<HTMLEndTagComment*>(content);
break;
case CommentKind::TextComment:
delete static_cast<TextComment*>(content);
break;
default:
delete content;
break;
}
}
}

DEF_VECTOR(ParagraphComment, InlineContentComment*, Content)
Expand Down
1 change: 0 additions & 1 deletion src/CppParser/AST.h
Expand Up @@ -932,7 +932,6 @@ class CS_API CS_ABSTRACT Comment
{
public:
Comment(CommentKind kind);
virtual ~Comment();
CommentKind Kind;
};

Expand Down

0 comments on commit a955116

Please sign in to comment.