diff options
Diffstat (limited to 'compilerplugins/clang/simplifypointertobool.cxx')
-rw-r--r-- | compilerplugins/clang/simplifypointertobool.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compilerplugins/clang/simplifypointertobool.cxx b/compilerplugins/clang/simplifypointertobool.cxx index 097a78e16f67..11aed0f317b7 100644 --- a/compilerplugins/clang/simplifypointertobool.cxx +++ b/compilerplugins/clang/simplifypointertobool.cxx @@ -131,14 +131,20 @@ public: bool PreTraverseIfStmt(IfStmt* stmt) { - contextuallyConvertedExprs_.push_back(stmt->getCond()->IgnoreParenImpCasts()); + if (auto const cond = stmt->getCond()) + { + contextuallyConvertedExprs_.push_back(cond->IgnoreParenImpCasts()); + } return true; } - bool PostTraverseIfStmt(IfStmt*, bool) + bool PostTraverseIfStmt(IfStmt* stmt, bool) { - assert(!contextuallyConvertedExprs_.empty()); - contextuallyConvertedExprs_.pop_back(); + if (stmt->getCond() != nullptr) + { + assert(!contextuallyConvertedExprs_.empty()); + contextuallyConvertedExprs_.pop_back(); + } return true; } |