| 3496 | } |
| 3497 | |
| 3498 | void BfModule::CheckErrorAttributes(BfTypeInstance* typeInstance, BfMethodInstance* methodInstance, BfFieldInstance* fieldInstance, BfCustomAttributes* customAttributes, BfAstNode* targetSrc) |
| 3499 | { |
| 3500 | if (customAttributes == NULL) |
| 3501 | return; |
| 3502 | |
| 3503 | auto _AddDeclarationMoreInfo = [&]() |
| 3504 | { |
| 3505 | if (methodInstance != NULL) |
| 3506 | { |
| 3507 | if (methodInstance->mMethodDef->mMethodDeclaration != NULL) |
| 3508 | mCompiler->mPassInstance->MoreInfo( |
| 3509 | StrFormat("See method declaration '%s'", MethodToString(methodInstance).c_str()), |
| 3510 | methodInstance->mMethodDef->GetRefNode()); |
| 3511 | } |
| 3512 | else |
| 3513 | { |
| 3514 | mCompiler->mPassInstance->MoreInfo( |
| 3515 | StrFormat("See type declaration '%s'", TypeToString(typeInstance, BfTypeNameFlag_UseUnspecializedGenericParamNames).c_str()), |
| 3516 | typeInstance->mTypeDef->GetRefNode()); |
| 3517 | } |
| 3518 | }; |
| 3519 | |
| 3520 | BfIRConstHolder* constHolder = typeInstance->mConstHolder; |
| 3521 | auto customAttribute = customAttributes->Get(mCompiler->mObsoleteAttributeTypeDef); |
| 3522 | if ((customAttribute != NULL) && (targetSrc != NULL)) |
| 3523 | { |
| 3524 | String err; |
| 3525 | if (fieldInstance != NULL) |
| 3526 | err = StrFormat("'%s' is obsolete", FieldToString(fieldInstance).c_str()); |
| 3527 | else if (methodInstance != NULL) |
| 3528 | err = StrFormat("'%s' is obsolete", MethodToString(methodInstance).c_str()); |
| 3529 | else |
| 3530 | err = StrFormat("'%s' is obsolete", TypeToString(typeInstance, BfTypeNameFlag_UseUnspecializedGenericParamNames).c_str()); |
| 3531 | |
| 3532 | bool isError = false; |
| 3533 | |
| 3534 | if (customAttribute->mCtorArgs.size() >= 1) |
| 3535 | { |
| 3536 | auto constant = constHolder->GetConstant(customAttribute->mCtorArgs[0]); |
| 3537 | if (constant->mTypeCode == BfTypeCode_Boolean) |
| 3538 | { |
| 3539 | isError = constant->mBool; |
| 3540 | } |
| 3541 | else if (constant->mTypeCode == BfTypeCode_StringId) |
| 3542 | { |
| 3543 | String* str = GetStringPoolString(customAttribute->mCtorArgs[0], constHolder); |
| 3544 | if (str != NULL) |
| 3545 | { |
| 3546 | err += ":\n '"; |
| 3547 | err += *str; |
| 3548 | err += "'"; |
| 3549 | } |
| 3550 | |
| 3551 | if (customAttribute->mCtorArgs.size() >= 2) |
| 3552 | { |
| 3553 | constant = constHolder->GetConstant(customAttribute->mCtorArgs[1]); |
| 3554 | isError = constant->mBool; |
| 3555 | } |
no test coverage detected