llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Complete VTable class name for types

Open AmrDeveloper opened this issue 1 year ago • 26 comments

Currently, in the RTTI Builder vTableClassNameForType, we return the VTable Class name for each type. This task's scope is to complete the support for the NYI types and add a test for that.

  • In the VTableClassNameForType function, check branches with NYI error and choose one type.
  • Find and return the correct VTableClass name, either from the ClangIR repository or the classical codegen.
  • Write a test that emits RTTI for that type (Hint: One way is to throw expr with that type).

Notes:

  • Please mention what type you will work on in this issue.
  • Please keep it one PR per type.
  • Check Throws.cpp and CIRGenItaniumCXXAPI.cpp changes for reference in #163078.
  • If the type is handled by you, see no test for it, feel free to add one.

AmrDeveloper avatar Oct 15 '25 17:10 AmrDeveloper

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
  2. Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
  3. Fix the issue locally.
  4. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  5. Create a Git commit.
  6. Run git clang-format HEAD~1 to format your changes.
  7. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

llvmbot avatar Oct 15 '25 17:10 llvmbot

@llvm/issue-subscribers-good-first-issue

Author: Amr Hesham (AmrDeveloper)

Currently, in the RTTI Builder `vTableClassNameForType`, we return the VTable Class name for each type. This task's scope is to complete the support for the NYI types and add a test for that.
  • In the VTableClassNameForType function, check branches with NYI error and choose one type.
  • Find and return the correct VTableClass name, either from the ClangIR repository or the classical codegen.
  • Write a test that emits RTTI for that type (Hint: One way is to throw expr with that type).

Notes:

  • Please mention what type you will work on in this issue.
  • Please keep it one PR per type.
  • Check Throws.cpp and CIRGenItaniumCXXAPI.cpp changes for reference in #163078.
  • If the type is handled by you, see no test for it, feel free to add one.

llvmbot avatar Oct 15 '25 17:10 llvmbot

Hello, I would like to work on the enum type :)

moar55 avatar Oct 15 '25 17:10 moar55

I would like to work on the array types (Type::ConstantArray, Type::IncompleteArray and Type::VariableArray).

MihailMihov avatar Oct 15 '25 23:10 MihailMihov

Hello, I would like to work on the FunctionNoProto and FunctionProto type.

y-Adrian avatar Oct 16 '25 17:10 y-Adrian

Hello, I would like to work on the:

  • Type::ObjCObjectPointer
  • Type::Pointer
  • Type::MemberPointer

please 😇

n2h9 avatar Oct 16 '25 18:10 n2h9

I can also take Auto and DeducedTemplateSpecialization.

moar55 avatar Oct 17 '25 07:10 moar55

I think I have found the correct string to return for Type::ConstantArray, Type::IncompleteArray and Type::VariableArray, _ZTVN10__cxxabiv117__array_type_infoE, but I'm not sure how I could test it.

throw expression applies the array-to-pointer conversion on expression and the other thing I wanted to try is a catch trying to catch an array type, but try doesn't seem to be implemented yet, so I couldn't actually try that. Is there some other possibility that I'm missing here?

MihailMihov avatar Oct 18 '25 13:10 MihailMihov

  • Type::ObjCObjectPointer
  • Type::Pointer
  • Type::MemberPointer

So I did some debugging, and looks like we can do this part for now:

Find and return the correct VTableClass name, either from the ClangIR repository or the classical codegen.

But not this one:

Write a test that emits RTTI for that type (Hint: One way is to throw expr with that type).

Because later in the code during call to CIRGenItaniumRTTIBuilder::buildTypeInfo f.e. line 1405 there is cgm.errorNYI("buildTypeInfo: Pointer"); and hence it will stop execution and not emit RTTI.

Should we for now skip updating this three types in VTableClassNameForType function until they will be implemented in buildTypeInfo ?

@AmrDeveloper

n2h9 avatar Oct 19 '25 13:10 n2h9

  • Type::ObjCObjectPointer
  • Type::Pointer
  • Type::MemberPointer

So I did some debugging, and looks like we can do this part for now:

Find and return the correct VTableClass name, either from the ClangIR repository or the classical codegen.

But not this one:

Write a test that emits RTTI for that type (Hint: One way is to throw expr with that type).

Because later in the code during call to CIRGenItaniumRTTIBuilder::buildTypeInfo f.e. line 1405 there is cgm.errorNYI("buildTypeInfo: Pointer"); and hence it will stop execution and not emit RTTI.

Should we for now skip updating this three types in VTableClassNameForType function until they will be implemented in buildTypeInfo ?

@AmrDeveloper

Yes, If something is not yet implemented, we should skip it for now

AmrDeveloper avatar Oct 20 '25 16:10 AmrDeveloper

Yes, If something is not yet implemented, we should skip it for now

I opened #164155 for the array types, but ran into a similar issue there. There are 3 array types, one of which could be tested once try/catch is upstreamed, but the other 2, unless I'm missing something, can only be tested with typeid, which isn't even implemented in the incubator, so I should close that PR?

MihailMihov avatar Oct 20 '25 18:10 MihailMihov

Yes, If something is not yet implemented, we should skip it for now

I opened #164155 for the array types, but ran into a similar issue there. There are 3 array types, one of which could be tested once try/catch is upstreamed, but the other 2, unless I'm missing something, can only be tested with typeid, which isn't even implemented in the incubator, so I should close that PR?

I think you can keep it as a draft for now, and I will ping you once try/catch is upstreamed (I have already opened a PR for it). I will check typeid too

AmrDeveloper avatar Oct 20 '25 18:10 AmrDeveloper

I have wrote two test cases for my task, but I just don't know how to build and run them on my Mac, I need some help.

Hello, I would like to work on the FunctionNoProto and FunctionProto type.

y-Adrian avatar Oct 28 '25 15:10 y-Adrian

I have wrote two test cases for my task, but I just don't know how to build and run them on my Mac, I need some help.

Hello, I would like to work on the FunctionNoProto and FunctionProto type.

Build clang

ninja clang

Run ClangIR codegen tests

ninja check-clang-cir-codegen

Run a single lit test file (make sure to build clang before)

bin/llvm-lit -sv <path>

AmrDeveloper avatar Oct 28 '25 16:10 AmrDeveloper

@AmrDeveloper Where should I run ninja check-clang-cir-codegen after I build Clang by ninja clang? I don't know run it in which directory. Here is what I got:

ninja: error: unknown target 'check-clang-cir-codegen'

y-Adrian avatar Oct 29 '25 13:10 y-Adrian

@AmrDeveloper Where should I run ninja check-clang-cir-codegen after I build Clang by ninja clang? I don't know run it in which directory. Here is what I got:

ninja: error: unknown target 'check-clang-cir-codegen'

let me link your thread on discourse so if anyone else face the same issue

https://discourse.llvm.org/t/how-to-build-test-on-a-mac/88727/6

AmrDeveloper avatar Oct 29 '25 16:10 AmrDeveloper

Hello. I would like to work on Type::ObjCInterface.

NullSpaceBoy avatar Nov 06 '25 18:11 NullSpaceBoy

Writing down here the types that are already picked up by people so it is easier for new contributors to see which types are already picked.

Type Assignee
Type::ObjCInterface @ARandomDev99
Type::ObjCObjectPointer @n2h9
Type::Pointer @n2h9
Type::MemberPointer @n2h9
Type::FunctionNoProto @y-Adrian
Type::FunctionProto @y-Adrian
Type::ConstantArray @MihailMihov
Type::IncompleteArray @MihailMihov
Type::VariableArray @MihailMihov
Type::Enum @moar55
Type::DeducedTemplateSpecialization @moar55
Type::Auto @moar55

kasha01 avatar Dec 26 '25 00:12 kasha01

  • Type::ObjCObjectPointer
  • Type::Pointer
  • Type::MemberPointer

So I did some debugging, and looks like we can do this part for now:

Find and return the correct VTableClass name, either from the ClangIR repository or the classical codegen.

But not this one:

Write a test that emits RTTI for that type (Hint: One way is to throw expr with that type).

Because later in the code during call to CIRGenItaniumRTTIBuilder::buildTypeInfo f.e. line 1405 there is cgm.errorNYI("buildTypeInfo: Pointer"); and hence it will stop execution and not emit RTTI. Should we for now skip updating this three types in VTableClassNameForType function until they will be implemented in buildTypeInfo ? @AmrDeveloper

Yes, If something is not yet implemented, we should skip it for now

I've looked into the implementation and noticed that buildTypeInfo depends on vTableClassNameForType. Can I try to complete the full implementation for both at the same time?

Perdixky avatar Feb 28 '26 11:02 Perdixky

  • Type::ObjCObjectPointer
  • Type::Pointer
  • Type::MemberPointer

So I did some debugging, and looks like we can do this part for now:

Find and return the correct VTableClass name, either from the ClangIR repository or the classical codegen.

But not this one:

Write a test that emits RTTI for that type (Hint: One way is to throw expr with that type).

Because later in the code during call to CIRGenItaniumRTTIBuilder::buildTypeInfo f.e. line 1405 there is cgm.errorNYI("buildTypeInfo: Pointer"); and hence it will stop execution and not emit RTTI. Should we for now skip updating this three types in VTableClassNameForType function until they will be implemented in buildTypeInfo ? @AmrDeveloper

Yes, If something is not yet implemented, we should skip it for now

I've looked into the implementation and noticed that buildTypeInfo depends on vTableClassNameForType. Can I try to complete the full implementation for both at the same time?

no objections from my side 👍

n2h9 avatar Feb 28 '26 12:02 n2h9