Full TypeAliasDecl support in ARMOR (TreeBuilder, USR/NSR generation) + unit tests (Release v0.7.4) - #56
Closed
Likith Viswanath Basina (likivisw) wants to merge 1 commit into
Closed
Conversation
Add full TypeAliasDecl support with typedef-compatible USR/NSR generation, function-pointer alias handling, and improved traversal. Expand ARMOR NSR tests for primitive, chained, container, pointer/reference, and template aliases with metadata validation. Signed-off-by: likith viswanath <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements complete handling of
using X = Ytype alias declarations (TypeAliasDecl) across the ARMOR API-compatibility pipeline, and adds the CMake wiring and unit test coverage needed to validate it.Changes
1. Full
TypeAliasDeclprocessing inTreeBuilderBuildTypeAliasDeclreturn type fromvoidtoboolso traversal control correctly propagates back toVisitTypeAliasDecl.processUnhandledDecl) with fullAPINodeconstruction for non-templated type aliases, including qualified name, data/canonical types, USR, NSR, and access specifier.normalizeFunctionPointerType.processUnhandledDecl.VisitTypeAliasDecltoUSRGeneratorandNSRGeneratorsousing X = Yproduces the same USR/NSR as an equivalenttypedef, keeping identification consistent between the two syntaxes.inactive_code_update, and newcomplex_chains/type_alias_del_changes/template_changescases) to reflect the new output.2. New CMake subdirectories for unit test modules
nsr_generator,qualified_name_generator, andusr_generatorunit test directories intosrc/tests/common/CMakeLists.txt.conftest.pyandmain.cppfixtures for each module.3. Type alias unit tests for the NSR generator
int,float,char,bool, etc.)vector,map,unordered_map,pair,tuple,array)Motivation
using-style type aliases were previously unhandled by the tree builder, causing them to be treated as opaque/unhandled declarations rather than being resolved to their underlying type liketypedef. This meant API compatibility checks could miss or misreport changes involvingusingaliases (including chained aliases, function pointer aliases, and container aliases). This PR closes that gap and backs it with test coverage.Example: v1/v2 Library Header
The new handling lets
typedefandusingbe freely interchanged across library versions without the diff engine flagging a spurious API break, as long as the resolved type is unchanged. It also still catches a real, semantic change at the end of an alias chain.v1/mylib.h
v2/mylib.h
Resulting AST (API) diff
Running the compatibility checker on v1 vs v2 above produces:
[ { "nodeType": "Typedef", "qualifiedName": "size_base_t", "tag": "modified", "children": [ { "nodeType": "Typedef", "qualifiedName": "size_base_t", "dataType": "short", "tag": "removed" }, { "nodeType": "Typedef", "qualifiedName": "size_base_t", "dataType": "int", "tag": "added" } ] } ]handle_t/handle_mid_t/handle_base_tandcallback_t/callback_base_fnproduce no diff entries at all — thetypedef→usingrewrite is correctly recognized as a no-op, which is exactly the false-positive this change eliminates.size_base_tis still correctly reported asmodified, since its underlying type actually widened (short→int), regardless oftypedef/usingspelling.Testing
complex_chains,type_alias_del_changes,template_changes,inactive_code_update.src/tests/common/unit/{nsr_generator,qualified_name_generator,usr_generator}covering type aliases, overloading scenarios, C++ friends, templates, and core USR generation.Notes
typedefhandling —usingaliases now converge to the same USR/NSR output for equivalent declarations.