Skip to content

Replace uses of isa/dyn_cast/cast/... member functions #702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jopperm opened this issue Jun 24, 2024 · 2 comments · Fixed by #703
Closed

Replace uses of isa/dyn_cast/cast/... member functions #702

jopperm opened this issue Jun 24, 2024 · 2 comments · Fixed by #703

Comments

@jopperm
Copy link
Contributor

jopperm commented Jun 24, 2024

We recently rebased on top of llvm/llvm-project#90413, causing many deprecation warnings across CIR's codebase. The use of mlir::Type's member functions should be mechanically replaced by the corresponding free functions.

@bcardosolopes
Copy link
Member

We must! I wonder if MLIR folks used clang-tidy or something to fix that. It's also going to be annoying to enforce that during review, but hopefully folks are going to catch up fast.

@jopperm
Copy link
Contributor Author

jopperm commented Jun 25, 2024

I'll look into it!

Hugobros3 pushed a commit to shady-gang/clangir that referenced this issue Oct 2, 2024
…vm#703)

Mechanical rewrite to use the corresponding free functions; fixes llvm#702.

I used a slightly modified version of the `clang-tidy` check provided in
https://discourse.llvm.org/t/psa-deprecating-cast-isa-methods-in-some-classes/70909
to rewrite the C++ source files, regular expressions for the TableGen
files, and manual cleanups where needed (e.g. chains like
`x.foo().cast<A>().bar().cast<B>()`)

I applied the following heuristic to determine which namespace prefix to
use:
- If the target type is not qualified, and the TU has `using namespace
mlir` or the code is inside the `mlir` namespace -> use a plain
`isa`/`cast`/...
- Exception: Always qualify inside custom types and attributes, because
their base classes define the very members we want to get rid of.
- Else. i.e. the target type is qualified as `::mlir::` or `mlir::`, use
that prefix.

The `clang-tidy` check also rewrote `dyn_cast_or_null` to
`dyn_cast_if_present`. I think that's useful because the former variant
is going to be deprecated as well in the future.

