Skip to content

Commit c48649d

Browse files
annotate private class members as needed (#50)
## Purpose Updates IDS to add the export annotation to private class members that require export. Previously, only public and protected member were exported. ## Overview This patch makes the following changes: 1. Implements `VisitCallExpr` to visit method calls identified in the AST. Common code for exporting method declarations was refactored from `VisitFunctionDecl` into private method `export_function_if_needed`, which is now also called by `VisitCallExpr` for private methods 2. Implements `VisitDeclRefExpr` to visit static fields references identified in the AST. Common code for exporting variable declarations was refactored from `VisitVarDecl` into `export_variable_if_needed`, which is now also called by `VisitDeclRefExpr` for private static fields. 3. Tracks every method, variable, and record declaration that needs an export annotation added in a simple `DeclSet` class. An instance of this class replaces previous `in_exported_record_ ` member bool that was used to track if the "current" record was being exported. This change simplifies things and ensures that we don't mistakenly export the same symbol twice now that there are multiple codepaths. 4. Implements a new `is_in_system_header` method to ensure we skip processing any declarations in system headers (this was missing from `VisitVarDecl`). 5. Adds a bunch of new test cases that fail without the other changes. ## Background Private methods in a class must be exported when they are referenced by inline function definitions. For example: ``` C++ class Example { public: inline int publicMethod() { return privateMethod(); } private: int privateMethod(); }; ``` Similarly, private static fields must in a class must also be exported when referenced by inline function definitions. For example: ``` C++ class Example { public: inline int publicMethod() { return privateStaticFiedl; } private: static int privateStaticField; }; ``` ## Validation 1. Ran existing and new tests on Linux and Windows. 2. Ran on LLVM Support library headers and compared results with previous results & manual fixups. Results matched what I had done manually before (+ a few annotations I missed). --------- Co-authored-by: Saleem Abdulrasool <[email protected]>
1 parent e261cde commit c48649d

File tree

2 files changed

+328
-122
lines changed

2 files changed

+328
-122
lines changed

0 commit comments

Comments
 (0)