Add ASTScope support for `@differentiable` attribute. (#27451)
`@differentiable` attribute where clauses may refer to generic
parameters from some generic context.
Without special ASTScope support for `@differentiable` attributes,
ASTScopeLookup.cpp logic tries to resolve the generic parameter
DeclNames in the where clause based on source location alone
(`ASTScopeImpl::findChildContaining`) and fails.
The fix is to add a special `DifferentiableAttributeScope`, mimicking
`SpecializeAttributeScope`. Every `@differentiable` attribute has its
own scope, derived from the declaration on which it is declared.
Unlike `@_specialize`, `@differentiable` may also be declared on
`AbstractStorageDecl` declarations (subscripts and variables).
Resolves TF-815.
`Decl::getSourceRangeIncludingAttrs` should not consider implicit
`@differentiable` attributes generated during `@differentiating`
attribute type-checking.
TF-835 tracks robust lowering for `@differentiating` attributes
that does not involve generating implicit `@differentiable` attributes,
circumventing this issue.