I'm using `-Werror=deprecated-declarations` to test the change (see
6b7420a); this required also changing
two occurrences of `StringRef::equals` to `==`. I could also just drop
the commit here; maybe we want to enable `-Werror` in general (there
aren't too many other warnings left in the codebase).

---------

Signed-off-by: Julian Oppermann <[email protected]>
smeenai pushed a commit to smeenai/clangir that referenced this issue Oct 9, 2024
…vm#703)

Mechanical rewrite to use the corresponding free functions; fixes llvm#702.

I used a slightly modified version of the `clang-tidy` check provided in
https://discourse.llvm.org/t/psa-deprecating-cast-isa-methods-in-some-classes/70909
to rewrite the C++ source files, regular expressions for the TableGen
files, and manual cleanups where needed (e.g. chains like
`x.foo().cast<A>().bar().cast<B>()`)

I applied the following heuristic to determine which namespace prefix to
use:
- If the target type is not qualified, and the TU has `using namespace
mlir` or the code is inside the `mlir` namespace -> use a plain
`isa`/`cast`/...
- Exception: Always qualify inside custom types and attributes, because
their base classes define the very members we want to get rid of.
- Else. i.e. the target type is qualified as `::mlir::` or `mlir::`, use
that prefix.

The `clang-tidy` check also rewrote `dyn_cast_or_null` to
`dyn_cast_if_present`. I think that's useful because the former variant
is going to be deprecated as well in the future.

I'm using `-Werror=deprecated-declarations` to test the change (see
6b7420a); this required also changing
two occurrences of `StringRef::equals` to `==`. I could also just drop
the commit here; maybe we want to enable `-Werror` in general (there
aren't too many other warnings left in the codebase).

---------

Signed-off-by: Julian Oppermann <[email protected]>
smeenai pushed a commit to smeenai/clangir that referenced this issue Oct 9, 2024
…vm#703)

Mechanical rewrite to use the corresponding free functions; fixes llvm#702.

I used a slightly modified version of the `clang-tidy` check provided in
https://discourse.llvm.org/t/psa-deprecating-cast-isa-methods-in-some-classes/70909
to rewrite the C++ source files, regular expressions for the TableGen
files, and manual cleanups where needed (e.g. chains like
`x.foo().cast<A>().bar().cast<B>()`)

I applied the following heuristic to determine which namespace prefix to
use:
- If the target type is not qualified, and the TU has `using namespace
mlir` or the code is inside the `mlir` namespace -> use a plain
`isa`/`cast`/...
- Exception: Always qualify inside custom types and attributes, because
their base classes define the very members we want to get rid of.
- Else. i.e. the target type is qualified as `::mlir::` or `mlir::`, use
that prefix.

The `clang-tidy` check also rewrote `dyn_cast_or_null` to
`dyn_cast_if_present`. I think that's useful because the former variant
is going to be deprecated as well in the future.

I'm using `-Werror=deprecated-declarations` to test the change (see
6b7420a); this required also changing
two occurrences of `StringRef::equals` to `==`. I could also just drop
the commit here; maybe we want to enable `-Werror` in general (there
aren't too many other warnings left in the codebase).

---------

Signed-off-by: Julian Oppermann <[email protected]>
keryell pushed a commit to keryell/clangir that referenced this issue Oct 19, 2024
…vm#703)

Mechanical rewrite to use the corresponding free functions; fixes llvm#702.

I used a slightly modified version of the `clang-tidy` check provided in
https://discourse.llvm.org/t/psa-deprecating-cast-isa-methods-in-some-classes/70909
to rewrite the C++ source files, regular expressions for the TableGen
files, and manual cleanups where needed (e.g. chains like
`x.foo().cast<A>().bar().cast<B>()`)

I applied the following heuristic to determine which namespace prefix to
use:
- If the target type is not qualified, and the TU has `using namespace
mlir` or the code is inside the `mlir` namespace -> use a plain
`isa`/`cast`/...
- Exception: Always qualify inside custom types and attributes, because
their base classes define the very members we want to get rid of.
- Else. i.e. the target type is qualified as `::mlir::` or `mlir::`, use
that prefix.

The `clang-tidy` check also rewrote `dyn_cast_or_null` to
`dyn_cast_if_present`. I think that's useful because the former variant
is going to be deprecated as well in the future.

I'm using `-Werror=deprecated-declarations` to test the change (see
6b7420a); this required also changing
two occurrences of `StringRef::equals` to `==`. I could also just drop
the commit here; maybe we want to enable `-Werror` in general (there
aren't too many other warnings left in the codebase).

---------

Signed-off-by: Julian Oppermann <[email protected]>
lanza pushed a commit that referenced this issue Nov 5, 2024
Mechanical rewrite to use the corresponding free functions; fixes #702.

I used a slightly modified version of the `clang-tidy` check provided in
https://discourse.llvm.org/t/psa-deprecating-cast-isa-methods-in-some-classes/70909
to rewrite the C++ source files, regular expressions for the TableGen
files, and manual cleanups where needed (e.g. chains like
`x.foo().cast<A>().bar().cast<B>()`)

I applied the following heuristic to determine which namespace prefix to
use:
- If the target type is not qualified, and the TU has `using namespace
mlir` or the code is inside the `mlir` namespace -> use a plain
`isa`/`cast`/...
- Exception: Always qualify inside custom types and attributes, because
their base classes define the very members we want to get rid of.
- Else. i.e. the target type is qualified as `::mlir::` or `mlir::`, use
that prefix.

The `clang-tidy` check also rewrote `dyn_cast_or_null` to
`dyn_cast_if_present`. I think that's useful because the former variant
is going to be deprecated as well in the future.

I'm using `-Werror=deprecated-declarations` to test the change (see
6b7420a); this required also changing
two occurrences of `StringRef::equals` to `==`. I could also just drop
the commit here; maybe we want to enable `-Werror` in general (there
aren't too many other warnings left in the codebase).

---------

Signed-off-by: Julian Oppermann <[email protected]>
lanza pushed a commit that referenced this issue Mar 18, 2025
Mechanical rewrite to use the corresponding free functions; fixes #702.

I used a slightly modified version of the `clang-tidy` check provided in
https://discourse.llvm.org/t/psa-deprecating-cast-isa-methods-in-some-classes/70909
to rewrite the C++ source files, regular expressions for the TableGen
files, and manual cleanups where needed (e.g. chains like
`x.foo().cast<A>().bar().cast<B>()`)

I applied the following heuristic to determine which namespace prefix to
use:
- If the target type is not qualified, and the TU has `using namespace
mlir` or the code is inside the `mlir` namespace -> use a plain
`isa`/`cast`/...
- Exception: Always qualify inside custom types and attributes, because
their base classes define the very members we want to get rid of.
- Else. i.e. the target type is qualified as `::mlir::` or `mlir::`, use
that prefix.

The `clang-tidy` check also rewrote `dyn_cast_or_null` to
`dyn_cast_if_present`. I think that's useful because the former variant
is going to be deprecated as well in the future.

I'm using `-Werror=deprecated-declarations` to test the change (see
6b7420a); this required also changing
two occurrences of `StringRef::equals` to `==`. I could also just drop
the commit here; maybe we want to enable `-Werror` in general (there
aren't too many other warnings left in the codebase).

---------

Signed-off-by: Julian Oppermann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants