mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[ASTScope] Introduce isa/cast/dyn_cast support to ASTScope hierarchy
The ASTScope class hierarchy rooted at ASTScopeImpl is relying entirely on overridden virtual functions and, in some cases, string comparisons on the class name, to provide customization for the various classes. Introduce proper LLVM dynamic casting support to this class hierarchy, eliminating the string comparisons and the manually-specified implementations of `getClassName` (which is now used only for printing). We've been meaning to do this for years, but today I got angry enough.
This commit is contained in:
@@ -116,8 +116,7 @@ SourceRange FunctionBodyScope::getSourceRangeOfThisASTNode(
|
||||
const bool omitAssertions) const {
|
||||
// If this function body scope is synthesized for a body macro, use the
|
||||
// real source range.
|
||||
if (getChildren().size() == 1 &&
|
||||
getChildren()[0]->getClassName() == "ASTSourceFileScope") {
|
||||
if (getChildren().size() == 1 && isa<ASTSourceFileScope>(getChildren()[0])) {
|
||||
return decl->getBodySourceRange();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user