- Don't null-check the ZCC_TreeNode 'this' pointer.

Compilers are allowed to simplify the 'this == nullptr' code block because it makes no sense in 'well-defined C++ code'.
This commit is contained in:
Edoardo Prezioso 2016-11-23 21:50:21 +01:00 committed by Christoph Oelckers
commit cd919e72e1
3 changed files with 52 additions and 47 deletions

View file

@ -161,34 +161,6 @@ struct ZCC_TreeNode
// one of the structures below.
EZCCTreeNodeType NodeType;
// Appends a sibling to this node's sibling list.
void AppendSibling(ZCC_TreeNode *sibling)
{
if (this == nullptr)
{
// Some bad syntax can actually get here, so better abort so that the user can see the error which caused this.
I_FatalError("Internal script compiler error. Execution aborted.");
}
if (sibling == NULL)
{
return;
}
// Check integrity of our sibling list.
assert(SiblingPrev->SiblingNext == this);
assert(SiblingNext->SiblingPrev == this);
// Check integrity of new sibling list.
assert(sibling->SiblingPrev->SiblingNext == sibling);
assert(sibling->SiblingNext->SiblingPrev == sibling);
ZCC_TreeNode *siblingend = sibling->SiblingPrev;
SiblingPrev->SiblingNext = sibling;
sibling->SiblingPrev = SiblingPrev;
SiblingPrev = siblingend;
siblingend->SiblingNext = this;
}
operator FScriptPosition()
{
return FScriptPosition(*SourceName, SourceLoc);
@ -196,6 +168,8 @@ struct ZCC_TreeNode
};
void AppendTreeNodeSibling(ZCC_TreeNode *thisnode, ZCC_TreeNode *sibling);
struct ZCC_Identifier : ZCC_TreeNode
{
ENamedName Id;