Skip to content

Commit 413824c

Browse files
committed
[AST] Simplify getRecursiveParentPatternStmt
`findParentPatternCaseStmtAndPattern` does more work than is necessary for this, we just want the parent of the canonical var.
1 parent 1983172 commit 413824c

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8227,16 +8227,7 @@ VarDecl *VarDecl::getCanonicalVarDecl() const {
82278227
}
82288228

82298229
Stmt *VarDecl::getRecursiveParentPatternStmt() const {
8230-
// If our parent is already a pattern stmt, just return that.
8231-
if (auto *stmt = getParentPatternStmt())
8232-
return stmt;
8233-
8234-
// Otherwise, see if we have a parent var decl. If we do not, then return
8235-
// nullptr. Otherwise, return the case stmt that we found.
8236-
auto result = findParentPatternCaseStmtAndPattern(this);
8237-
if (!result.has_value())
8238-
return nullptr;
8239-
return result->first;
8230+
return getCanonicalVarDecl()->getParentPatternStmt();
82408231
}
82418232

82428233
/// Return the Pattern involved in initializing this VarDecl. Recall that the

0 commit comments

Comments
 (0)