mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Remove the redundant DeclCtx field in SILFunction.
In all cases the DeclCtx field was supposed to be initialized from the SILLocation of the function, so we can save one pointer per SILFunction. There is one test case change where a different (more precise) diagnostic is being generated after this change.
This commit is contained in:
@@ -126,6 +126,24 @@ SourceLoc SILLocation::getEndSourceLoc(ASTNodeTy N) const {
|
||||
llvm_unreachable("impossible SILLocation");
|
||||
}
|
||||
|
||||
DeclContext *SILLocation::getAsDeclContext() const {
|
||||
if (!isASTNode())
|
||||
return nullptr;
|
||||
if (auto *D = getAsASTNode<Decl>())
|
||||
switch (D->getKind()) {
|
||||
// These four dual-inherit from DeclContext.
|
||||
case DeclKind::Func: return cast<FuncDecl>(D);
|
||||
case DeclKind::Constructor: return cast<ConstructorDecl>(D);
|
||||
case DeclKind::Extension: return cast<ExtensionDecl>(D);
|
||||
case DeclKind::Destructor: return cast<DestructorDecl>(D);
|
||||
default: return D->getDeclContext();
|
||||
}
|
||||
if (auto *E = getAsASTNode<Expr>())
|
||||
if (auto *DC = dyn_cast<AbstractClosureExpr>(E))
|
||||
return DC;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SILLocation::DebugLoc SILLocation::decode(SourceLoc Loc,
|
||||
const SourceManager &SM) {
|
||||
DebugLoc DL;
|
||||
|
||||
Reference in New Issue
Block a user