Skip to content

Conversation

@delcypher
Copy link

@delcypher delcypher commented Jan 7, 2025

[BoundsSafety][NFC] Simplify the interface of
BoundsSafetyCheckAssignmentToCountAttrPtrWithIncompletePointeeTy

Previously the interface took a std::functionstd::string. The
rationale behind this was to prevent callers from always allocating and
computing a std::string.

While trying to upstream this code (rdar://133600117)
(llvm#106321) it was pointed out
that there might be a simpler way to implement this.

This patch instead has callers pass

  • a ValueDecl* pointer. In the cases where this isn't known (currently
    return values and unnamed parameters) this can be set to nullptr
  • a boolean flag stating whether or not the ValueDecl* should be fully
    qualified when printed.

This avoids needing to pass a std::function and also avoids std::string
unnecessary allocation.

rdar://142544708

@delcypher delcypher added the clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang label Jan 7, 2025
@delcypher delcypher self-assigned this Jan 7, 2025
@delcypher
Copy link
Author

@swift-ci test

@delcypher
Copy link
Author

@swift-ci test llvm

@delcypher delcypher force-pushed the dev/dliew/refactor-BoundsSafetyCheckAssignmentToCountAttrPtr branch from b18ab14 to 2e4e871 Compare January 7, 2025 23:25
`BoundsSafetyCheckAssignmentToCountAttrPtrWithIncompletePointeeTy`

Previously the interface took a std::function<std::string>. The
rationale behind this was to prevent callers from always allocating and
computing a `std::string`.

While trying to upstream this code (rdar://133600117)
(llvm#106321) it was pointed out
that there might be a simpler way to implement this.

This patch instead has callers pass

* a `ValueDecl*` pointer. In the cases where this isn't known (currently
  return values and unnamed parameters) this can be set to nullptr
* a boolean flag stating whether or not the `ValueDecl*` should be fully
  qualified when printed.

This avoids needing to pass a `std::function` and also avoids `std::string`
unnecessary allocation.

rdar://142544708
@delcypher delcypher force-pushed the dev/dliew/refactor-BoundsSafetyCheckAssignmentToCountAttrPtr branch from 2e4e871 to bb51313 Compare January 8, 2025 13:56
@delcypher delcypher merged commit 5d2794a into next Jan 8, 2025
@delcypher delcypher deleted the dev/dliew/refactor-BoundsSafetyCheckAssignmentToCountAttrPtr branch January 8, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants