Skip to content

Instantly share code, notes, and snippets.

@Ruturaj4
Last active August 27, 2023 23:51
Show Gist options
  • Save Ruturaj4/3f39004fec6c3f30c258347affc7c9c4 to your computer and use it in GitHub Desktop.
Save Ruturaj4/3f39004fec6c3f30c258347affc7c9c4 to your computer and use it in GitHub Desktop.
ExtractAPI Objective-C categories

GSoC 2023 Final Submission Report - [ExtractAPI Objective-C categories]

Alt Text

Project Overview

Project Description

Clang, a compiler front-end (a part of LLVM infrastructure) supports symbol graph generation for languages such as C and Objective-C. One way to gather correct API information without exposing unnecessary low-level details, is by using “clang-extract-api” tool. It gathers and serializes information about APIs from header files to JSON output. However, support for Objective-C “categories” is still not complete. The primary objective of this project is to focus on modifying clang’s symbol graph output to generate and to include Objective-C categories and to implement support for generating this information both through clang and through libclang.

Detailed Description

Introducing support for Objective-C Categories for ExtractAPI. The support for Objective-C Categories is currently lacking in terms of categories that extend a type defined in current module and categories that extend types that belong to external modules such as NSString. Thus the objective of this patch is two fold, to fix former and the later.

This is achieved by introducing two new symbols ->

objective-c.module.extension. objective-c.class.extension. Note that the extension represents objective-c "category" (orienting well with Swift's Extension, which in spite that fact that is different, however "broadly" serves similar purpose). The original idea is inspired by Max's @theMomax initial post - https://forums.swift.org/t/symbol-graph-adaptions-for-documenting-extensions-to-external-types-in-docc/56684, and Daniel's helpful comments and feedback. The implementation nonetheless is different serving purpose for this project.

The following diagram well represents the purpose ->

Alt Text

Programming Language Used

  • C++

Challenges Faced

I primarily faced following challenge -

  • It took me a long time to build LLVM from scratch and to debug the LLVM code (due to slow machine). Although I had an access to the faster machine, I decided not to do so.

What I Learned

  • I read others code and learned how to organize code in industry-level projects.
  • Additionally, this practice increased my ability to comprehend code authored by others more efficiently.
  • I used LLDB extensively and thus that increased my knowledge about debugging big codebase in general.
  • I also learned that testing is important to keep the industry standard and one should extensively test their code keeping various edge cases in mind.

Future Work

  • The key work required is to ensure that the generated json (for the Objective-C categories) should be appropriately displayed in the docc preview.

Link to Code

I would like to include following commit link (in LLVM phabricator) to the primary patch.

Special Thanks

I would like to thanks my mentor Daniel Grumberg for helping me in completing all the above objectives.

Conclusion

In conclusion, this project strives to introduce support to the Objective-C categories in LLVM's ExtractAPI. To sum up my GSoC journey, I would like to express my gratitude to mentors and the LLVM Organization for giving me a chance to work on this project.


Many thanks for your time and giving me this opportunity!

Ruturaj Vaidya [GitHub Profile]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment