diff --git a/src/beta/include/tree_builder.hpp b/src/beta/include/tree_builder.hpp index e0f78a7..333ccac 100644 --- a/src/beta/include/tree_builder.hpp +++ b/src/beta/include/tree_builder.hpp @@ -72,7 +72,7 @@ class TreeBuilder { void BuildClassTemplateDecl(clang::ClassTemplateDecl* Decl); void BuildClassTemplateSpecializationDecl(clang::ClassTemplateSpecializationDecl* Decl); void BuildClassTemplatePartialSpecializationDecl(clang::ClassTemplatePartialSpecializationDecl* Decl); - void BuildTypeAliasDecl(clang::TypeAliasDecl* Decl); + bool BuildTypeAliasDecl(clang::TypeAliasDecl* Decl); void BuildUsingDecl(clang::UsingDecl* Decl); void BuildUsingDirectiveDecl(clang::UsingDirectiveDecl* Decl); void BuildNamespaceAliasDecl(clang::NamespaceAliasDecl* Decl); diff --git a/src/beta/src/astnormalizer.cpp b/src/beta/src/astnormalizer.cpp index a872e62..a032f47 100644 --- a/src/beta/src/astnormalizer.cpp +++ b/src/beta/src/astnormalizer.cpp @@ -320,8 +320,7 @@ bool beta::ASTNormalize::VisitFunctionDecl(clang::FunctionDecl *Decl) { } bool beta::ASTNormalize::VisitTypeAliasDecl(clang::TypeAliasDecl *Decl) { - treeBuilder.BuildTypeAliasDecl(Decl); - return true; + return treeBuilder.BuildTypeAliasDecl(Decl); } bool beta::ASTNormalize::VisitTypedefDecl(clang::TypedefDecl *Decl) { diff --git a/src/beta/src/tree_builder.cpp b/src/beta/src/tree_builder.cpp index bae349d..f8e58f5 100644 --- a/src/beta/src/tree_builder.cpp +++ b/src/beta/src/tree_builder.cpp @@ -1018,13 +1018,49 @@ void beta::TreeBuilder::BuildClassTemplatePartialSpecializationDecl(clang::Class processUnhandledDecl(Decl); } -void beta::TreeBuilder::BuildTypeAliasDecl(clang::TypeAliasDecl* Decl) { - if (!IsDeclFromMainFileAndNotLocal(Decl) || isWrittenInTemplatedClass(Decl)) return; +bool beta::TreeBuilder::BuildTypeAliasDecl(clang::TypeAliasDecl* Decl) { + if(!IsDeclFromMainFileAndNotLocal(Decl) || isInTemplatedClass(Decl) || Decl->isTemplated()){ + if(IsDeclFromMainFileAndNotLocal(Decl) && !isWrittenInTemplatedClass(Decl)){ armor::debug() << "Excluding TypeAliasDecl\n"; TEST_LOG << "TypeAliasDecl\n"; + processUnhandledDecl(Decl); + } + return false; + } - processUnhandledDecl(Decl); + const std::string USR = ::generateUSRForDecl(Decl); + if( context->usrNodeMap.find(USR) != context->usrNodeMap.end() ) return true; + llvm::SmallString<128> nameBuf; + llvm::raw_svector_ostream OS(nameBuf); + const clang::QualType underlyingType = Decl->getUnderlyingType(); + auto typeDefNode = std::make_shared(); + Decl->printName(OS); + PushName(nameBuf); + typeDefNode->qualifiedName = GetCurrentQualifiedName(); + typeDefNode->kind = NodeKind::Typedef; + auto [dataType, canonicalType] = getTypesWithAndWithoutTypeResolution(underlyingType, Decl->getASTContext()); + typeDefNode->dataType = dataType; + typeDefNode->caonicalType = canonicalType; + typeDefNode->USR = USR; + typeDefNode->NSR = ::generateNSRForDecl(Decl); + typeDefNode->access = getAccessSpecifier(Decl->getAccess()); + context->usrNodeMap.insert_or_assign(std::move(USR), typeDefNode); + armor::debug() << "VisitTypeAliasDecl V2: " << typeDefNode->qualifiedName << "\n"; + if (!llvm::isa(underlyingType)) { + if (const clang::TypeSourceInfo *TSI = Decl->getTypeSourceInfo()) { + auto [typeModifiers,unwrappedTL] = unwrapTypeLoc(TSI->getTypeLoc()); + if (const clang::FunctionProtoTypeLoc FTL = unwrappedTL.getAs()) { + typeDefNode->dataType = std::string{}; + PushNode(typeDefNode); + normalizeFunctionPointerType(typeModifiers, FTL, Decl); + PopNode(); + } + } + } + PopName(); + AddNode(typeDefNode); + return true; } void beta::TreeBuilder::BuildUsingDecl(clang::UsingDecl* Decl) { diff --git a/src/common/src/custom_usr_generator.cpp b/src/common/src/custom_usr_generator.cpp index f8ac4ea..739de6a 100644 --- a/src/common/src/custom_usr_generator.cpp +++ b/src/common/src/custom_usr_generator.cpp @@ -98,6 +98,7 @@ class USRGenerator : public ConstDeclVisitor { void VisitClassTemplateDecl(const ClassTemplateDecl *D); void VisitTagDecl(const TagDecl *D); void VisitTypedefDecl(const TypedefDecl *D); + void VisitTypeAliasDecl(const TypeAliasDecl *D); void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D); void VisitVarDecl(const VarDecl *D); void VisitFriendDecl(const FriendDecl *D); @@ -531,6 +532,15 @@ void USRGenerator::VisitTypedefDecl(const TypedefDecl *D) { Out << "@T@"; Out << D->getName(); } +void USRGenerator::VisitTypeAliasDecl(const TypeAliasDecl *D) { + if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D))) + return; + const DeclContext *DC = D->getDeclContext(); + if (const NamedDecl *DCN = dyn_cast(DC)) + Visit(DCN); + Out << "@T@"; + Out << D->getName(); +} void USRGenerator::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) { GenLoc(D, /*IncludeOffset=*/true); diff --git a/src/common/src/nsr_generator.cpp b/src/common/src/nsr_generator.cpp index d2cded1..7190034 100644 --- a/src/common/src/nsr_generator.cpp +++ b/src/common/src/nsr_generator.cpp @@ -98,6 +98,7 @@ class NSRGenerator : public ConstDeclVisitor { void VisitClassTemplateDecl(const ClassTemplateDecl *D); void VisitTagDecl(const TagDecl *D); void VisitTypedefDecl(const TypedefDecl *D); + void VisitTypeAliasDecl(const TypeAliasDecl *D); // void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D); void VisitVarDecl(const VarDecl *D); void VisitFriendDecl(const FriendDecl *D); @@ -528,6 +529,15 @@ void NSRGenerator::VisitTypedefDecl(const TypedefDecl *D) { Out << "@T@"; Out << D->getName(); } +void NSRGenerator::VisitTypeAliasDecl(const TypeAliasDecl *D) { + if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D))) + return; + const DeclContext *DC = D->getDeclContext(); + if (const NamedDecl *DCN = dyn_cast(DC)) + Visit(DCN); + Out << "@T@"; + Out << D->getName(); +} // void USRGenerator::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) { // GenLoc(D, /*IncludeOffset=*/true); diff --git a/src/common/src/qualified_name_generator.cpp b/src/common/src/qualified_name_generator.cpp index 74e0eb3..c18d8b3 100644 --- a/src/common/src/qualified_name_generator.cpp +++ b/src/common/src/qualified_name_generator.cpp @@ -61,6 +61,7 @@ class USRGenerator : public ConstDeclVisitor { void VisitClassTemplateDecl(const ClassTemplateDecl *D); void VisitTagDecl(const TagDecl *D); void VisitTypedefDecl(const TypedefDecl *D); + void VisitTypeAliasDecl(const TypeAliasDecl *D); void VisitVarDecl(const VarDecl *D); void VisitBindingDecl(const BindingDecl *D); void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D); @@ -323,6 +324,14 @@ void USRGenerator::VisitTypedefDecl(const TypedefDecl *D) { Out << D->getName(); } +void USRGenerator::VisitTypeAliasDecl(const TypeAliasDecl *D) { + const unsigned startSize = Buf.size(); + const DeclContext *DC = D->getDeclContext(); + if (const NamedDecl *DCN = dyn_cast(DC)) Visit(DCN); + const unsigned endSize = Buf.size(); + startSize == endSize ? Out : Out << "::"; + Out << D->getName(); +} void USRGenerator::GenExtSymbolContainer(const NamedDecl *D) { StringRef Container = GetExternalSourceContainer(D); if (!Container.empty()) diff --git a/src/tests/armor/functional/inactive_code_update/expected_output.txt b/src/tests/armor/functional/inactive_code_update/expected_output.txt index d404145..6ce4b09 100644 --- a/src/tests/armor/functional/inactive_code_update/expected_output.txt +++ b/src/tests/armor/functional/inactive_code_update/expected_output.txt @@ -139,14 +139,6 @@ 2354681959671418142 // End of mylib.h - Compact version with preprocessing, templates, classes, structs, unions ---------------------------------------- -TypeAliasDecl -4778056794275737411 -using byte_t = uint8_t ----------------------------------------- -TypeAliasDecl -12067307721732456158 -using size_type = std::size_t ----------------------------------------- EnumConst ErrorCode:SUCCESS Get the actual end location (after the last token) startOffset == endOffset @@ -712,14 +704,6 @@ processData 2354681959671418142 // End of mylib.h - Compact version with preprocessing, templates, classes, structs, unions ---------------------------------------- -TypeAliasDecl -4778056794275737411 -using byte_t = uint8_t ----------------------------------------- -TypeAliasDecl -12067307721732456158 -using size_type = std::size_t ----------------------------------------- EnumConst ErrorCode:SUCCESS Get the actual end location (after the last token) startOffset == endOffset @@ -1182,7 +1166,6 @@ comments1 1748340414771073951 : 1 ---------------------------------------- unhandledDecls1 -11044959451838826049 : 1 5527843489271040135 : 1 1567017602521651188 : 1 5323582179407016097 : 1 @@ -1197,7 +1180,6 @@ unhandledDecls1 10705571255276855191 : 4 10585965716865580119 : 1 7497696533842709105 : 1 -12067307721732456158 : 1 1402593494274183058 : 1 13074568307166890559 : 1 14191502057406420813 : 1 @@ -1212,12 +1194,12 @@ unhandledDecls1 4504840211387841570 : 1 15464300162902583911 : 1 8068769666068225577 : 1 -4778056794275737411 : 1 +13117341127079206593 : 1 12700262454154676125 : 1 8733956534700832650 : 1 15173472626001195300 : 1 15219203312359965853 : 1 -13117341127079206593 : 1 +11044959451838826049 : 1 9884558697256544607 : 1 15521860531219160998 : 3 8717144482643656166 : 1 @@ -1278,7 +1260,6 @@ comments2 1748340414771073951 : 1 ---------------------------------------- unhandledDecls2 -11044959451838826049 : 1 5527843489271040135 : 1 1567017602521651188 : 1 5323582179407016097 : 1 @@ -1292,7 +1273,6 @@ unhandledDecls2 11687501982600197290 : 1 10705571255276855191 : 4 10585965716865580119 : 1 -12067307721732456158 : 1 1402593494274183058 : 1 13074568307166890559 : 1 14191502057406420813 : 1 @@ -1307,12 +1287,12 @@ unhandledDecls2 4504840211387841570 : 1 15464300162902583911 : 1 8068769666068225577 : 1 -4778056794275737411 : 1 +13117341127079206593 : 1 12700262454154676125 : 1 8733956534700832650 : 1 15173472626001195300 : 1 15219203312359965853 : 1 -13117341127079206593 : 1 +11044959451838826049 : 1 618311601172597535 : 1 9884558697256544607 : 1 15521860531219160998 : 3 diff --git a/src/tests/beta/functional/complex_chains/expected_output.json b/src/tests/beta/functional/complex_chains/expected_output.json new file mode 100644 index 0000000..0879e00 --- /dev/null +++ b/src/tests/beta/functional/complex_chains/expected_output.json @@ -0,0 +1,84 @@ +[ + { + "children": [ + { + "dataType": "unsigned int", + "nodeType": "Enumerator", + "qualifiedName": "StatusCode::STATUS_OK" + }, + { + "dataType": "unsigned int", + "nodeType": "Enumerator", + "qualifiedName": "StatusCode::STATUS_FAIL" + }, + { + "dataType": "unsigned int", + "nodeType": "Enumerator", + "qualifiedName": "StatusCode::STATUS_PENDING" + } + ], + "nodeType": "Enum", + "qualifiedName": "StatusCode", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "StatusCode", + "nodeType": "Typedef", + "qualifiedName": "StatusCode", + "tag": "removed" + }, + { + "dataType": "enum StatusCodeEnum", + "nodeType": "Typedef", + "qualifiedName": "StatusCode", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "StatusCode", + "tag": "modified" + }, + { + "children": [ + { + "dataType": "short", + "nodeType": "Typedef", + "qualifiedName": "size_base_t", + "tag": "removed" + }, + { + "dataType": "int", + "nodeType": "Typedef", + "qualifiedName": "size_base_t", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "size_base_t", + "tag": "modified" + }, + { + "children": [ + { + "dataType": "unsigned int", + "nodeType": "Enumerator", + "qualifiedName": "StatusCodeEnum::STATUS_OK" + }, + { + "dataType": "unsigned int", + "nodeType": "Enumerator", + "qualifiedName": "StatusCodeEnum::STATUS_FAIL" + }, + { + "dataType": "unsigned int", + "nodeType": "Enumerator", + "qualifiedName": "StatusCodeEnum::STATUS_PENDING" + } + ], + "nodeType": "Enum", + "qualifiedName": "StatusCodeEnum", + "tag": "added" + } +] diff --git a/src/tests/beta/functional/complex_chains/test_complex_chains.py b/src/tests/beta/functional/complex_chains/test_complex_chains.py new file mode 100644 index 0000000..068d846 --- /dev/null +++ b/src/tests/beta/functional/complex_chains/test_complex_chains.py @@ -0,0 +1,29 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import json +import subprocess +from deepdiff import DeepDiff + + +def test_ast_diff(binary_path, binary_args, request): + + test_dir = os.path.dirname(request.fspath) + + subprocess.run( + [binary_path] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + with open(f'{test_dir}/expected_output.json', 'r') as f: + expected_json = json.load(f) + + with open(f'{test_dir}/debug_output/ast_diffs/ast_diff_output_mylib.h.json', 'r') as f: + actual_json = json.load(f) + + diff = DeepDiff(expected_json, actual_json['astDiff'], ignore_order=True) + + assert diff == {} diff --git a/src/tests/beta/functional/complex_chains/v1/mylib.h b/src/tests/beta/functional/complex_chains/v1/mylib.h new file mode 100644 index 0000000..37cd292 --- /dev/null +++ b/src/tests/beta/functional/complex_chains/v1/mylib.h @@ -0,0 +1,65 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include "stdint.h" + +// --------------------------------------------------------------------------- +// 1. Plain typedef chain (unchanged in v2) — sanity baseline. +// --------------------------------------------------------------------------- +typedef int32_t base_int_t; +typedef base_int_t mid_int_t; +typedef mid_int_t top_int_t; + +// --------------------------------------------------------------------------- +// 2. typedef chain in v1 -> using chain in v2, same resolved type each hop. +// --------------------------------------------------------------------------- +typedef uint32_t handle_base_t; +typedef handle_base_t handle_mid_t; +typedef handle_mid_t handle_t; + +// --------------------------------------------------------------------------- +// 3. using chain in v1 -> typedef chain in v2, same resolved type each hop. +// --------------------------------------------------------------------------- +using token_base_t = uint16_t; +using token_mid_t = token_base_t; +using token_t = token_mid_t; + +// --------------------------------------------------------------------------- +// 4. Mixed chain: typedef -> using -> typedef, same resolved type in v2 +// (order/kind of each hop flips, but the final canonical type is stable). +// --------------------------------------------------------------------------- +typedef int64_t mixed_base_t; +using mixed_mid_t = mixed_base_t; +typedef mixed_mid_t mixed_top_t; + +// --------------------------------------------------------------------------- +// 5. Function-pointer typedef chain -> using chain, same signature. +// --------------------------------------------------------------------------- +typedef void (*callback_base_fn)(int code, const char *msg); +typedef callback_base_fn callback_t; + +// --------------------------------------------------------------------------- +// 6. Anonymous-enum-with-typedef-name -> named-enum-with-using-alias. +// --------------------------------------------------------------------------- +typedef enum +{ + STATUS_OK = 0, + STATUS_FAIL, + STATUS_PENDING +} StatusCode; + +// --------------------------------------------------------------------------- +// 7. Chain that DOES change semantically at the far end (real incompatible +// change) — the alias itself is untouched, but the base type widens. +// --------------------------------------------------------------------------- +typedef int16_t size_base_t; +typedef size_base_t size_mid_t; +typedef size_mid_t size_t_alias; + +// --------------------------------------------------------------------------- +// 8. Deep chain (5 hops) to exercise multi-level resolution both directions. +// --------------------------------------------------------------------------- +typedef uint8_t deep_l1_t; +typedef deep_l1_t deep_l2_t; +typedef deep_l2_t deep_l3_t; +typedef deep_l3_t deep_l4_t; +typedef deep_l4_t deep_l5_t; diff --git a/src/tests/beta/functional/complex_chains/v2/mylib.h b/src/tests/beta/functional/complex_chains/v2/mylib.h new file mode 100644 index 0000000..ebc446f --- /dev/null +++ b/src/tests/beta/functional/complex_chains/v2/mylib.h @@ -0,0 +1,67 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include "stdint.h" + +// --------------------------------------------------------------------------- +// 1. Plain typedef chain (unchanged) — sanity baseline. +// --------------------------------------------------------------------------- +typedef int32_t base_int_t; +typedef base_int_t mid_int_t; +typedef mid_int_t top_int_t; + +// --------------------------------------------------------------------------- +// 2. typedef chain in v1 -> using chain in v2, same resolved type each hop. +// --------------------------------------------------------------------------- +using handle_base_t = uint32_t; +using handle_mid_t = handle_base_t; +using handle_t = handle_mid_t; + +// --------------------------------------------------------------------------- +// 3. using chain in v1 -> typedef chain in v2, same resolved type each hop. +// --------------------------------------------------------------------------- +typedef uint16_t token_base_t; +typedef token_base_t token_mid_t; +typedef token_mid_t token_t; + +// --------------------------------------------------------------------------- +// 4. Mixed chain: typedef -> using -> typedef in v1 becomes +// using -> typedef -> using in v2, same resolved type throughout. +// --------------------------------------------------------------------------- +using mixed_base_t = int64_t; +typedef mixed_base_t mixed_mid_t; +using mixed_top_t = mixed_mid_t; + +// --------------------------------------------------------------------------- +// 5. Function-pointer typedef chain -> using chain, same signature. +// --------------------------------------------------------------------------- +using callback_base_fn = void (*)(int code, const char *msg); +using callback_t = callback_base_fn; + +// --------------------------------------------------------------------------- +// 6. Anonymous-enum-with-typedef-name -> named-enum-with-using-alias. +// --------------------------------------------------------------------------- +enum StatusCodeEnum +{ + STATUS_OK = 0, + STATUS_FAIL, + STATUS_PENDING +}; +using StatusCode = StatusCodeEnum; + +// --------------------------------------------------------------------------- +// 7. Chain that DOES change semantically at the far end (real incompatible +// change) — the alias name is untouched, but the base type widens from +// int16_t to int32_t, so size_t_alias's canonical type must differ. +// --------------------------------------------------------------------------- +typedef int32_t size_base_t; +typedef size_base_t size_mid_t; +typedef size_mid_t size_t_alias; + +// --------------------------------------------------------------------------- +// 8. Deep chain (5 hops), typedef chain flipped to using chain throughout. +// --------------------------------------------------------------------------- +using deep_l1_t = uint8_t; +using deep_l2_t = deep_l1_t; +using deep_l3_t = deep_l2_t; +using deep_l4_t = deep_l3_t; +using deep_l5_t = deep_l4_t; diff --git a/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.json b/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.json index a4ba0e4..d35c8cb 100644 --- a/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.json +++ b/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.json @@ -847,6 +847,12 @@ "qualifiedName": "ResourceManager", "tag": "removed" }, + { + "dataType": "std::variant", + "nodeType": "Typedef", + "qualifiedName": "Value", + "tag": "removed" + }, { "children": [ { diff --git a/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.txt b/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.txt index 2ebdb5b..eda6420 100644 --- a/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.txt +++ b/src/tests/beta/functional/flow_cxx_adv_template_categorisation/expected_output.txt @@ -564,10 +564,6 @@ std::unique_ptr make_unique_with_args(Args&&... args) { return std::make_unique(std::forward(args)...); } ---------------------------------------- -TypeAliasDecl -5643335536656467175 -using Value = std::variant ----------------------------------------- Function Body process 9063025977719545702 @@ -1008,7 +1004,6 @@ unhandledDecls1 13816479023391194073 : 1 11442841472222897421 : 1 12073625207878275815 : 1 -5643335536656467175 : 1 7216266635772902375 : 1 12814579946915968411 : 1 11160874710484048764 : 1 diff --git a/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.json b/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.json index 851eadc..95e50ad 100644 --- a/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.json +++ b/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.json @@ -197,6 +197,12 @@ "qualifiedName": "sample_matrix", "tag": "removed" }, + { + "dataType": "std::function (const std::vector &, double)>", + "nodeType": "Typedef", + "qualifiedName": "ComplexFunctionType", + "tag": "removed" + }, { "dataType": "std::map", "nodeType": "Variable", diff --git a/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.txt b/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.txt index dd5dc88..6b0a751 100644 --- a/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.txt +++ b/src/tests/beta/functional/flow_decl_init_categorisation/expected_output.txt @@ -767,10 +767,6 @@ sample_matrix{ {4, 5, 6} } ---------------------------------------- -TypeAliasDecl -15529516918349818119 -using ComplexFunctionType = std::function(const std::vector&, double)> ----------------------------------------- Var init signal_processors 17592249031386877950 @@ -1158,7 +1154,6 @@ comments1 ---------------------------------------- unhandledDecls1 1771605423457679277 : 1 -15529516918349818119 : 1 14784299442328131169 : 1 4670556794927485077 : 1 7455076031092283842 : 1 diff --git a/src/tests/beta/functional/template_changes/expected_output.json b/src/tests/beta/functional/template_changes/expected_output.json index 2c38e45..ce31d56 100644 --- a/src/tests/beta/functional/template_changes/expected_output.json +++ b/src/tests/beta/functional/template_changes/expected_output.json @@ -1,4 +1,42 @@ [ + { + "children": [ + { + "dataType": "class std::vector>", + "nodeType": "Typedef", + "qualifiedName": "IntVector", + "tag": "removed" + }, + { + "dataType": "class std::vector>", + "nodeType": "Typedef", + "qualifiedName": "IntVector", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "IntVector", + "tag": "modified" + }, + { + "children": [ + { + "dataType": "class std::function", + "nodeType": "Typedef", + "qualifiedName": "StringCallback", + "tag": "removed" + }, + { + "dataType": "class std::function, class std::allocator> &)>", + "nodeType": "Typedef", + "qualifiedName": "StringCallback", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "StringCallback", + "tag": "modified" + }, { "children": [ { diff --git a/src/tests/beta/functional/type_alias_del_changes/expected_output.json b/src/tests/beta/functional/type_alias_del_changes/expected_output.json new file mode 100644 index 0000000..a040f9a --- /dev/null +++ b/src/tests/beta/functional/type_alias_del_changes/expected_output.json @@ -0,0 +1,872 @@ +{ + "astDiff": [ + { + "children": [ + { + "dataType": "int", + "nodeType": "Typedef", + "qualifiedName": "Int32", + "tag": "removed" + }, + { + "dataType": "long", + "nodeType": "Typedef", + "qualifiedName": "Int32", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "Int32", + "tag": "modified" + }, + { + "children": [ + { + "dataType": "float", + "nodeType": "Typedef", + "qualifiedName": "Float32", + "tag": "removed" + }, + { + "dataType": "double", + "nodeType": "Typedef", + "qualifiedName": "Float32", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "Float32", + "tag": "modified" + }, + { + "dataType": "bool", + "nodeType": "Typedef", + "qualifiedName": "Bool", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "unsigned long long", + "nodeType": "Typedef", + "qualifiedName": "Size", + "tag": "removed" + }, + { + "dataType": "unsigned int", + "nodeType": "Typedef", + "qualifiedName": "Size", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "Size", + "tag": "modified" + }, + { + "dataType": "UInt32", + "nodeType": "Typedef", + "qualifiedName": "Handle", + "tag": "removed" + }, + { + "dataType": "Handle", + "nodeType": "Typedef", + "qualifiedName": "SubHandle", + "tag": "removed" + }, + { + "dataType": "SubHandle", + "nodeType": "Typedef", + "qualifiedName": "Token", + "tag": "removed" + }, + { + "dataType": "Int32 *", + "nodeType": "Typedef", + "qualifiedName": "Int32Ptr", + "tag": "removed" + }, + { + "dataType": "Int32 &", + "nodeType": "Typedef", + "qualifiedName": "Int32Ref", + "tag": "removed" + }, + { + "dataType": "ConstBytePtr", + "nodeType": "Typedef", + "qualifiedName": "ConstBuffer", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "class std::vector>", + "nodeType": "Typedef", + "qualifiedName": "FloatVec", + "tag": "removed" + }, + { + "dataType": "class std::vector>", + "nodeType": "Typedef", + "qualifiedName": "FloatVec", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "FloatVec", + "tag": "modified" + }, + { + "dataType": "std::map", + "nodeType": "Typedef", + "qualifiedName": "IntStringMap", + "tag": "removed" + }, + { + "dataType": "std::unordered_map", + "nodeType": "Typedef", + "qualifiedName": "IntIntUMap", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "class std::tuple, class std::allocator>>", + "nodeType": "Typedef", + "qualifiedName": "MixedTuple", + "tag": "removed" + }, + { + "dataType": "class std::tuple, class std::allocator>>", + "nodeType": "Typedef", + "qualifiedName": "MixedTuple", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "MixedTuple", + "tag": "modified" + }, + { + "dataType": "std::array", + "nodeType": "Typedef", + "qualifiedName": "IntArr4", + "tag": "removed" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "Cube", + "tag": "removed" + }, + { + "dataType": "std::map", + "nodeType": "Typedef", + "qualifiedName": "RecordIndex", + "tag": "removed" + }, + { + "dataType": "IntPair", + "nodeType": "Typedef", + "qualifiedName": "Pair", + "tag": "removed" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "PairVec", + "tag": "removed" + }, + { + "dataType": "std::map", + "nodeType": "Typedef", + "qualifiedName": "PairMap", + "tag": "removed" + }, + { + "dataType": "std::vector>", + "nodeType": "Typedef", + "qualifiedName": "VecOfVecFloat", + "tag": "removed" + }, + { + "dataType": "std::map>", + "nodeType": "Typedef", + "qualifiedName": "MapOfMapInt", + "tag": "removed" + }, + { + "dataType": "std::vector>", + "nodeType": "Typedef", + "qualifiedName": "VecOfPair", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "class std::map, class std::allocator>>, struct std::less, class std::allocator, class std::allocator>>>>>", + "nodeType": "Typedef", + "qualifiedName": "MapOfTuple", + "tag": "removed" + }, + { + "dataType": "class std::map, class std::allocator>>, struct std::less, class std::allocator, class std::allocator>>>>>", + "nodeType": "Typedef", + "qualifiedName": "MapOfTuple", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "MapOfTuple", + "tag": "modified" + }, + { + "dataType": "IntVec", + "nodeType": "Typedef", + "qualifiedName": "GridRow", + "tag": "removed" + }, + { + "dataType": "std::map", + "nodeType": "Typedef", + "qualifiedName": "SparseGridIndex", + "tag": "removed" + }, + { + "dataType": "std::unique_ptr", + "nodeType": "Typedef", + "qualifiedName": "IntUnique", + "tag": "removed" + }, + { + "dataType": "std::shared_ptr", + "nodeType": "Typedef", + "qualifiedName": "VoidShared", + "tag": "removed" + }, + { + "dataType": "std::map", + "nodeType": "Typedef", + "qualifiedName": "SharedIntMap", + "tag": "removed" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "IntFn", + "tag": "removed" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "IntIntIntFn", + "tag": "removed" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "VoidStrFn", + "tag": "removed" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "RowTransformFn", + "tag": "removed" + }, + { + "dataType": "EventHandler", + "nodeType": "Typedef", + "qualifiedName": "SignalHandler", + "tag": "removed" + }, + { + "dataType": "BoolIntFn", + "nodeType": "Typedef", + "qualifiedName": "Predicate", + "tag": "removed" + }, + { + "dataType": "Predicate", + "nodeType": "Typedef", + "qualifiedName": "Filter", + "tag": "removed" + }, + { + "dataType": "Transformer", + "nodeType": "Typedef", + "qualifiedName": "Mapper", + "tag": "removed" + }, + { + "dataType": "Mapper", + "nodeType": "Typedef", + "qualifiedName": "Reducer", + "tag": "removed" + }, + { + "dataType": "Dict", + "nodeType": "Typedef", + "qualifiedName": "HandleMap", + "tag": "removed" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "TokenSet", + "tag": "removed" + }, + { + "dataType": "Ptr", + "nodeType": "Typedef", + "qualifiedName": "SharedMatrix", + "tag": "removed" + }, + { + "dataType": "UniquePtr", + "nodeType": "Typedef", + "qualifiedName": "UniqueGrid", + "tag": "removed" + }, + { + "dataType": "Vec", + "nodeType": "Typedef", + "qualifiedName": "SharedMatrixVec", + "tag": "removed" + }, + { + "dataType": "Fn", + "nodeType": "Typedef", + "qualifiedName": "RowFn", + "tag": "removed" + }, + { + "dataType": "Fn", + "nodeType": "Typedef", + "qualifiedName": "GridReducer", + "tag": "removed" + }, + { + "dataType": "HashMap", + "nodeType": "Typedef", + "qualifiedName": "HandlerRegistry", + "tag": "removed" + }, + { + "dataType": "std::tuple", + "nodeType": "Typedef", + "qualifiedName": "RecordTuple", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "class std::tuple>>, class std::function>", + "nodeType": "Typedef", + "qualifiedName": "FullRecord", + "tag": "removed" + }, + { + "dataType": "class std::tuple>>, class std::function>", + "nodeType": "Typedef", + "qualifiedName": "FullRecord", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "FullRecord", + "tag": "modified" + }, + { + "children": [ + { + "dataType": "int", + "nodeType": "Typedef", + "qualifiedName": "L4", + "tag": "removed" + }, + { + "dataType": "long", + "nodeType": "Typedef", + "qualifiedName": "L4", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "L4", + "tag": "modified" + }, + { + "dataType": "L5", + "nodeType": "Typedef", + "qualifiedName": "L6", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "class std::vector>", + "nodeType": "Typedef", + "qualifiedName": "C5", + "tag": "removed" + }, + { + "dataType": "class std::deque>", + "nodeType": "Typedef", + "qualifiedName": "C5", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "C5", + "tag": "modified" + }, + { + "children": [ + { + "dataType": "class std::function", + "nodeType": "Typedef", + "qualifiedName": "F3", + "tag": "removed" + }, + { + "dataType": "class std::function", + "nodeType": "Typedef", + "qualifiedName": "F3", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "F3", + "tag": "modified" + }, + { + "dataType": "F4", + "nodeType": "Typedef", + "qualifiedName": "F5", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "class std::shared_ptr", + "nodeType": "Typedef", + "qualifiedName": "S1", + "tag": "removed" + }, + { + "dataType": "class std::shared_ptr", + "nodeType": "Typedef", + "qualifiedName": "S1", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "S1", + "tag": "modified" + }, + { + "dataType": "S3", + "nodeType": "Typedef", + "qualifiedName": "S4", + "tag": "removed" + }, + { + "dataType": "S4", + "nodeType": "Typedef", + "qualifiedName": "S5", + "tag": "removed" + }, + { + "children": [ + { + "dataType": "unsigned int", + "nodeType": "Typedef", + "qualifiedName": "XBase", + "tag": "removed" + }, + { + "dataType": "unsigned long long", + "nodeType": "Typedef", + "qualifiedName": "XBase", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "XBase", + "tag": "modified" + }, + { + "children": [ + { + "dataType": "class std::function>> (unsigned int)>", + "nodeType": "Typedef", + "qualifiedName": "XFn", + "tag": "removed" + }, + { + "dataType": "class std::function", + "nodeType": "Typedef", + "qualifiedName": "XFn", + "tag": "added" + } + ], + "nodeType": "Typedef", + "qualifiedName": "XFn", + "tag": "modified" + }, + { + "dataType": "XCallback", + "nodeType": "Typedef", + "qualifiedName": "XHandler", + "tag": "removed" + }, + { + "dataType": "int", + "nodeType": "Typedef", + "qualifiedName": "NativeInt", + "tag": "added" + }, + { + "dataType": "long", + "nodeType": "Typedef", + "qualifiedName": "NativeLong", + "tag": "added" + }, + { + "dataType": "uint16_t", + "nodeType": "Typedef", + "qualifiedName": "Byte16", + "tag": "added" + }, + { + "dataType": "Offset", + "nodeType": "Typedef", + "qualifiedName": "Stride", + "tag": "added" + }, + { + "dataType": "UInt64", + "nodeType": "Typedef", + "qualifiedName": "NodeId", + "tag": "added" + }, + { + "dataType": "NodeId", + "nodeType": "Typedef", + "qualifiedName": "EdgeId", + "tag": "added" + }, + { + "dataType": "EdgeId", + "nodeType": "Typedef", + "qualifiedName": "GraphId", + "tag": "added" + }, + { + "dataType": "Int64 *", + "nodeType": "Typedef", + "qualifiedName": "Int64Ptr", + "tag": "added" + }, + { + "dataType": "Int64 &", + "nodeType": "Typedef", + "qualifiedName": "Int64Ref", + "tag": "added" + }, + { + "dataType": "Byte &", + "nodeType": "Typedef", + "qualifiedName": "ByteRef", + "tag": "added" + }, + { + "dataType": "ConstBytePtr", + "nodeType": "Typedef", + "qualifiedName": "SecureBuffer", + "tag": "added" + }, + { + "dataType": "BytePtr", + "nodeType": "Typedef", + "qualifiedName": "MutableBuffer", + "tag": "added" + }, + { + "dataType": "std::deque", + "nodeType": "Typedef", + "qualifiedName": "IntDeque", + "tag": "added" + }, + { + "dataType": "std::list", + "nodeType": "Typedef", + "qualifiedName": "StringList", + "tag": "added" + }, + { + "dataType": "std::set", + "nodeType": "Typedef", + "qualifiedName": "IntSet", + "tag": "added" + }, + { + "dataType": "std::unordered_set", + "nodeType": "Typedef", + "qualifiedName": "StringUSet", + "tag": "added" + }, + { + "dataType": "std::array", + "nodeType": "Typedef", + "qualifiedName": "IntArr8", + "tag": "added" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "Tensor", + "tag": "added" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "HyperTensor", + "tag": "added" + }, + { + "dataType": "std::unordered_map", + "nodeType": "Typedef", + "qualifiedName": "RecordMap", + "tag": "added" + }, + { + "dataType": "std::pair", + "nodeType": "Typedef", + "qualifiedName": "TaggedPair", + "tag": "added" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "TaggedPairVec", + "tag": "added" + }, + { + "dataType": "std::vector>", + "nodeType": "Typedef", + "qualifiedName": "VecOfVecDouble", + "tag": "added" + }, + { + "dataType": "std::map>", + "nodeType": "Typedef", + "qualifiedName": "MapOfMapStr", + "tag": "added" + }, + { + "dataType": "std::vector>", + "nodeType": "Typedef", + "qualifiedName": "VecOfPairStrStr", + "tag": "added" + }, + { + "dataType": "std::set>", + "nodeType": "Typedef", + "qualifiedName": "SetOfVecInt", + "tag": "added" + }, + { + "dataType": "std::unordered_map>", + "nodeType": "Typedef", + "qualifiedName": "UMapOfSet", + "tag": "added" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "GridCol", + "tag": "added" + }, + { + "dataType": "std::unordered_map", + "nodeType": "Typedef", + "qualifiedName": "SparseGridMap", + "tag": "added" + }, + { + "dataType": "std::shared_ptr", + "nodeType": "Typedef", + "qualifiedName": "Int64Shared", + "tag": "added" + }, + { + "dataType": "std::unique_ptr", + "nodeType": "Typedef", + "qualifiedName": "Int64Unique", + "tag": "added" + }, + { + "dataType": "std::shared_ptr", + "nodeType": "Typedef", + "qualifiedName": "FloatShared", + "tag": "added" + }, + { + "dataType": "std::unordered_map", + "nodeType": "Typedef", + "qualifiedName": "SharedIntUMap", + "tag": "added" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "WeakIntVec", + "tag": "added" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "LongFn", + "tag": "added" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "BoolStrFn", + "tag": "added" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "VoidVoidPtrFn", + "tag": "added" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "TensorFn", + "tag": "added" + }, + { + "dataType": "std::function", + "nodeType": "Typedef", + "qualifiedName": "NodeFn", + "tag": "added" + }, + { + "dataType": "EventHandler", + "nodeType": "Typedef", + "qualifiedName": "Listener", + "tag": "added" + }, + { + "dataType": "Listener", + "nodeType": "Typedef", + "qualifiedName": "Observer", + "tag": "added" + }, + { + "dataType": "BoolIntFn", + "nodeType": "Typedef", + "qualifiedName": "Condition", + "tag": "added" + }, + { + "dataType": "Condition", + "nodeType": "Typedef", + "qualifiedName": "Guard", + "tag": "added" + }, + { + "dataType": "Transformer", + "nodeType": "Typedef", + "qualifiedName": "Converter", + "tag": "added" + }, + { + "dataType": "Converter", + "nodeType": "Typedef", + "qualifiedName": "Processor", + "tag": "added" + }, + { + "dataType": "Dict", + "nodeType": "Typedef", + "qualifiedName": "NodeMap", + "tag": "added" + }, + { + "dataType": "std::vector", + "nodeType": "Typedef", + "qualifiedName": "GraphIdVec", + "tag": "added" + }, + { + "dataType": "Ptr", + "nodeType": "Typedef", + "qualifiedName": "SharedTensor", + "tag": "added" + }, + { + "dataType": "UniquePtr", + "nodeType": "Typedef", + "qualifiedName": "UniqueMatrix", + "tag": "added" + }, + { + "dataType": "Vec", + "nodeType": "Typedef", + "qualifiedName": "SharedTensorVec", + "tag": "added" + }, + { + "dataType": "Vec>", + "nodeType": "Typedef", + "qualifiedName": "WeakRowVec", + "tag": "added" + }, + { + "dataType": "Fn", + "nodeType": "Typedef", + "qualifiedName": "RowProcessor", + "tag": "added" + }, + { + "dataType": "Fn", + "nodeType": "Typedef", + "qualifiedName": "TensorReducer", + "tag": "added" + }, + { + "dataType": "HashMap", + "nodeType": "Typedef", + "qualifiedName": "ListenerRegistry", + "tag": "added" + }, + { + "dataType": "std::tuple", + "nodeType": "Typedef", + "qualifiedName": "NodeTuple", + "tag": "added" + }, + { + "dataType": "XCallback", + "nodeType": "Typedef", + "qualifiedName": "XDispatch", + "tag": "added" + }, + { + "dataType": "XDispatch", + "nodeType": "Typedef", + "qualifiedName": "XRouter", + "tag": "added" + } + ], + "headerResolutionFailures": [], + "parsed_status": 1, + "unparsed_status": 0 +} \ No newline at end of file diff --git a/src/tests/beta/functional/type_alias_del_changes/expected_output.txt b/src/tests/beta/functional/type_alias_del_changes/expected_output.txt new file mode 100644 index 0000000..46deac0 --- /dev/null +++ b/src/tests/beta/functional/type_alias_del_changes/expected_output.txt @@ -0,0 +1,1663 @@ +11404736249108278501 +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +---------------------------------------- +252520090170005577 +// SPDX-License-Identifier: BSD-3-Clause +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +11149761070607086961 +// 1. PRIMITIVE TYPE ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +5248513871541095644 +// 2. CHAINED PRIMITIVE ALIASES (alias of alias of alias) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +9850970185470461602 +// chain depth 2 +---------------------------------------- +3610881658362837064 +// chain depth 3 +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +9850970185470461602 +// chain depth 2 +---------------------------------------- +3610881658362837064 +// chain depth 3 +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +2853455229304338679 +// 3. POINTER & REFERENCE ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +15926650430079865224 +// reference alias +---------------------------------------- +11184083995844251978 +// Chained pointer aliases +---------------------------------------- +15191455350617312688 +// alias of pointer alias +---------------------------------------- +18172139382183206391 +// alias of const-pointer alias +---------------------------------------- +17383416654796827135 +// alias of alias of pointer alias +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +1752838695977643055 +// 4. STD CONTAINER ALIASES (single-level) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +7871926879234601291 +// 5. CHAINED CONTAINER ALIASES (alias of alias) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +2148807242502289883 +// container of aliased type +---------------------------------------- +7199033186932259925 +// container of container alias +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +5921609618575121452 +// container of aliased map +---------------------------------------- +2900283883012086638 +// map of aliased vector +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +3587195173874557315 +// container of aliased pair +---------------------------------------- +6306533687610645736 +// map with aliased value +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +1475039864271242461 +// 6. NESTED CONTAINER ALIASES (containers of containers) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +11066733538289463600 +// Chained nested container aliases +---------------------------------------- +4275494295659418594 +// alias of nested container +---------------------------------------- +3240903208949036876 +// alias of inner container +---------------------------------------- +14905002786809828863 +// alias of map-of-vec +---------------------------------------- +13714003494646059046 +// map of aliased map-of-vec +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +8137075360998891103 +// 7. SMART POINTER ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +2555128749633484648 +// Chained smart pointer aliases +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +4564835725483051485 +// container of aliased smart ptr +---------------------------------------- +18235028608634436679 +// map of aliased smart ptr +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +8314227229905058262 +// 8. FUNCTION / CALLABLE ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +11568376671704996640 +// Function aliases using aliased types +---------------------------------------- +429779159624641756 +// uses primitive alias +---------------------------------------- +7344439801981776869 +// uses chained alias +---------------------------------------- +3718167786300357498 +// uses container alias +---------------------------------------- +13193802090873694445 +// uses chained container alias +---------------------------------------- +2012088206175678195 +// Chained function aliases +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +9850970185470461602 +// chain depth 2 +---------------------------------------- +3610881658362837064 +// chain depth 3 +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +9850970185470461602 +// chain depth 2 +---------------------------------------- +4894130948340937445 +// chain depth 1 +---------------------------------------- +9850970185470461602 +// chain depth 2 +---------------------------------------- +3610881658362837064 +// chain depth 3 +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +15350775264933600095 +// 9. TEMPLATE TYPE ALIAS (alias templates) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +17383113153148670429 +// lightweight optional-like +---------------------------------------- +2440479233654532305 +// chained template alias +---------------------------------------- +10759702886415352822 +// generic callable alias +---------------------------------------- +15545826810032948234 +// chained template aliases +---------------------------------------- +15545826810032948234 +// chained template aliases +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +794331785699694517 +// 10. COMBINATIONS: MIXING PRIMITIVE, CONTAINER, SMART-PTR, FUNCTION ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +10419969884169340079 +// Primitive alias inside containers +---------------------------------------- +5427950912835260427 +// template alias + chained primitive +---------------------------------------- +1920832191407404802 +// template alias + chained primitives +---------------------------------------- +3986321989749612476 +// container of depth-3 chained alias +---------------------------------------- +16427100093354697756 +// Smart pointer of aliased container +---------------------------------------- +11261687479186704058 +// smart ptr of container alias +---------------------------------------- +16482307980681478241 +// smart ptr of chained container alias +---------------------------------------- +1321933976435768978 +// unique ptr of aliased nested container +---------------------------------------- +18239961002813768538 +// Container of smart pointers of aliased types +---------------------------------------- +2393421474652669910 +// vec of (shared ptr of alias) +---------------------------------------- +6765258042076783070 +// vec of (shared ptr of chained alias) +---------------------------------------- +17587235711832830798 +// Function aliases using template aliases +---------------------------------------- +2288015484516565445 +// template fn alias + chained primitive +---------------------------------------- +8778413824097401265 +// template fn alias + container alias +---------------------------------------- +3890138928315361536 +// template fn alias + chained container +---------------------------------------- +1433163756463256833 +// template fn alias + nested alias +---------------------------------------- +6902891125146014803 +// Map of function aliases +---------------------------------------- +4478548153540263626 +// map of chained fn alias +---------------------------------------- +808324391169902847 +// hashmap of depth-2 fn alias +---------------------------------------- +2617465969389828359 +// Tuple combining aliased types +---------------------------------------- +10423006034036588447 +// tuple of mixed aliases +---------------------------------------- +4676129134848100515 +// tuple of depth-3 aliases +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +17151622302622386845 +// 11. DEEP CHAINING (5+ levels) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4643692507184473152 +// Primitive chain +---------------------------------------- +13610479474926537002 +// Container chain +---------------------------------------- +992270746239737613 +// Function chain +---------------------------------------- +16316165297072387077 +// Smart pointer chain +---------------------------------------- +8281021421508420751 +// Cross-kind chaining: primitive -> container -> smart ptr -> function +---------------------------------------- +5386395824135468412 +// primitive alias +---------------------------------------- +3341658668244301603 +// container of primitive alias +---------------------------------------- +11261687479186704058 +// smart ptr of container alias +---------------------------------------- +6421088975288516295 +// function using smart ptr + primitive alias +---------------------------------------- +1792776889139741625 +// alias of cross-kind chain +---------------------------------------- +6833535043510860959 +// alias of alias of cross-kind chain +---------------------------------------- +TypeAliasTemplateDecl +13530249878176052360 +template +using Vec = std::vector +---------------------------------------- +TypeAliasDecl +13697161691107378638 +using Vec = std::vector +---------------------------------------- +TypeAliasTemplateDecl +9110170453641539830 +template +using Ptr = std::shared_ptr +---------------------------------------- +TypeAliasDecl +4735944636330133398 +using Ptr = std::shared_ptr +---------------------------------------- +TypeAliasTemplateDecl +11146285664447373960 +template +using UniquePtr = std::unique_ptr +---------------------------------------- +TypeAliasDecl +13666490864582731476 +using UniquePtr = std::unique_ptr +---------------------------------------- +TypeAliasTemplateDecl +2218946773300014716 +template +using Dict = std::map +---------------------------------------- +TypeAliasDecl +3421834521381985077 +using Dict = std::map +---------------------------------------- +TypeAliasTemplateDecl +1199539765464261317 +template +using HashMap = std::unordered_map +---------------------------------------- +TypeAliasDecl +2665715727263166377 +using HashMap = std::unordered_map +---------------------------------------- +TypeAliasTemplateDecl +7796448320629310809 +template +using Opt = std::pair +---------------------------------------- +TypeAliasDecl +14903892007700950802 +using Opt = std::pair +---------------------------------------- +TypeAliasTemplateDecl +15010102255912192795 +template +using Grid2D = std::vector> +---------------------------------------- +TypeAliasDecl +2078330257739762030 +using Grid2D = std::vector> +---------------------------------------- +TypeAliasTemplateDecl +16175532854313652232 +template +using Grid3D = std::vector> +---------------------------------------- +TypeAliasDecl +7986584479452669155 +using Grid3D = std::vector> +---------------------------------------- +TypeAliasTemplateDecl +8205538019059934295 +template +using MultiDict = std::map> +---------------------------------------- +TypeAliasDecl +8881172517728465046 +using MultiDict = std::map> +---------------------------------------- +TypeAliasTemplateDecl +10613145642924201792 +template +using Fn = std::function +---------------------------------------- +TypeAliasDecl +6875241862954294873 +using Fn = std::function +---------------------------------------- +TypeAliasTemplateDecl +12102200880125177183 +template +using PtrVec = Vec> +---------------------------------------- +TypeAliasDecl +291352495783494926 +using PtrVec = Vec> +---------------------------------------- +TypeAliasTemplateDecl +3036384633426028592 +template +using PtrDict = Dict> +---------------------------------------- +TypeAliasDecl +14507221016930695187 +using PtrDict = Dict> +---------------------------------------- +1426345352165272409 +#include +---------------------------------------- +2348909900560597168 +#include +---------------------------------------- +11728103345505421467 +#include +---------------------------------------- +11160874710484048764 +#include +---------------------------------------- +8964816057146264539 +#include +---------------------------------------- +8370400199979850612 +#include +---------------------------------------- +8344189864065839774 +#include +---------------------------------------- +16977924592700156950 +#include +---------------------------------------- +11404736249108278501 +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +---------------------------------------- +252520090170005577 +// SPDX-License-Identifier: BSD-3-Clause +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +11149761070607086961 +// 1. PRIMITIVE TYPE ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4178143098090593375 +// CHANGED: int -> long +---------------------------------------- +15197976802059844906 +// CHANGED: float -> double +---------------------------------------- +17814318868777993526 +// REMOVED: Bool = bool +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +5248513871541095644 +// 2. CHAINED PRIMITIVE ALIASES (alias of alias of alias) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +9901471898086977033 +// CHANGED: UInt64 -> UInt32 (chain depth 1) +---------------------------------------- +9850970185470461602 +// chain depth 2 +---------------------------------------- +3610881658362837064 +// chain depth 3 +---------------------------------------- +3523643139583791779 +// ADDED: chain depth 4 +---------------------------------------- +5641326640400040586 +// REMOVED: Handle = UInt32 +---------------------------------------- +504333923543914406 +// REMOVED: SubHandle = Handle +---------------------------------------- +7239989414526776013 +// REMOVED: Token = SubHandle +---------------------------------------- +3781725373968941510 +// ADDED: new chain root +---------------------------------------- +12706775618843963419 +// ADDED: chain depth 2 +---------------------------------------- +12821181564448774172 +// ADDED: chain depth 3 +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +2853455229304338679 +// 3. POINTER & REFERENCE ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +7285788825886116710 +// REMOVED: Int32Ptr = Int32 * +---------------------------------------- +17179216593563787037 +// REMOVED: Int32Ref = Int32 & +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +11184083995844251978 +// Chained pointer aliases +---------------------------------------- +14344283787590691545 +// alias of pointer alias (unchanged) +---------------------------------------- +18181219690644048107 +// REMOVED: ConstBuffer = ConstBytePtr +---------------------------------------- +8696862922069619194 +// alias of alias of pointer alias (unchanged) +---------------------------------------- +2845779888906582568 +// ADDED: replaces ConstBuffer with new name +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +1752838695977643055 +// 4. STD CONTAINER ALIASES (single-level) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +6324310926622112764 +// REMOVED: FloatVec = std::vector +---------------------------------------- +10961146337500272546 +// REMOVED: IntStringMap = std::map +---------------------------------------- +3802011675671303464 +// REMOVED: IntIntUMap = std::unordered_map +---------------------------------------- +15197976802059844906 +// CHANGED: float -> double +---------------------------------------- +13254155876154586460 +// REMOVED: IntArr4 = std::array +---------------------------------------- +14669237475292288744 +// CHANGED: vector -> vector +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +7871926879234601291 +// 5. CHAINED CONTAINER ALIASES (alias of alias) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +6257432530174134644 +// chain depth 1 (unchanged) +---------------------------------------- +6019322406730310952 +// container of aliased type (unchanged) +---------------------------------------- +9084233107073492274 +// REMOVED: Cube = std::vector +---------------------------------------- +17847828408312592394 +// ADDED: replaces Cube with new name +---------------------------------------- +3523643139583791779 +// ADDED: chain depth 4 +---------------------------------------- +6257432530174134644 +// chain depth 1 (unchanged) +---------------------------------------- +14378680671227842510 +// container of aliased map (unchanged) +---------------------------------------- +15181106283560638837 +// REMOVED: RecordIndex = std::map +---------------------------------------- +10012713244221599830 +// ADDED: unordered variant +---------------------------------------- +14348584700269493468 +// REMOVED: Pair = IntPair +---------------------------------------- +806203575553109813 +// REMOVED: PairVec = std::vector +---------------------------------------- +9409457829166330997 +// REMOVED: PairMap = std::map +---------------------------------------- +710248694817315089 +// ADDED: new pair alias +---------------------------------------- +2459433694116547527 +// ADDED: container of new pair alias +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +1475039864271242461 +// 6. NESTED CONTAINER ALIASES (containers of containers) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +1868823852304113485 +// REMOVED: VecOfVecFloat = std::vector> +---------------------------------------- +18399101434437320235 +// ADDED: float -> double +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +2928992993484341940 +// REMOVED: MapOfMapInt = std::map> +---------------------------------------- +16454372819791836895 +// ADDED: int -> string value +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +10364263590291066209 +// REMOVED: VecOfPair = std::vector> +---------------------------------------- +12769764562454093145 +// ADDED: int key -> string key +---------------------------------------- +3709073900383460922 +// CHANGED: float -> double in tuple +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +11066733538289463600 +// Chained nested container aliases +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +6154094118991902002 +// REMOVED: GridRow = IntVec +---------------------------------------- +16725986461767886304 +// ADDED: replaces GridRow +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +17386625149156106229 +// REMOVED: SparseGridIndex = std::map +---------------------------------------- +2574610333197441359 +// ADDED: map -> unordered_map +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +8137075360998891103 +// 7. SMART POINTER ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +6151399401671813530 +// REMOVED: IntUnique = std::unique_ptr +---------------------------------------- +5513639302280271508 +// REMOVED: VoidShared = std::shared_ptr +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +2555128749633484648 +// Chained smart pointer aliases +---------------------------------------- +6257432530174134644 +// chain depth 1 (unchanged) +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +14457626678487853218 +// REMOVED: SharedIntMap = std::map +---------------------------------------- +2574610333197441359 +// ADDED: map -> unordered_map +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +8314227229905058262 +// 8. FUNCTION / CALLABLE ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4680674432206922957 +// REMOVED: IntFn = std::function +---------------------------------------- +8358827326109878713 +// REMOVED: IntIntIntFn = std::function +---------------------------------------- +9590621776111910478 +// REMOVED: VoidStrFn = std::function +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +11568376671704996640 +// Function aliases using aliased types +---------------------------------------- +6241782127034004349 +// unchanged (Size type changed) +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +8579860654819534859 +// REMOVED: RowTransformFn = std::function +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +10508260770358040981 +// ADDED: uses new Tensor alias +---------------------------------------- +11454050464724572530 +// ADDED: uses new NodeId alias +---------------------------------------- +2012088206175678195 +// Chained function aliases +---------------------------------------- +6257432530174134644 +// chain depth 1 (unchanged) +---------------------------------------- +16121114961944492026 +// chain depth 2 (unchanged) +---------------------------------------- +5037807686815234473 +// REMOVED: SignalHandler = EventHandler +---------------------------------------- +2286676807481858742 +// ADDED: replaces SignalHandler +---------------------------------------- +3523643139583791779 +// ADDED: chain depth 4 +---------------------------------------- +7415194895567271421 +// REMOVED: Predicate = BoolIntFn +---------------------------------------- +1047372761605079481 +// REMOVED: Filter = Predicate +---------------------------------------- +15106848945143863647 +// ADDED: replaces Predicate +---------------------------------------- +5460948093803174027 +// ADDED: replaces Filter +---------------------------------------- +6257432530174134644 +// chain depth 1 (unchanged) +---------------------------------------- +5477711595397431482 +// REMOVED: Mapper = Transformer +---------------------------------------- +18328919879396601410 +// REMOVED: Reducer = Mapper +---------------------------------------- +5750524575352470434 +// ADDED: replaces Mapper +---------------------------------------- +8238788300160017836 +// ADDED: replaces Reducer +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +15350775264933600095 +// 9. TEMPLATE TYPE ALIAS (alias templates) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +9711253733876001379 +// REMOVED: Opt = std::pair +---------------------------------------- +2589870117610787549 +// ADDED: renamed from Opt +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +13736483326638830666 +// REMOVED: Grid3D = std::vector> +---------------------------------------- +15956319408839922099 +// ADDED: renamed from Grid3D +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +15752019028760991640 +// ADDED +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +794331785699694517 +// 10. COMBINATIONS: MIXING PRIMITIVE, CONTAINER, SMART-PTR, FUNCTION ALIASES +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +10419969884169340079 +// Primitive alias inside containers +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +15022944404075145092 +// REMOVED: HandleMap = Dict +---------------------------------------- +17038239904803205361 +// ADDED: uses new NodeId/EdgeId aliases +---------------------------------------- +11584211933318599226 +// REMOVED: TokenSet = std::vector +---------------------------------------- +4563919174673379386 +// ADDED: uses new GraphId alias +---------------------------------------- +16427100093354697756 +// Smart pointer of aliased container +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +11854888223766999524 +// REMOVED: SharedMatrix = Ptr +---------------------------------------- +10508260770358040981 +// ADDED: uses new Tensor alias +---------------------------------------- +6248968026949934484 +// REMOVED: UniqueGrid = UniquePtr +---------------------------------------- +10384939186536709673 +// ADDED: unique ptr of Matrix +---------------------------------------- +18239961002813768538 +// Container of smart pointers of aliased types +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +17717306687869576396 +// REMOVED: SharedMatrixVec = Vec +---------------------------------------- +1121612739304306626 +// ADDED: uses new SharedTensor +---------------------------------------- +4056218983753519944 +// ADDED: weak ptr of Row +---------------------------------------- +17587235711832830798 +// Function aliases using template aliases +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +3149912055449315319 +// REMOVED: RowFn = Fn +---------------------------------------- +10363411291193122774 +// ADDED: extra Index param +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +8680453102023265910 +// REMOVED: GridReducer = Fn +---------------------------------------- +825671218067460037 +// ADDED: uses Tensor alias +---------------------------------------- +6902891125146014803 +// Map of function aliases +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +953826516052976430 +// REMOVED: HandlerRegistry = HashMap +---------------------------------------- +121668510791714866 +// ADDED: uses new Listener alias +---------------------------------------- +2617465969389828359 +// Tuple combining aliased types +---------------------------------------- +17319850569763971926 +// REMOVED: RecordTuple = std::tuple +---------------------------------------- +1530462406374455884 +// ADDED: uses new NodeId/EdgeId +---------------------------------------- +10015471543328867047 +// CHANGED: Token->GraphId, SharedRow unchanged +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +17151622302622386845 +// 11. DEEP CHAINING (5+ levels) +---------------------------------------- +4310552818775364650 +// ============================================================================= +---------------------------------------- +4643692507184473152 +// Primitive chain +---------------------------------------- +7457166044703762416 +// REMOVED: L4 = L3 +---------------------------------------- +2047144075112695967 +// REMOVED: L5 = L4 +---------------------------------------- +2052795602195097495 +// REMOVED: L6 = L5 +---------------------------------------- +79665933161571699 +// CHANGED: L3 -> long (breaks chain, new root type) +---------------------------------------- +5464835847929545566 +// chain continues from new L4 +---------------------------------------- +13610479474926537002 +// Container chain +---------------------------------------- +17903375182798020782 +// REMOVED: C5 = C4 +---------------------------------------- +5168072066612139521 +// CHANGED: C4 (vector) -> deque (new root type) +---------------------------------------- +992270746239737613 +// Function chain +---------------------------------------- +8033428497687873347 +// REMOVED: F3 = F2 +---------------------------------------- +11113431588118460095 +// REMOVED: F4 = F3 +---------------------------------------- +8275386646422716277 +// REMOVED: F5 = F4 +---------------------------------------- +5099965704849693456 +// CHANGED: void(int) -> void(long) +---------------------------------------- +14546516561823076737 +// chain continues from new F3 +---------------------------------------- +16316165297072387077 +// Smart pointer chain +---------------------------------------- +16997519660953267333 +// REMOVED: S1 = std::shared_ptr +---------------------------------------- +7286065719784844245 +// REMOVED: S2 = S1 +---------------------------------------- +4404699905320766071 +// REMOVED: S3 = S2 +---------------------------------------- +16603188799106375962 +// REMOVED: S4 = S3 +---------------------------------------- +16113481455920540716 +// REMOVED: S5 = S4 +---------------------------------------- +11170851582239548605 +// CHANGED: shared_ptr -> shared_ptr +---------------------------------------- +8281021421508420751 +// Cross-kind chaining: primitive -> container -> smart ptr -> function +---------------------------------------- +15679126253613473413 +// CHANGED: UInt32 -> UInt64 +---------------------------------------- +8257276987225225350 +// unchanged (type of XBase changed) +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +13776569293494928210 +// REMOVED: XFn = std::function +---------------------------------------- +6885325467572028113 +// CHANGED: XShared(XBase) -> bool(XBase) +---------------------------------------- +4398279772560448233 +// unchanged +---------------------------------------- +12175148229514341611 +// REMOVED: XHandler = XCallback +---------------------------------------- +3036901581192331513 +// ADDED: replaces XHandler +---------------------------------------- +12821181564448774172 +// ADDED: chain depth 3 +---------------------------------------- +TypeAliasTemplateDecl +13530249878176052360 +template +using Vec = std::vector +---------------------------------------- +TypeAliasDecl +13697161691107378638 +using Vec = std::vector +---------------------------------------- +TypeAliasTemplateDecl +9110170453641539830 +template +using Ptr = std::shared_ptr +---------------------------------------- +TypeAliasDecl +4735944636330133398 +using Ptr = std::shared_ptr +---------------------------------------- +TypeAliasTemplateDecl +11146285664447373960 +template +using UniquePtr = std::unique_ptr +---------------------------------------- +TypeAliasDecl +13666490864582731476 +using UniquePtr = std::unique_ptr +---------------------------------------- +TypeAliasTemplateDecl +2218946773300014716 +template +using Dict = std::map +---------------------------------------- +TypeAliasDecl +3421834521381985077 +using Dict = std::map +---------------------------------------- +TypeAliasTemplateDecl +1199539765464261317 +template +using HashMap = std::unordered_map +---------------------------------------- +TypeAliasDecl +2665715727263166377 +using HashMap = std::unordered_map +---------------------------------------- +TypeAliasTemplateDecl +13804569324797630323 +template +using Optional = std::pair +---------------------------------------- +TypeAliasDecl +13973672842342196889 +using Optional = std::pair +---------------------------------------- +TypeAliasTemplateDecl +15010102255912192795 +template +using Grid2D = std::vector> +---------------------------------------- +TypeAliasDecl +2078330257739762030 +using Grid2D = std::vector> +---------------------------------------- +TypeAliasTemplateDecl +3217341941703100558 +template +using Volume = std::vector> +---------------------------------------- +TypeAliasDecl +13797693400243215562 +using Volume = std::vector> +---------------------------------------- +TypeAliasTemplateDecl +8205538019059934295 +template +using MultiDict = std::map> +---------------------------------------- +TypeAliasDecl +8881172517728465046 +using MultiDict = std::map> +---------------------------------------- +TypeAliasTemplateDecl +10613145642924201792 +template +using Fn = std::function +---------------------------------------- +TypeAliasDecl +6875241862954294873 +using Fn = std::function +---------------------------------------- +TypeAliasTemplateDecl +12102200880125177183 +template +using PtrVec = Vec> +---------------------------------------- +TypeAliasDecl +291352495783494926 +using PtrVec = Vec> +---------------------------------------- +TypeAliasTemplateDecl +3036384633426028592 +template +using PtrDict = Dict> +---------------------------------------- +TypeAliasDecl +14507221016930695187 +using PtrDict = Dict> +---------------------------------------- +TypeAliasTemplateDecl +1821609541650584171 +template // ADDED +using WeakPtr = std::weak_ptr +---------------------------------------- +TypeAliasDecl +16025837600090272036 +using WeakPtr = std::weak_ptr +---------------------------------------- +TypeAliasTemplateDecl +10432922583541527466 +template // ADDED +using Deque = std::deque +---------------------------------------- +TypeAliasDecl +16677097987942968287 +using Deque = std::deque +---------------------------------------- +TypeAliasTemplateDecl +5688466148224524760 +template // ADDED +using Set = std::set +---------------------------------------- +TypeAliasDecl +18187567235089285073 +using Set = std::set +---------------------------------------- +TypeAliasTemplateDecl +17431137034675374037 +template // ADDED +using MultiMap = std::multimap +---------------------------------------- +TypeAliasDecl +6637734153472693726 +using MultiMap = std::multimap +---------------------------------------- +1426345352165272409 +#include +---------------------------------------- +2602868284906415958 +#include +---------------------------------------- +2348909900560597168 +#include +---------------------------------------- +12307509085317227009 +#include +---------------------------------------- +11728103345505421467 +#include +---------------------------------------- +11160874710484048764 +#include +---------------------------------------- +5715186182496864876 +#include +---------------------------------------- +8964816057146264539 +#include +---------------------------------------- +8370400199979850612 +#include +---------------------------------------- +9930332682935459729 +#include +---------------------------------------- +8344189864065839774 +#include +---------------------------------------- +16977924592700156950 +#include +---------------------------------------- + +############ CONTEXT 1 MAPS ############ +comments1 +3890138928315361536 : 1 +6833535043510860959 : 1 +18239961002813768538 : 1 +2617465969389828359 : 1 +16482307980681478241 : 1 +6306533687610645736 : 1 +2555128749633484648 : 1 +16427100093354697756 : 1 +252520090170005577 : 1 +10759702886415352822 : 1 +4676129134848100515 : 1 +3341658668244301603 : 1 +4310552818775364650 : 22 +13610479474926537002 : 1 +8778413824097401265 : 1 +6765258042076783070 : 1 +5427950912835260427 : 1 +11404736249108278501 : 1 +4894130948340937445 : 9 +1321933976435768978 : 1 +7344439801981776869 : 1 +2012088206175678195 : 1 +11568376671704996640 : 1 +3718167786300357498 : 1 +1433163756463256833 : 1 +2148807242502289883 : 1 +15926650430079865224 : 1 +794331785699694517 : 1 +4275494295659418594 : 1 +8281021421508420751 : 1 +3986321989749612476 : 1 +17151622302622386845 : 1 +11184083995844251978 : 1 +2853455229304338679 : 1 +18172139382183206391 : 1 +2440479233654532305 : 1 +4478548153540263626 : 1 +16316165297072387077 : 1 +15350775264933600095 : 1 +8137075360998891103 : 1 +1792776889139741625 : 1 +4643692507184473152 : 1 +13193802090873694445 : 1 +18235028608634436679 : 1 +6421088975288516295 : 1 +17587235711832830798 : 1 +7199033186932259925 : 1 +1920832191407404802 : 1 +10419969884169340079 : 1 +1752838695977643055 : 1 +5248513871541095644 : 1 +429779159624641756 : 1 +11149761070607086961 : 1 +7871926879234601291 : 1 +17383416654796827135 : 1 +5921609618575121452 : 1 +14905002786809828863 : 1 +808324391169902847 : 1 +11261687479186704058 : 2 +992270746239737613 : 1 +2900283883012086638 : 1 +3610881658362837064 : 4 +9850970185470461602 : 5 +5386395824135468412 : 1 +8314227229905058262 : 1 +3587195173874557315 : 1 +15191455350617312688 : 1 +17383113153148670429 : 1 +1475039864271242461 : 1 +11066733538289463600 : 1 +4564835725483051485 : 1 +15545826810032948234 : 2 +2393421474652669910 : 1 +2288015484516565445 : 1 +10423006034036588447 : 1 +3240903208949036876 : 1 +13714003494646059046 : 1 +6902891125146014803 : 1 +---------------------------------------- +unhandledDecls1 +10613145642924201792 : 1 +8370400199979850612 : 1 +13697161691107378638 : 1 +291352495783494926 : 1 +9110170453641539830 : 1 +7986584479452669155 : 1 +8205538019059934295 : 1 +8344189864065839774 : 1 +14903892007700950802 : 1 +7796448320629310809 : 1 +6875241862954294873 : 1 +1426345352165272409 : 1 +13666490864582731476 : 1 +2078330257739762030 : 1 +15010102255912192795 : 1 +13530249878176052360 : 1 +11146285664447373960 : 1 +3421834521381985077 : 1 +16175532854313652232 : 1 +2218946773300014716 : 1 +2665715727263166377 : 1 +4735944636330133398 : 1 +8881172517728465046 : 1 +3036384633426028592 : 1 +2348909900560597168 : 1 +11160874710484048764 : 1 +16977924592700156950 : 1 +11728103345505421467 : 1 +1199539765464261317 : 1 +12102200880125177183 : 1 +8964816057146264539 : 1 +14507221016930695187 : 1 +---------------------------------------- +inactiveUnhandledDecls1 +(empty) +---------------------------------------- + +############ CONTEXT 2 MAPS ############ +comments2 +18239961002813768538 : 1 +2617465969389828359 : 1 +2928992993484341940 : 1 +10364263590291066209 : 1 +2555128749633484648 : 1 +1121612739304306626 : 1 +12821181564448774172 : 2 +16427100093354697756 : 1 +8680453102023265910 : 1 +6241782127034004349 : 1 +4310552818775364650 : 22 +15197976802059844906 : 2 +15022944404075145092 : 1 +13610479474926537002 : 1 +5460948093803174027 : 1 +11404736249108278501 : 1 +2012088206175678195 : 1 +1868823852304113485 : 1 +8696862922069619194 : 1 +16121114961944492026 : 1 +5168072066612139521 : 1 +17903375182798020782 : 1 +794331785699694517 : 1 +17179216593563787037 : 1 +4404699905320766071 : 1 +6885325467572028113 : 1 +18399101434437320235 : 1 +16997519660953267333 : 1 +9084233107073492274 : 1 +16454372819791836895 : 1 +15679126253613473413 : 1 +6154094118991902002 : 1 +121668510791714866 : 1 +4643692507184473152 : 1 +6151399401671813530 : 1 +9590621776111910478 : 1 +17587235711832830798 : 1 +10419969884169340079 : 1 +13254155876154586460 : 1 +9901471898086977033 : 1 +2286676807481858742 : 1 +9711253733876001379 : 1 +5099965704849693456 : 1 +11170851582239548605 : 1 +11149761070607086961 : 1 +16113481455920540716 : 1 +14344283787590691545 : 1 +8257276987225225350 : 1 +16725986461767886304 : 1 +3709073900383460922 : 1 +11584211933318599226 : 1 +5513639302280271508 : 1 +4563919174673379386 : 1 +10015471543328867047 : 1 +6248968026949934484 : 1 +3610881658362837064 : 1 +17386625149156106229 : 1 +9850970185470461602 : 1 +10961146337500272546 : 1 +6324310926622112764 : 1 +14457626678487853218 : 1 +10012713244221599830 : 1 +17319850569763971926 : 1 +5750524575352470434 : 1 +2574610333197441359 : 2 +17847828408312592394 : 1 +5037807686815234473 : 1 +710248694817315089 : 1 +4056218983753519944 : 1 +825671218067460037 : 1 +11454050464724572530 : 1 +17717306687869576396 : 1 +14669237475292288744 : 1 +10508260770358040981 : 2 +18328919879396601410 : 1 +252520090170005577 : 1 +3523643139583791779 : 3 +7415194895567271421 : 1 +5464835847929545566 : 1 +8579860654819534859 : 1 +11113431588118460095 : 1 +3781725373968941510 : 1 +79665933161571699 : 1 +11568376671704996640 : 1 +7239989414526776013 : 1 +4680674432206922957 : 1 +14546516561823076737 : 1 +953826516052976430 : 1 +806203575553109813 : 1 +8281021421508420751 : 1 +4398279772560448233 : 27 +8033428497687873347 : 1 +7457166044703762416 : 1 +17151622302622386845 : 1 +11184083995844251978 : 1 +2853455229304338679 : 1 +3149912055449315319 : 1 +13736483326638830666 : 1 +16316165297072387077 : 1 +4178143098090593375 : 1 +8137075360998891103 : 1 +8358827326109878713 : 1 +7285788825886116710 : 1 +1047372761605079481 : 1 +15106848945143863647 : 1 +16603188799106375962 : 1 +2459433694116547527 : 1 +6257432530174134644 : 5 +15350775264933600095 : 1 +14378680671227842510 : 1 +2845779888906582568 : 1 +3802011675671303464 : 1 +7286065719784844245 : 1 +1752838695977643055 : 1 +5248513871541095644 : 1 +14348584700269493468 : 1 +17814318868777993526 : 1 +6019322406730310952 : 1 +2052795602195097495 : 1 +17038239904803205361 : 1 +7871926879234601291 : 1 +13776569293494928210 : 1 +8238788300160017836 : 1 +12769764562454093145 : 1 +15956319408839922099 : 1 +992270746239737613 : 1 +5477711595397431482 : 1 +12706775618843963419 : 1 +9409457829166330997 : 1 +15181106283560638837 : 1 +8275386646422716277 : 1 +10384939186536709673 : 1 +8314227229905058262 : 1 +10363411291193122774 : 1 +11066733538289463600 : 1 +2589870117610787549 : 1 +1475039864271242461 : 1 +5641326640400040586 : 1 +11854888223766999524 : 1 +18181219690644048107 : 1 +15752019028760991640 : 25 +12175148229514341611 : 1 +2047144075112695967 : 1 +1530462406374455884 : 1 +3036901581192331513 : 1 +504333923543914406 : 1 +6902891125146014803 : 1 +---------------------------------------- +unhandledDecls2 +10613145642924201792 : 1 +11160874710484048764 : 1 +8964816057146264539 : 1 +8370400199979850612 : 1 +13697161691107378638 : 1 +3217341941703100558 : 1 +291352495783494926 : 1 +17431137034675374037 : 1 +9110170453641539830 : 1 +9930332682935459729 : 1 +10432922583541527466 : 1 +8205538019059934295 : 1 +6637734153472693726 : 1 +8344189864065839774 : 1 +5715186182496864876 : 1 +13973672842342196889 : 1 +6875241862954294873 : 1 +13804569324797630323 : 1 +1426345352165272409 : 1 +13666490864582731476 : 1 +12307509085317227009 : 1 +2078330257739762030 : 1 +15010102255912192795 : 1 +13530249878176052360 : 1 +11146285664447373960 : 1 +3421834521381985077 : 1 +2218946773300014716 : 1 +2665715727263166377 : 1 +4735944636330133398 : 1 +8881172517728465046 : 1 +3036384633426028592 : 1 +2602868284906415958 : 1 +13797693400243215562 : 1 +2348909900560597168 : 1 +16025837600090272036 : 1 +18187567235089285073 : 1 +11728103345505421467 : 1 +1821609541650584171 : 1 +5688466148224524760 : 1 +1199539765464261317 : 1 +12102200880125177183 : 1 +16677097987942968287 : 1 +16977924592700156950 : 1 +14507221016930695187 : 1 +---------------------------------------- +inactiveUnhandledDecls2 +(empty) +---------------------------------------- diff --git a/src/tests/beta/functional/type_alias_del_changes/test_type_alias_decl_changes.py b/src/tests/beta/functional/type_alias_del_changes/test_type_alias_decl_changes.py new file mode 100644 index 0000000..d15eb67 --- /dev/null +++ b/src/tests/beta/functional/type_alias_del_changes/test_type_alias_decl_changes.py @@ -0,0 +1,41 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import json +import subprocess +from deepdiff import DeepDiff + + +def test_ast_diff(binary_path, binary_args, request): + + test_dir = os.path.dirname(request.fspath) + + subprocess.run( + [binary_path] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + with open(f'{test_dir}/expected_output.json', 'r') as f: + expected_json = json.load(f) + + with open(f'{test_dir}/debug_output/ast_diffs/ast_diff_output_mylib.h.json', 'r') as f: + actual_json = json.load(f) + + diff = DeepDiff(expected_json, actual_json, ignore_order=True) + + assert diff == {} + + # Compare text output files line by line + with open(f'{test_dir}/expected_output.txt', 'r') as f: + expected_lines = f.readlines() + + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = f.readlines() + + for i, (expected_line, actual_line) in enumerate(zip(expected_lines, actual_lines), 1): + assert expected_line == actual_line, f"Line {i} differs:\nExpected: {expected_line}\nActual: {actual_line}" + + assert len(expected_lines) == len(actual_lines), f"File length differs: expected {len(expected_lines)} lines, got {len(actual_lines)} lines" diff --git a/src/tests/beta/functional/type_alias_del_changes/v1/mylib.h b/src/tests/beta/functional/type_alias_del_changes/v1/mylib.h new file mode 100644 index 0000000..7bc7888 --- /dev/null +++ b/src/tests/beta/functional/type_alias_del_changes/v1/mylib.h @@ -0,0 +1,272 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +// ============================================================================= +// 1. PRIMITIVE TYPE ALIASES +// ============================================================================= + +using Byte = unsigned char; +using Int8 = signed char; +using Int16 = short; +using Int32 = int; +using Int64 = long long; +using UInt8 = unsigned char; +using UInt16 = unsigned short; +using UInt32 = unsigned int; +using UInt64 = unsigned long long; +using Float32 = float; +using Float64 = double; +using Char = char; +using Bool = bool; + +// ============================================================================= +// 2. CHAINED PRIMITIVE ALIASES (alias of alias of alias) +// ============================================================================= + +using Size = UInt64; // chain depth 1 +using Index = Size; // chain depth 2 +using Offset = Index; // chain depth 3 +using Handle = UInt32; // chain depth 1 +using SubHandle = Handle; // chain depth 2 +using Token = SubHandle; // chain depth 3 + +// ============================================================================= +// 3. POINTER & REFERENCE ALIASES +// ============================================================================= + +using BytePtr = Byte *; +using ConstBytePtr = const Byte *; +using Int32Ptr = Int32 *; +using Int32Ref = Int32 &; // reference alias +using VoidPtr = void *; +using ConstVoidPtr = const void *; + +// Chained pointer aliases +using RawBuffer = BytePtr; // alias of pointer alias +using ConstBuffer = ConstBytePtr; // alias of const-pointer alias +using BufferHandle = RawBuffer; // alias of alias of pointer alias + +// ============================================================================= +// 4. STD CONTAINER ALIASES (single-level) +// ============================================================================= + +using IntVec = std::vector; +using FloatVec = std::vector; +using DoubleVec = std::vector; +using StringVec = std::vector; +using ByteVec = std::vector; +using IntIntMap = std::map; +using StringIntMap = std::map; +using IntStringMap = std::map; +using StringStrMap = std::map; +using IntIntUMap = std::unordered_map; +using StrIntUMap = std::unordered_map; +using IntPair = std::pair; +using StrIntPair = std::pair; +using IntTriple = std::tuple; +using MixedTuple = std::tuple; +using IntArr4 = std::array; +using FloatArr3 = std::array; + +// ============================================================================= +// 5. CHAINED CONTAINER ALIASES (alias of alias) +// ============================================================================= + +using Row = IntVec; // chain depth 1 +using Matrix = std::vector; // container of aliased type +using Cube = std::vector; // container of container alias + +using Record = StringIntMap; // chain depth 1 +using RecordSet = std::vector; // container of aliased map +using RecordIndex = std::map; // map of aliased vector + +using Pair = IntPair; // chain depth 1 +using PairVec = std::vector; // container of aliased pair +using PairMap = std::map; // map with aliased value + +// ============================================================================= +// 6. NESTED CONTAINER ALIASES (containers of containers) +// ============================================================================= + +using VecOfVecInt = std::vector>; +using VecOfVecFloat = std::vector>; +using MapOfVecInt = std::map>; +using MapOfMapInt = std::map>; +using VecOfMapStrInt = std::vector>; +using UMapOfVecStr = std::unordered_map>; +using VecOfPair = std::vector>; +using MapOfTuple = std::map>; + +// Chained nested container aliases +using Grid = VecOfVecInt; // alias of nested container +using GridRow = IntVec; // alias of inner container +using SparseGrid = MapOfVecInt; // alias of map-of-vec +using SparseGridIndex = std::map;// map of aliased map-of-vec + +// ============================================================================= +// 7. SMART POINTER ALIASES +// ============================================================================= + +using IntShared = std::shared_ptr; +using IntUnique = std::unique_ptr; +using IntWeak = std::weak_ptr; +using VoidShared = std::shared_ptr; + +// Chained smart pointer aliases +using SharedInt = IntShared; // chain depth 1 +using SharedIntVec = std::vector; // container of aliased smart ptr +using SharedIntMap = std::map; // map of aliased smart ptr + +// ============================================================================= +// 8. FUNCTION / CALLABLE ALIASES +// ============================================================================= + +using VoidFn = std::function; +using IntFn = std::function; +using IntIntFn = std::function; +using IntIntIntFn = std::function; +using BoolIntFn = std::function; +using VoidIntFn = std::function; +using VoidStrFn = std::function; +using StrStrFn = std::function; + +// Function aliases using aliased types +using SizeFn = std::function; // uses primitive alias +using IndexMapFn = std::function; // uses chained alias +using RowTransformFn = std::function; // uses container alias +using MatrixFn = std::function; // uses chained container alias + +// Chained function aliases +using Callback = VoidFn; // chain depth 1 +using EventHandler = Callback; // chain depth 2 +using SignalHandler = EventHandler; // chain depth 3 + +using Predicate = BoolIntFn; // chain depth 1 +using Filter = Predicate; // chain depth 2 + +using Transformer = IntIntFn; // chain depth 1 +using Mapper = Transformer; // chain depth 2 +using Reducer = Mapper; // chain depth 3 + +// ============================================================================= +// 9. TEMPLATE TYPE ALIAS (alias templates) +// ============================================================================= + +template +using Vec = std::vector; + +template +using Ptr = std::shared_ptr; + +template +using UniquePtr = std::unique_ptr; + +template +using Dict = std::map; + +template +using HashMap = std::unordered_map; + +template +using Opt = std::pair; // lightweight optional-like + +template +using Grid2D = std::vector>; + +template +using Grid3D = std::vector>; // chained template alias + +template +using MultiDict = std::map>; + +template +using Fn = std::function; // generic callable alias + +template +using PtrVec = Vec>; // chained template aliases + +template +using PtrDict = Dict>; // chained template aliases + +// ============================================================================= +// 10. COMBINATIONS: MIXING PRIMITIVE, CONTAINER, SMART-PTR, FUNCTION ALIASES +// ============================================================================= + +// Primitive alias inside containers +using IndexVec = Vec; // template alias + chained primitive +using HandleMap = Dict; // template alias + chained primitives +using TokenSet = std::vector; // container of depth-3 chained alias + +// Smart pointer of aliased container +using SharedRow = Ptr; // smart ptr of container alias +using SharedMatrix = Ptr; // smart ptr of chained container alias +using UniqueGrid = UniquePtr; // unique ptr of aliased nested container + +// Container of smart pointers of aliased types +using SharedRowVec = Vec; // vec of (shared ptr of alias) +using SharedMatrixVec = Vec; // vec of (shared ptr of chained alias) + +// Function aliases using template aliases +using IndexTransform = Fn; // template fn alias + chained primitive +using RowFn = Fn; // template fn alias + container alias +using MatrixBuilder = Fn; // template fn alias + chained container +using GridReducer = Fn; // template fn alias + nested alias + +// Map of function aliases +using CallbackMap = Dict; // map of chained fn alias +using HandlerRegistry = HashMap; // hashmap of depth-2 fn alias + +// Tuple combining aliased types +using RecordTuple = std::tuple; // tuple of mixed aliases +using FullRecord = std::tuple; // tuple of depth-3 aliases + +// ============================================================================= +// 11. DEEP CHAINING (5+ levels) +// ============================================================================= + +// Primitive chain +using L1 = int; +using L2 = L1; +using L3 = L2; +using L4 = L3; +using L5 = L4; +using L6 = L5; + +// Container chain +using C1 = std::vector; +using C2 = C1; +using C3 = C2; +using C4 = C3; +using C5 = C4; + +// Function chain +using F1 = std::function; +using F2 = F1; +using F3 = F2; +using F4 = F3; +using F5 = F4; + +// Smart pointer chain +using S1 = std::shared_ptr; +using S2 = S1; +using S3 = S2; +using S4 = S3; +using S5 = S4; + +// Cross-kind chaining: primitive -> container -> smart ptr -> function +using XBase = UInt32; // primitive alias +using XVec = std::vector; // container of primitive alias +using XShared = std::shared_ptr; // smart ptr of container alias +using XFn = std::function; // function using smart ptr + primitive alias +using XCallback = XFn; // alias of cross-kind chain +using XHandler = XCallback; // alias of alias of cross-kind chain diff --git a/src/tests/beta/functional/type_alias_del_changes/v2/mylib.h b/src/tests/beta/functional/type_alias_del_changes/v2/mylib.h new file mode 100644 index 0000000..9624e9d --- /dev/null +++ b/src/tests/beta/functional/type_alias_del_changes/v2/mylib.h @@ -0,0 +1,357 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ============================================================================= +// 1. PRIMITIVE TYPE ALIASES +// ============================================================================= + +using Byte = unsigned char; +using Int8 = signed char; +using Int16 = short; +using Int32 = long; // CHANGED: int -> long +using Int64 = long long; +using UInt8 = unsigned char; +using UInt16 = unsigned short; +using UInt32 = unsigned int; +using UInt64 = unsigned long long; +using Float32 = double; // CHANGED: float -> double +using Float64 = double; +using Char = char; +// REMOVED: Bool = bool +using NativeInt = int; // ADDED +using NativeLong = long; // ADDED +using Byte16 = uint16_t; // ADDED + +// ============================================================================= +// 2. CHAINED PRIMITIVE ALIASES (alias of alias of alias) +// ============================================================================= + +using Size = UInt32; // CHANGED: UInt64 -> UInt32 (chain depth 1) +using Index = Size; // chain depth 2 +using Offset = Index; // chain depth 3 +using Stride = Offset; // ADDED: chain depth 4 +// REMOVED: Handle = UInt32 +// REMOVED: SubHandle = Handle +// REMOVED: Token = SubHandle +using NodeId = UInt64; // ADDED: new chain root +using EdgeId = NodeId; // ADDED: chain depth 2 +using GraphId = EdgeId; // ADDED: chain depth 3 + +// ============================================================================= +// 3. POINTER & REFERENCE ALIASES +// ============================================================================= + +using BytePtr = Byte *; +using ConstBytePtr = const Byte *; +// REMOVED: Int32Ptr = Int32 * +// REMOVED: Int32Ref = Int32 & +using VoidPtr = void *; +using ConstVoidPtr = const void *; +using Int64Ptr = Int64 *; // ADDED +using Int64Ref = Int64 &; // ADDED +using ByteRef = Byte &; // ADDED + +// Chained pointer aliases +using RawBuffer = BytePtr; // alias of pointer alias (unchanged) +// REMOVED: ConstBuffer = ConstBytePtr +using BufferHandle = RawBuffer; // alias of alias of pointer alias (unchanged) +using SecureBuffer = ConstBytePtr; // ADDED: replaces ConstBuffer with new name +using MutableBuffer = BytePtr; // ADDED + +// ============================================================================= +// 4. STD CONTAINER ALIASES (single-level) +// ============================================================================= + +using IntVec = std::vector; +// REMOVED: FloatVec = std::vector +using DoubleVec = std::vector; +using StringVec = std::vector; +using ByteVec = std::vector; +using IntIntMap = std::map; +using StringIntMap = std::map; +// REMOVED: IntStringMap = std::map +using StringStrMap = std::map; +// REMOVED: IntIntUMap = std::unordered_map +using StrIntUMap = std::unordered_map; +using IntPair = std::pair; +using StrIntPair = std::pair; +using IntTriple = std::tuple; +using MixedTuple = std::tuple; // CHANGED: float -> double +// REMOVED: IntArr4 = std::array +using FloatArr3 = std::array; +using FloatVec = std::vector; // CHANGED: vector -> vector +using IntDeque = std::deque; // ADDED +using StringList = std::list; // ADDED +using IntSet = std::set; // ADDED +using StringUSet = std::unordered_set; // ADDED +using IntArr8 = std::array; // ADDED + +// ============================================================================= +// 5. CHAINED CONTAINER ALIASES (alias of alias) +// ============================================================================= + +using Row = IntVec; // chain depth 1 (unchanged) +using Matrix = std::vector; // container of aliased type (unchanged) +// REMOVED: Cube = std::vector +using Tensor = std::vector; // ADDED: replaces Cube with new name +using HyperTensor = std::vector; // ADDED: chain depth 4 + +using Record = StringIntMap; // chain depth 1 (unchanged) +using RecordSet = std::vector; // container of aliased map (unchanged) +// REMOVED: RecordIndex = std::map +using RecordMap = std::unordered_map; // ADDED: unordered variant + +// REMOVED: Pair = IntPair +// REMOVED: PairVec = std::vector +// REMOVED: PairMap = std::map +using TaggedPair = std::pair; // ADDED: new pair alias +using TaggedPairVec = std::vector; // ADDED: container of new pair alias + +// ============================================================================= +// 6. NESTED CONTAINER ALIASES (containers of containers) +// ============================================================================= + +using VecOfVecInt = std::vector>; // unchanged +// REMOVED: VecOfVecFloat = std::vector> +using VecOfVecDouble = std::vector>; // ADDED: float -> double +using MapOfVecInt = std::map>; // unchanged +// REMOVED: MapOfMapInt = std::map> +using MapOfMapStr = std::map>; // ADDED: int -> string value +using VecOfMapStrInt = std::vector>; // unchanged +using UMapOfVecStr = std::unordered_map>; // unchanged +// REMOVED: VecOfPair = std::vector> +using VecOfPairStrStr = std::vector>; // ADDED: int key -> string key +using MapOfTuple = std::map>; // CHANGED: float -> double in tuple +using SetOfVecInt = std::set>; // ADDED +using UMapOfSet = std::unordered_map>; // ADDED + +// Chained nested container aliases +using Grid = VecOfVecInt; // unchanged +// REMOVED: GridRow = IntVec +using GridCol = std::vector; // ADDED: replaces GridRow +using SparseGrid = MapOfVecInt; // unchanged +// REMOVED: SparseGridIndex = std::map +using SparseGridMap = std::unordered_map; // ADDED: map -> unordered_map + +// ============================================================================= +// 7. SMART POINTER ALIASES +// ============================================================================= + +using IntShared = std::shared_ptr; +// REMOVED: IntUnique = std::unique_ptr +using IntWeak = std::weak_ptr; +// REMOVED: VoidShared = std::shared_ptr +using Int64Shared = std::shared_ptr; // ADDED +using Int64Unique = std::unique_ptr; // ADDED +using FloatShared = std::shared_ptr; // ADDED + +// Chained smart pointer aliases +using SharedInt = IntShared; // chain depth 1 (unchanged) +using SharedIntVec = std::vector; // unchanged +// REMOVED: SharedIntMap = std::map +using SharedIntUMap = std::unordered_map; // ADDED: map -> unordered_map +using WeakIntVec = std::vector; // ADDED + +// ============================================================================= +// 8. FUNCTION / CALLABLE ALIASES +// ============================================================================= + +using VoidFn = std::function; +// REMOVED: IntFn = std::function +using IntIntFn = std::function; +// REMOVED: IntIntIntFn = std::function +using BoolIntFn = std::function; +using VoidIntFn = std::function; +// REMOVED: VoidStrFn = std::function +using StrStrFn = std::function; +using LongFn = std::function; // ADDED +using BoolStrFn = std::function; // ADDED +using VoidVoidPtrFn = std::function; // ADDED + +// Function aliases using aliased types +using SizeFn = std::function; // unchanged (Size type changed) +using IndexMapFn = std::function; // unchanged +// REMOVED: RowTransformFn = std::function +using MatrixFn = std::function; // unchanged +using TensorFn = std::function; // ADDED: uses new Tensor alias +using NodeFn = std::function; // ADDED: uses new NodeId alias + +// Chained function aliases +using Callback = VoidFn; // chain depth 1 (unchanged) +using EventHandler = Callback; // chain depth 2 (unchanged) +// REMOVED: SignalHandler = EventHandler +using Listener = EventHandler; // ADDED: replaces SignalHandler +using Observer = Listener; // ADDED: chain depth 4 + +// REMOVED: Predicate = BoolIntFn +// REMOVED: Filter = Predicate +using Condition = BoolIntFn; // ADDED: replaces Predicate +using Guard = Condition; // ADDED: replaces Filter + +using Transformer = IntIntFn; // chain depth 1 (unchanged) +// REMOVED: Mapper = Transformer +// REMOVED: Reducer = Mapper +using Converter = Transformer; // ADDED: replaces Mapper +using Processor = Converter; // ADDED: replaces Reducer + +// ============================================================================= +// 9. TEMPLATE TYPE ALIAS (alias templates) +// ============================================================================= + +template +using Vec = std::vector; // unchanged + +template +using Ptr = std::shared_ptr; // unchanged + +template +using UniquePtr = std::unique_ptr; // unchanged + +template +using Dict = std::map; // unchanged + +template +using HashMap = std::unordered_map; // unchanged + +// REMOVED: Opt = std::pair +template +using Optional = std::pair; // ADDED: renamed from Opt + +template +using Grid2D = std::vector>; // unchanged + +// REMOVED: Grid3D = std::vector> +template +using Volume = std::vector>; // ADDED: renamed from Grid3D + +template +using MultiDict = std::map>; // unchanged + +template +using Fn = std::function; // unchanged + +template +using PtrVec = Vec>; // unchanged + +template +using PtrDict = Dict>; // unchanged + +template // ADDED +using WeakPtr = std::weak_ptr; + +template // ADDED +using Deque = std::deque; + +template // ADDED +using Set = std::set; + +template // ADDED +using MultiMap = std::multimap; + +// ============================================================================= +// 10. COMBINATIONS: MIXING PRIMITIVE, CONTAINER, SMART-PTR, FUNCTION ALIASES +// ============================================================================= + +// Primitive alias inside containers +using IndexVec = Vec; // unchanged +// REMOVED: HandleMap = Dict +using NodeMap = Dict; // ADDED: uses new NodeId/EdgeId aliases +// REMOVED: TokenSet = std::vector +using GraphIdVec = std::vector; // ADDED: uses new GraphId alias + +// Smart pointer of aliased container +using SharedRow = Ptr; // unchanged +// REMOVED: SharedMatrix = Ptr +using SharedTensor = Ptr; // ADDED: uses new Tensor alias +// REMOVED: UniqueGrid = UniquePtr +using UniqueMatrix = UniquePtr; // ADDED: unique ptr of Matrix + +// Container of smart pointers of aliased types +using SharedRowVec = Vec; // unchanged +// REMOVED: SharedMatrixVec = Vec +using SharedTensorVec = Vec; // ADDED: uses new SharedTensor +using WeakRowVec = Vec>; // ADDED: weak ptr of Row + +// Function aliases using template aliases +using IndexTransform = Fn; // unchanged +// REMOVED: RowFn = Fn +using RowProcessor = Fn; // ADDED: extra Index param +using MatrixBuilder = Fn; // unchanged +// REMOVED: GridReducer = Fn +using TensorReducer = Fn; // ADDED: uses Tensor alias + +// Map of function aliases +using CallbackMap = Dict; // unchanged +// REMOVED: HandlerRegistry = HashMap +using ListenerRegistry = HashMap; // ADDED: uses new Listener alias + +// Tuple combining aliased types +// REMOVED: RecordTuple = std::tuple +using NodeTuple = std::tuple; // ADDED: uses new NodeId/EdgeId +using FullRecord = std::tuple; // CHANGED: Token->GraphId, SharedRow unchanged + +// ============================================================================= +// 11. DEEP CHAINING (5+ levels) +// ============================================================================= + +// Primitive chain +using L1 = int; +using L2 = L1; +using L3 = L2; +// REMOVED: L4 = L3 +// REMOVED: L5 = L4 +// REMOVED: L6 = L5 +using L4 = long; // CHANGED: L3 -> long (breaks chain, new root type) +using L5 = L4; // chain continues from new L4 + +// Container chain +using C1 = std::vector; +using C2 = C1; +using C3 = C2; +using C4 = C3; +// REMOVED: C5 = C4 +using C5 = std::deque; // CHANGED: C4 (vector) -> deque (new root type) + +// Function chain +using F1 = std::function; +using F2 = F1; +// REMOVED: F3 = F2 +// REMOVED: F4 = F3 +// REMOVED: F5 = F4 +using F3 = std::function; // CHANGED: void(int) -> void(long) +using F4 = F3; // chain continues from new F3 + +// Smart pointer chain +// REMOVED: S1 = std::shared_ptr +// REMOVED: S2 = S1 +// REMOVED: S3 = S2 +// REMOVED: S4 = S3 +// REMOVED: S5 = S4 +using S1 = std::shared_ptr; // CHANGED: shared_ptr -> shared_ptr +using S2 = S1; +using S3 = S2; + +// Cross-kind chaining: primitive -> container -> smart ptr -> function +using XBase = UInt64; // CHANGED: UInt32 -> UInt64 +using XVec = std::vector; // unchanged (type of XBase changed) +using XShared = std::shared_ptr; // unchanged +// REMOVED: XFn = std::function +using XFn = std::function; // CHANGED: XShared(XBase) -> bool(XBase) +using XCallback = XFn; // unchanged +// REMOVED: XHandler = XCallback +using XDispatch = XCallback; // ADDED: replaces XHandler +using XRouter = XDispatch; // ADDED: chain depth 3 diff --git a/src/tests/common/CMakeLists.txt b/src/tests/common/CMakeLists.txt index e61fda3..f6632a9 100644 --- a/src/tests/common/CMakeLists.txt +++ b/src/tests/common/CMakeLists.txt @@ -31,3 +31,7 @@ target_link_libraries(common_unit_tests include(GoogleTest) gtest_discover_tests(common_unit_tests) + +add_subdirectory(unit/nsr_generator) +add_subdirectory(unit/qualified_name_generator) +add_subdirectory(unit/usr_generator) diff --git a/src/tests/common/unit/nsr_generator/CMakeLists.txt b/src/tests/common/unit/nsr_generator/CMakeLists.txt new file mode 100644 index 0000000..95a1d24 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/CMakeLists.txt @@ -0,0 +1,23 @@ +file(GLOB_RECURSE NSR_GENERATOR_DEBUG_SOURCES "src/*.cpp") + +add_executable(nsr_generator_debug + ${NSR_GENERATOR_DEBUG_SOURCES} +) + +target_compile_definitions(nsr_generator_debug PRIVATE + CLANG_FLAGS="${CLANG_EXTRA_FLAGS_CPP_ESCAPED}" +) + +target_include_directories(nsr_generator_debug PRIVATE + ${CMAKE_SOURCE_DIR}/src/common/include + ${LLVM_INCLUDE_DIRS} + ${CLANG_INCLUDE_DIRS} +) + +target_link_libraries(nsr_generator_debug + common_lib_test + ${LLVM_LIBS} + clangTooling + clangIndex + clangFrontend +) diff --git a/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/armor_class_overloading.cpp b/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/armor_class_overloading.cpp new file mode 100644 index 0000000..6033feb --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/armor_class_overloading.cpp @@ -0,0 +1,150 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include +#include +#include +#include +#include + +// Basic class with template methods +class BasicContainer { +public: + // Template method overloading with different types + template + void store(T value); + + // Template specialization for int + template<> + void store(int value); + + // Template specialization for std::string + template<> + void store(std::string value); + + // Non-template overload + void store(double value); + +}; + +// Template class with overloaded methods +template +class DataContainer { +public: + DataContainer() = default; + explicit DataContainer(T initialValue) : data(initialValue) {} + + // Const and non-const method overloading + const T& getData() const; + + T& getData(); + + // Method overloading with different parameter counts + void calculate(int a); + + void calculate(int a, int b); + +private: + T data; + + // Private overload + void calculate(int a, int b, int c); + +}; + +// Template specialization for std::string +template<> +class DataContainer { +public: + DataContainer() = default; + explicit DataContainer(const std::string& initialValue) : data(initialValue) {} + + // Different return types for specialized class + const std::string& getData() const; + + std::string& getData(); + + // Additional methods specific to string specialization + size_t getLength() const; + + bool isEmpty() const; + +private: + std::string data; +}; + +// Template class with partial specialization for pointers +template +class SmartContainer { +public: + SmartContainer() : data() {} + explicit SmartContainer(const T& value) : data(value) {} + + void process(); + + T& getValue() { return data; } + const T& getValue() const { return data; } + +private: + T data; +}; + +// Partial specialization for pointer types +template +class SmartContainer { +public: + SmartContainer() : data(nullptr), ownsPointer(false) {} + + // Constructor overloading + explicit SmartContainer(T* ptr) : data(ptr), ownsPointer(false) {} + SmartContainer(T* ptr, bool takeOwnership) : data(ptr), ownsPointer(takeOwnership) {} + + ~SmartContainer() { + if (ownsPointer && data) { + delete data; + } + } + + void process(); + + T* getValue() { return data; } + const T* getValue() const { return data; } + +private: + T* data; + bool ownsPointer; +}; + +// Template class with template methods +template +class MultiTypeContainer { +public: + MultiTypeContainer() = default; + + // Template method with default template parameter + template + void process(V value); + // Template method with explicit template parameter + template + void convert(V value); + // Specialization for int within class template + template<> + void process(int value); +}; + +// CRTP (Curiously Recurring Template Pattern) example +template +class Base { +public: + void implementation(); +}; + +class Derived1 : public Base { +public: + // Override the implementation + void implementation(); +}; + +class Derived2 : public Base { +public: + // This one uses the base implementation +}; \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/expected.txt b/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/expected.txt new file mode 100644 index 0000000..3419511 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/expected.txt @@ -0,0 +1,364 @@ +Declaration: store +Location: Line 12, Column 10 +Kind: FunctionTemplate +Clang USR: c:@S@BasicContainer@FT@>1#Tstore#t0.0#v# +Armor NSR: c:@S@BasicContainer@F@store# +------------------------------------------- + +Declaration: store +Location: Line 12, Column 10 +Kind: CXXMethod +Clang USR: c:@S@BasicContainer@FT@>1#Tstore#t0.0#v# +Armor NSR: c:@S@BasicContainer@F@store# +------------------------------------------- + +Declaration: store +Location: Line 16, Column 10 +Kind: CXXMethod +Clang USR: c:@S@BasicContainer@F@store<#I>#I# +Armor NSR: c:@S@BasicContainer@F@store# +------------------------------------------- + +Declaration: store +Location: Line 20, Column 10 +Kind: CXXMethod +Clang USR: c:@S@BasicContainer@F@store<#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C>#S0_# +Armor NSR: c:@S@BasicContainer@F@store# +------------------------------------------- + +Declaration: store +Location: Line 23, Column 10 +Kind: CXXMethod +Clang USR: c:@S@BasicContainer@F@store#d# +Armor NSR: c:@S@BasicContainer@F@store# +------------------------------------------- + +Declaration: DataContainer +Location: Line 29, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@DataContainer +Armor NSR: c:@S@DataContainer +------------------------------------------- + +Declaration: DataContainer +Location: Line 29, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@DataContainer +Armor NSR: c:@S@DataContainer +------------------------------------------- + +Declaration: DataContainer +Location: Line 31, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@DataContainer@F@DataContainer# +Armor NSR: c:@S@DataContainer@F@DataContainer# +------------------------------------------- + +Declaration: DataContainer +Location: Line 32, Column 14 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@DataContainer@F@DataContainer#t0.0# +Armor NSR: c:@S@DataContainer@F@DataContainer# +------------------------------------------- + +Declaration: getData +Location: Line 35, Column 14 +Kind: CXXMethod +Clang USR: c:@ST>1#T@DataContainer@F@getData#1 +Armor NSR: c:@S@DataContainer@F@getData# +------------------------------------------- + +Declaration: getData +Location: Line 37, Column 8 +Kind: CXXMethod +Clang USR: c:@ST>1#T@DataContainer@F@getData# +Armor NSR: c:@S@DataContainer@F@getData# +------------------------------------------- + +Declaration: calculate +Location: Line 40, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@DataContainer@F@calculate#I# +Armor NSR: c:@S@DataContainer@F@calculate# +------------------------------------------- + +Declaration: calculate +Location: Line 42, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@DataContainer@F@calculate#I#I# +Armor NSR: c:@S@DataContainer@F@calculate# +------------------------------------------- + +Declaration: data +Location: Line 45, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@DataContainer@FI@data +Armor NSR: c:@S@DataContainer@FI@data +------------------------------------------- + +Declaration: calculate +Location: Line 48, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@DataContainer@F@calculate#I#I#I# +Armor NSR: c:@S@DataContainer@F@calculate# +------------------------------------------- + +Declaration: DataContainer +Location: Line 54, Column 7 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C +Armor NSR: c:@S@DataContainer +------------------------------------------- + +Declaration: DataContainer +Location: Line 56, Column 5 +Kind: CXXConstructor +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@DataContainer# +Armor NSR: c:@S@DataContainer@F@DataContainer# +------------------------------------------- + +Declaration: DataContainer +Location: Line 57, Column 14 +Kind: CXXConstructor +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@DataContainer#&1S0_# +Armor NSR: c:@S@DataContainer@F@DataContainer# +------------------------------------------- + +Declaration: getData +Location: Line 60, Column 24 +Kind: CXXMethod +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@getData#1 +Armor NSR: c:@S@DataContainer@F@getData# +------------------------------------------- + +Declaration: getData +Location: Line 62, Column 18 +Kind: CXXMethod +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@getData# +Armor NSR: c:@S@DataContainer@F@getData# +------------------------------------------- + +Declaration: getLength +Location: Line 65, Column 12 +Kind: CXXMethod +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@getLength#1 +Armor NSR: c:@S@DataContainer@F@getLength# +------------------------------------------- + +Declaration: isEmpty +Location: Line 67, Column 10 +Kind: CXXMethod +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@isEmpty#1 +Armor NSR: c:@S@DataContainer@F@isEmpty# +------------------------------------------- + +Declaration: data +Location: Line 70, Column 17 +Kind: Field +Clang USR: c:@S@DataContainer>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@FI@data +Armor NSR: c:@S@DataContainer@FI@data +------------------------------------------- + +Declaration: SmartContainer +Location: Line 75, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@SmartContainer +Armor NSR: c:@S@SmartContainer +------------------------------------------- + +Declaration: SmartContainer +Location: Line 75, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@SmartContainer +Armor NSR: c:@S@SmartContainer +------------------------------------------- + +Declaration: SmartContainer +Location: Line 77, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@SmartContainer@F@SmartContainer# +Armor NSR: c:@S@SmartContainer@F@SmartContainer# +------------------------------------------- + +Declaration: SmartContainer +Location: Line 78, Column 14 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@SmartContainer@F@SmartContainer#&1t0.0# +Armor NSR: c:@S@SmartContainer@F@SmartContainer# +------------------------------------------- + +Declaration: process +Location: Line 80, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@SmartContainer@F@process# +Armor NSR: c:@S@SmartContainer@F@process# +------------------------------------------- + +Declaration: getValue +Location: Line 82, Column 8 +Kind: CXXMethod +Clang USR: c:@ST>1#T@SmartContainer@F@getValue# +Armor NSR: c:@S@SmartContainer@F@getValue# +------------------------------------------- + +Declaration: getValue +Location: Line 83, Column 14 +Kind: CXXMethod +Clang USR: c:@ST>1#T@SmartContainer@F@getValue#1 +Armor NSR: c:@S@SmartContainer@F@getValue# +------------------------------------------- + +Declaration: data +Location: Line 86, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@SmartContainer@FI@data +Armor NSR: c:@S@SmartContainer@FI@data +------------------------------------------- + +Declaration: SmartContainer +Location: Line 91, Column 7 +Kind: ClassTemplatePartialSpecialization +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0 +Armor NSR: c:@S@SmartContainer +------------------------------------------- + +Declaration: SmartContainer +Location: Line 93, Column 5 +Kind: CXXConstructor +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@F@SmartContainer# +Armor NSR: c:@S@SmartContainer@F@SmartContainer# +------------------------------------------- + +Declaration: SmartContainer +Location: Line 96, Column 14 +Kind: CXXConstructor +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@F@SmartContainer#S0_# +Armor NSR: c:@S@SmartContainer@F@SmartContainer# +------------------------------------------- + +Declaration: SmartContainer +Location: Line 97, Column 5 +Kind: CXXConstructor +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@F@SmartContainer#S0_#b# +Armor NSR: c:@S@SmartContainer@F@SmartContainer# +------------------------------------------- + +Declaration: ~SmartContainer +Location: Line 99, Column 5 +Kind: CXXDestructor +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@F@~SmartContainer# +Armor NSR: c:@S@SmartContainer@F@~SmartContainer# +------------------------------------------- + +Declaration: process +Location: Line 105, Column 10 +Kind: CXXMethod +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@F@process# +Armor NSR: c:@S@SmartContainer@F@process# +------------------------------------------- + +Declaration: getValue +Location: Line 107, Column 8 +Kind: CXXMethod +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@F@getValue# +Armor NSR: c:@S@SmartContainer@F@getValue# +------------------------------------------- + +Declaration: getValue +Location: Line 108, Column 14 +Kind: CXXMethod +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@F@getValue#1 +Armor NSR: c:@S@SmartContainer@F@getValue# +------------------------------------------- + +Declaration: data +Location: Line 111, Column 8 +Kind: Field +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@FI@data +Armor NSR: c:@S@SmartContainer@FI@data +------------------------------------------- + +Declaration: ownsPointer +Location: Line 112, Column 10 +Kind: Field +Clang USR: c:@SP>1#T@SmartContainer>#*t0.0@FI@ownsPointer +Armor NSR: c:@S@SmartContainer@FI@ownsPointer +------------------------------------------- + +Declaration: MultiTypeContainer +Location: Line 117, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#T@MultiTypeContainer +Armor NSR: c:@S@MultiTypeContainer +------------------------------------------- + +Declaration: MultiTypeContainer +Location: Line 117, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>2#T#T@MultiTypeContainer +Armor NSR: c:@S@MultiTypeContainer +------------------------------------------- + +Declaration: MultiTypeContainer +Location: Line 119, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>2#T#T@MultiTypeContainer@F@MultiTypeContainer# +Armor NSR: c:@S@MultiTypeContainer@F@MultiTypeContainer# +------------------------------------------- + +Declaration: process +Location: Line 123, Column 10 +Kind: FunctionTemplate +Clang USR: c:@ST>2#T#T@MultiTypeContainer@FT@>1#Tprocess#t1.0#v# +Armor NSR: c:@S@MultiTypeContainer@F@process# +------------------------------------------- + +Declaration: process +Location: Line 123, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>2#T#T@MultiTypeContainer@FT@>1#Tprocess#t1.0#v# +Armor NSR: c:@S@MultiTypeContainer@F@process# +------------------------------------------- + +Declaration: convert +Location: Line 126, Column 10 +Kind: FunctionTemplate +Clang USR: c:@ST>2#T#T@MultiTypeContainer@FT@>1#Tconvert#t1.0#v# +Armor NSR: c:@S@MultiTypeContainer@F@convert# +------------------------------------------- + +Declaration: convert +Location: Line 126, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>2#T#T@MultiTypeContainer@FT@>1#Tconvert#t1.0#v# +Armor NSR: c:@S@MultiTypeContainer@F@convert# +------------------------------------------- + +Declaration: process +Location: Line 129, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>2#T#T@MultiTypeContainer@F@process#I# +Armor NSR: c:@S@MultiTypeContainer@F@process# +------------------------------------------- + +Declaration: Base +Location: Line 134, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@Base +Armor NSR: c:@S@Base +------------------------------------------- + +Declaration: Base +Location: Line 134, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@Base +Armor NSR: c:@S@Base +------------------------------------------- + +Declaration: implementation +Location: Line 136, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@Base@F@implementation# +Armor NSR: c:@S@Base@F@implementation# +------------------------------------------- + diff --git a/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/test_class_overloading.py b/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/test_class_overloading.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_class_overloading/test_class_overloading.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/cxx_friends.cpp b/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/cxx_friends.cpp new file mode 100644 index 0000000..278f57a --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/cxx_friends.cpp @@ -0,0 +1,356 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include +#include +#include +#include +#include +#include +#include + +class ClassA; // Forward declaration + +class ClassC; + +class ClassB { +public: + void accessClassA(const ClassA& obj) {} + int help(); +}; + +class ClassA { +private: + int privateData; + +public: + ClassA(int data) : privateData(data) {} + + void ok(); + + // Declare a specific member function of ClassB as a friend + friend void ClassB::accessClassA(const ClassA& obj); + friend void ok(); + friend ClassC; +}; + +void ok(); + +union b; + +struct a{ + friend void ok(); + friend b; +}; + +union b{ + friend void ok(); + friend a; +}; + +template class A { + friend int foo(T); + friend class B; + friend T; // only in C++0x + template friend class C; + template friend A& operator+=(A&, const U&) {} +}; + +// Forward declarations with complex template patterns +template class VariadicTemplate; +template class DefaultTemplate; +template class Container = std::vector> class TemplateTemplate; + +// Type aliases +using IntAlias = int; +using StringVector = std::vector; +template using Ptr = std::shared_ptr; + +// Complex template function with SFINAE +template +T complexTemplateFunction(T value) { + return value * value; +} + +// Variadic template function +template +void variadicFunction(Args... args) { + (std::cout << ... << args) << std::endl; +} + +// Class with type alias friends +class ClassWithTypeAliasFriends { +private: + int privateData = 100; + +public: + // Type alias for a function pointer + using FunctionPtr = void(*)(ClassWithTypeAliasFriends&); + + // Type alias for a member function pointer + using MemberFunctionPtr = void(ClassWithTypeAliasFriends::*)(); + + // Friend the function pointer type + friend FunctionPtr; + + // Friend a specific function that matches the alias + friend void functionMatchingAlias(ClassWithTypeAliasFriends& obj) { + std::cout << "Function matching alias accessing private data: " << obj.privateData << std::endl; + } +}; + +// Class with complex template friends +template +class ComplexClass { +private: + T data; + + // Private nested type + struct PrivateNested { + T nestedData; + }; + + PrivateNested nested; + +public: + ComplexClass(T val) : data(val), nested{val} {} + + // Friend function with SFINAE + template + friend U accessWithSFINAE(const ComplexClass& obj) { + return obj.data; + } + + // Friend variadic template class + template + friend class VariadicTemplate; + + // Friend template template class + template class Container> + friend class TemplateTemplate; + + // Friend function with decltype and auto return type + template + friend auto complexFriendFunction(const ComplexClass& obj) -> decltype(obj.data) { + return obj.data; + } + + // Friend class template with default parameter + template + friend class DefaultTemplate; +}; + +// Variadic template class implementation +template +class VariadicTemplate { +private: + std::tuple data; + +public: + VariadicTemplate(Ts... values) : data(values...) {} + + // Method to access ComplexClass private data + template + void accessComplexClassData(const ComplexClass& obj) { + std::cout << "VariadicTemplate accessing ComplexClass data: " << obj.data << std::endl; + std::cout << "VariadicTemplate accessing ComplexClass nested data: " << obj.nested.nestedData << std::endl; + } +}; + +// Template template class implementation +template class Container> +class TemplateTemplate { +private: + Container container; + +public: + // Method to access ComplexClass private data + void accessComplexClassData(const ComplexClass& obj) { + std::cout << "TemplateTemplate accessing ComplexClass data: " << obj.data << std::endl; + } +}; + +// Default template class implementation +template +class DefaultTemplate { +public: + // Method to access ComplexClass private data + void accessComplexClassData(const ComplexClass& obj) { + std::cout << "DefaultTemplate accessing ComplexClass data: " << obj.data << std::endl; + } +}; + +// Class with conditional friends using SFINAE +template +class ConditionalFriends { +private: + T data; + +public: + ConditionalFriends(T val) : data(val) {} + + // Friend only if T is integral + template + friend U + integralOnlyFriend(const ConditionalFriends& obj) { + std::cout << "Integral-only friend accessing data: " << obj.data << std::endl; + } + + // Friend only if T is floating point + template + friend void + floatOnlyFriend(const ConditionalFriends& obj) { + std::cout << "Float-only friend accessing data: " << obj.data << std::endl; + } +}; + +// Class with recursive friend relationship +template +class RecursiveTemplate { +private: + T data[N]; + +public: + RecursiveTemplate(T val) { + for (size_t i = 0; i < N; ++i) { + data[i] = val; + } + } + + // Friend the next smaller size + friend class RecursiveTemplate; + + // Method to access smaller template's data + void accessSmallerTemplate(const RecursiveTemplate& smaller) { + std::cout << "Accessing smaller template's first element: " << smaller.data[0] << std::endl; + } +}; + +// Base case for recursive template +template +class RecursiveTemplate { +private: + T dummy; + +public: + RecursiveTemplate(T val) : dummy(val) {} + + // Friend the next larger size + friend class RecursiveTemplate; +}; + +// Class with friend function that uses perfect forwarding +class PerfectForwardingClass { +private: + int data = 42; + +public: + // Friend function with perfect forwarding + template + friend auto perfectForwardingFriend(PerfectForwardingClass& obj, Args&&... args) { + std::cout << "Perfect forwarding friend accessing data: " << obj.data << std::endl; + return std::make_tuple(obj.data, std::forward(args)...); + } +}; + +// Class with friend operators +template +class OperatorFriendClass { +private: + T value; + +public: + OperatorFriendClass(T val) : value(val) {} + + // Friend operator overloads + template + friend OperatorFriendClass operator+(const OperatorFriendClass& lhs, const OperatorFriendClass& rhs) { + return OperatorFriendClass(lhs.value + rhs.value); + } + + template + friend std::ostream& operator<<(std::ostream& os, const OperatorFriendClass& obj) { + return os << "OperatorFriendClass{" << obj.value << "}"; + } + + // Friend comparison operators with SFINAE + template + friend bool + operator==(const OperatorFriendClass& lhs, const OperatorFriendClass& rhs) { + return lhs.value == rhs.value; + } +}; + +// Class with type traits and concept-like friends (C++17 style) +template +class TypeTraitsFriendClass { +private: + T data; + +public: + TypeTraitsFriendClass(T val) : data(val) {} + + // Friend only arithmetic types + template + friend U + getArithmeticData(const TypeTraitsFriendClass& obj) { + return obj.data; + } + + // Friend only class types + template + friend const U& + getClassData(const TypeTraitsFriendClass& obj) { + return obj.data; + } +}; + +// Class with alias template friends +template +class AliasTemplateFriendClass { +private: + T data; + +public: + AliasTemplateFriendClass(T val) : data(val) {} + + // Method to demonstrate usage + void showData() const { + std::cout << "AliasTemplateFriendClass data: " << data << std::endl; + } +}; + +// Function to demonstrate alias template friendship +template +void demonstrateAliasTemplateFriendship() { + AliasTemplateFriendClass obj(42); + Ptr> ptr = std::make_shared>(obj); + std::cout << "Accessing through alias template friend: " << ptr->data << std::endl; +} + +// Specialized template for demonstration +class SpecializedFriendBase { +private: + int secretData = 100; + +public: + // Friend a specific specialization + template friend class SpecializedFriend; +}; + +// Primary template +template +class SpecializedFriend { +public: + void doSomething() { + std::cout << "Primary template" << std::endl; + } +}; + +// Explicit specialization (not dependent) +template<> +class SpecializedFriend { +public: + void accessBaseData(SpecializedFriendBase& base) { + std::cout << "Specialized friend accessing base data: " << base.secretData << std::endl; + } +}; diff --git a/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/expected.txt b/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/expected.txt new file mode 100644 index 0000000..a6121b4 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/expected.txt @@ -0,0 +1,973 @@ +Declaration: accessClassA +Location: Line 15, Column 10 +Kind: CXXMethod +Clang USR: c:@S@ClassB@F@accessClassA#&1$@S@ClassA# +Armor NSR: c:@S@ClassB@F@accessClassA# +------------------------------------------- + +Declaration: ClassA +Location: Line 24, Column 5 +Kind: CXXConstructor +Clang USR: c:@S@ClassA@F@ClassA#I# +Armor NSR: c:@S@ClassA@F@ClassA# +------------------------------------------- + +Declaration: Friend +Location: Line 29, Column 25 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@ClassB@F@accessClassA#(F) +------------------------------------------- + +Declaration: accessClassA +Location: Line 29, Column 25 +Kind: CXXMethod +Clang USR: c:@S@ClassB@F@accessClassA#&1$@S@ClassA# +Armor NSR: c:@S@ClassB@F@accessClassA# +------------------------------------------- + +Declaration: Friend +Location: Line 30, Column 17 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@ok#(F) +------------------------------------------- + +Declaration: Friend +Location: Line 31, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@ClassC(F) +------------------------------------------- + +Declaration: Friend +Location: Line 39, Column 17 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@ok#(F) +------------------------------------------- + +Declaration: Friend +Location: Line 40, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@U@b(F) +------------------------------------------- + +Declaration: Friend +Location: Line 44, Column 17 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@ok#(F) +------------------------------------------- + +Declaration: Friend +Location: Line 45, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@a(F) +------------------------------------------- + +Declaration: A +Location: Line 48, Column 29 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@A +Armor NSR: c:@S@A +------------------------------------------- + +Declaration: A +Location: Line 48, Column 29 +Kind: CXXRecord +Clang USR: c:@ST>1#T@A +Armor NSR: c:@S@A +------------------------------------------- + +Declaration: Friend +Location: Line 49, Column 15 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@foo#(F) +------------------------------------------- + +Declaration: foo +Location: Line 49, Column 15 +Kind: Function +Clang USR: c:@F@foo#t0.0# +Armor NSR: c:@F@foo# +------------------------------------------- + +Declaration: Friend +Location: Line 50, Column 11 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@B(F) +------------------------------------------- + +Declaration: Friend +Location: Line 51, Column 11 +Kind: Friend +Clang USR: c: +Armor NSR: c:t0.0(F) +------------------------------------------- + +Declaration: Friend +Location: Line 52, Column 39 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@C(F) +------------------------------------------- + +Declaration: C +Location: Line 52, Column 39 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@C +Armor NSR: c:@S@C +------------------------------------------- + +Declaration: C +Location: Line 52, Column 39 +Kind: CXXRecord +Clang USR: c:@ST>1#T@C +Armor NSR: c:@S@C +------------------------------------------- + +Declaration: Friend +Location: Line 53, Column 36 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@operator+=#(F) +------------------------------------------- + +Declaration: operator+= +Location: Line 53, Column 36 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Toperator+=#&>@ST>1#T@A1t0.0#&1t1.0#S0_# +Armor NSR: c:@F@operator+=# +------------------------------------------- + +Declaration: operator+= +Location: Line 53, Column 36 +Kind: Function +Clang USR: c:@FT@>1#Toperator+=#&>@ST>1#T@A1t0.0#&1t1.0#S0_# +Armor NSR: c:@F@operator+=# +------------------------------------------- + +Declaration: VariadicTemplate +Location: Line 57, Column 32 +Kind: ClassTemplate +Clang USR: c:@ST>1#pT@VariadicTemplate +Armor NSR: c:@S@VariadicTemplate +------------------------------------------- + +Declaration: VariadicTemplate +Location: Line 57, Column 32 +Kind: CXXRecord +Clang USR: c:@ST>1#pT@VariadicTemplate +Armor NSR: c:@S@VariadicTemplate +------------------------------------------- + +Declaration: DefaultTemplate +Location: Line 58, Column 47 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#T@DefaultTemplate +Armor NSR: c:@S@DefaultTemplate +------------------------------------------- + +Declaration: DefaultTemplate +Location: Line 58, Column 47 +Kind: CXXRecord +Clang USR: c:@ST>2#T#T@DefaultTemplate +Armor NSR: c:@S@DefaultTemplate +------------------------------------------- + +Declaration: TemplateTemplate +Location: Line 59, Column 78 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate +Armor NSR: c:@S@TemplateTemplate +------------------------------------------- + +Declaration: TemplateTemplate +Location: Line 59, Column 78 +Kind: CXXRecord +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate +Armor NSR: c:@S@TemplateTemplate +------------------------------------------- + +Declaration: IntAlias +Location: Line 62, Column 7 +Kind: TypeAlias +Clang USR: c:@IntAlias +Armor NSR: c:@T@IntAlias +------------------------------------------- + +Declaration: StringVector +Location: Line 63, Column 7 +Kind: TypeAlias +Clang USR: c:@StringVector +Armor NSR: c:@T@StringVector +------------------------------------------- + +Declaration: Ptr +Location: Line 64, Column 28 +Kind: TypeAlias +Clang USR: c:@Ptr +Armor NSR: c:@T@Ptr +------------------------------------------- + +Declaration: complexTemplateFunction +Location: Line 68, Column 3 +Kind: FunctionTemplate +Clang USR: c:@FT@>2#T#TcomplexTemplateFunction#t0.0#S0_# +Armor NSR: c:@F@complexTemplateFunction# +------------------------------------------- + +Declaration: complexTemplateFunction +Location: Line 68, Column 3 +Kind: Function +Clang USR: c:@FT@>2#T#TcomplexTemplateFunction#t0.0#S0_# +Armor NSR: c:@F@complexTemplateFunction# +------------------------------------------- + +Declaration: variadicFunction +Location: Line 74, Column 6 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#pTvariadicFunction#Pt0.0#v# +Armor NSR: c:@F@variadicFunction# +------------------------------------------- + +Declaration: variadicFunction +Location: Line 74, Column 6 +Kind: Function +Clang USR: c:@FT@>1#pTvariadicFunction#Pt0.0#v# +Armor NSR: c:@F@variadicFunction# +------------------------------------------- + +Declaration: FunctionPtr +Location: Line 85, Column 11 +Kind: TypeAlias +Clang USR: c:@S@ClassWithTypeAliasFriends@FunctionPtr +Armor NSR: c:@S@ClassWithTypeAliasFriends@T@FunctionPtr +------------------------------------------- + +Declaration: MemberFunctionPtr +Location: Line 88, Column 11 +Kind: TypeAlias +Clang USR: c:@S@ClassWithTypeAliasFriends@MemberFunctionPtr +Armor NSR: c:@S@ClassWithTypeAliasFriends@T@MemberFunctionPtr +------------------------------------------- + +Declaration: Friend +Location: Line 91, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:*Fv(#&$@S@ClassWithTypeAliasFriends)(F) +------------------------------------------- + +Declaration: Friend +Location: Line 94, Column 17 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@functionMatchingAlias#(F) +------------------------------------------- + +Declaration: functionMatchingAlias +Location: Line 94, Column 17 +Kind: Function +Clang USR: c:@F@functionMatchingAlias#&$@S@ClassWithTypeAliasFriends# +Armor NSR: c:@F@functionMatchingAlias# +------------------------------------------- + +Declaration: ComplexClass +Location: Line 101, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@ComplexClass +Armor NSR: c:@S@ComplexClass +------------------------------------------- + +Declaration: ComplexClass +Location: Line 101, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@ComplexClass +Armor NSR: c:@S@ComplexClass +------------------------------------------- + +Declaration: data +Location: Line 103, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@ComplexClass@FI@data +Armor NSR: c:@S@ComplexClass@FI@data +------------------------------------------- + +Declaration: PrivateNested +Location: Line 106, Column 12 +Kind: CXXRecord +Clang USR: c:@ST>1#T@ComplexClass@S@PrivateNested +Armor NSR: c:@S@ComplexClass@S@PrivateNested +------------------------------------------- + +Declaration: nestedData +Location: Line 107, Column 11 +Kind: Field +Clang USR: c:@ST>1#T@ComplexClass@S@PrivateNested@FI@nestedData +Armor NSR: c:@S@ComplexClass@S@PrivateNested@FI@nestedData +------------------------------------------- + +Declaration: nested +Location: Line 110, Column 19 +Kind: Field +Clang USR: c:@ST>1#T@ComplexClass@FI@nested +Armor NSR: c:@S@ComplexClass@FI@nested +------------------------------------------- + +Declaration: ComplexClass +Location: Line 113, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@ComplexClass@F@ComplexClass#t0.0# +Armor NSR: c:@S@ComplexClass@F@ComplexClass# +------------------------------------------- + +Declaration: Friend +Location: Line 117, Column 14 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@accessWithSFINAE#(F) +------------------------------------------- + +Declaration: accessWithSFINAE +Location: Line 117, Column 14 +Kind: FunctionTemplate +Clang USR: c:@FT@>2#T#TaccessWithSFINAE#&1>@ST>1#T@ComplexClass1t1.0#S2_# +Armor NSR: c:@F@accessWithSFINAE# +------------------------------------------- + +Declaration: accessWithSFINAE +Location: Line 117, Column 14 +Kind: Function +Clang USR: c:@FT@>2#T#TaccessWithSFINAE#&1>@ST>1#T@ComplexClass1t1.0#S2_# +Armor NSR: c:@F@accessWithSFINAE# +------------------------------------------- + +Declaration: Friend +Location: Line 123, Column 18 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@VariadicTemplate(F) +------------------------------------------- + +Declaration: VariadicTemplate +Location: Line 123, Column 18 +Kind: ClassTemplate +Clang USR: c:@ST>1#pT@VariadicTemplate +Armor NSR: c:@S@VariadicTemplate +------------------------------------------- + +Declaration: VariadicTemplate +Location: Line 123, Column 18 +Kind: CXXRecord +Clang USR: c:@ST>1#pT@VariadicTemplate +Armor NSR: c:@S@VariadicTemplate +------------------------------------------- + +Declaration: Friend +Location: Line 127, Column 18 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@TemplateTemplate(F) +------------------------------------------- + +Declaration: TemplateTemplate +Location: Line 127, Column 18 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate +Armor NSR: c:@S@TemplateTemplate +------------------------------------------- + +Declaration: TemplateTemplate +Location: Line 127, Column 18 +Kind: CXXRecord +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate +Armor NSR: c:@S@TemplateTemplate +------------------------------------------- + +Declaration: Friend +Location: Line 131, Column 17 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@complexFriendFunction#(F) +------------------------------------------- + +Declaration: complexFriendFunction +Location: Line 131, Column 17 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#TcomplexFriendFunction#&1>@ST>1#T@ComplexClass1t1.0# # +Armor NSR: c:@F@complexFriendFunction# +------------------------------------------- + +Declaration: complexFriendFunction +Location: Line 131, Column 17 +Kind: Function +Clang USR: c:@FT@>1#TcomplexFriendFunction#&1>@ST>1#T@ComplexClass1t1.0# # +Armor NSR: c:@F@complexFriendFunction# +------------------------------------------- + +Declaration: Friend +Location: Line 137, Column 18 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@DefaultTemplate(F) +------------------------------------------- + +Declaration: DefaultTemplate +Location: Line 137, Column 18 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#T@DefaultTemplate +Armor NSR: c:@S@DefaultTemplate +------------------------------------------- + +Declaration: DefaultTemplate +Location: Line 137, Column 18 +Kind: CXXRecord +Clang USR: c:@ST>2#T#T@DefaultTemplate +Armor NSR: c:@S@DefaultTemplate +------------------------------------------- + +Declaration: VariadicTemplate +Location: Line 142, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#pT@VariadicTemplate +Armor NSR: c:@S@VariadicTemplate +------------------------------------------- + +Declaration: VariadicTemplate +Location: Line 142, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#pT@VariadicTemplate +Armor NSR: c:@S@VariadicTemplate +------------------------------------------- + +Declaration: data +Location: Line 144, Column 23 +Kind: Field +Clang USR: c:@ST>1#pT@VariadicTemplate@FI@data +Armor NSR: c:@S@VariadicTemplate@FI@data +------------------------------------------- + +Declaration: VariadicTemplate +Location: Line 147, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#pT@VariadicTemplate@F@VariadicTemplate#Pt0.0# +Armor NSR: c:@S@VariadicTemplate@F@VariadicTemplate# +------------------------------------------- + +Declaration: accessComplexClassData +Location: Line 151, Column 10 +Kind: FunctionTemplate +Clang USR: c:@ST>1#pT@VariadicTemplate@FT@>1#TaccessComplexClassData#&1>@ST>1#T@ComplexClass1t1.0#v# +Armor NSR: c:@S@VariadicTemplate@F@accessComplexClassData# +------------------------------------------- + +Declaration: accessComplexClassData +Location: Line 151, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#pT@VariadicTemplate@FT@>1#TaccessComplexClassData#&1>@ST>1#T@ComplexClass1t1.0#v# +Armor NSR: c:@S@VariadicTemplate@F@accessComplexClassData# +------------------------------------------- + +Declaration: TemplateTemplate +Location: Line 159, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate +Armor NSR: c:@S@TemplateTemplate +------------------------------------------- + +Declaration: TemplateTemplate +Location: Line 159, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate +Armor NSR: c:@S@TemplateTemplate +------------------------------------------- + +Declaration: container +Location: Line 161, Column 18 +Kind: Field +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate@FI@container +Armor NSR: c:@S@TemplateTemplate@FI@container +------------------------------------------- + +Declaration: accessComplexClassData +Location: Line 165, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>2#T#t>1#T@TemplateTemplate@F@accessComplexClassData#&1>@ST>1#T@ComplexClass1t0.0# +Armor NSR: c:@S@TemplateTemplate@F@accessComplexClassData# +------------------------------------------- + +Declaration: DefaultTemplate +Location: Line 172, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#T@DefaultTemplate +Armor NSR: c:@S@DefaultTemplate +------------------------------------------- + +Declaration: DefaultTemplate +Location: Line 172, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>2#T#T@DefaultTemplate +Armor NSR: c:@S@DefaultTemplate +------------------------------------------- + +Declaration: accessComplexClassData +Location: Line 175, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>2#T#T@DefaultTemplate@F@accessComplexClassData#&1>@ST>1#T@ComplexClass1t0.0# +Armor NSR: c:@S@DefaultTemplate@F@accessComplexClassData# +------------------------------------------- + +Declaration: ConditionalFriends +Location: Line 182, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@ConditionalFriends +Armor NSR: c:@S@ConditionalFriends +------------------------------------------- + +Declaration: ConditionalFriends +Location: Line 182, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@ConditionalFriends +Armor NSR: c:@S@ConditionalFriends +------------------------------------------- + +Declaration: data +Location: Line 184, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@ConditionalFriends@FI@data +Armor NSR: c:@S@ConditionalFriends@FI@data +------------------------------------------- + +Declaration: ConditionalFriends +Location: Line 187, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@ConditionalFriends@F@ConditionalFriends#t0.0# +Armor NSR: c:@S@ConditionalFriends@F@ConditionalFriends# +------------------------------------------- + +Declaration: Friend +Location: Line 192, Column 5 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@integralOnlyFriend#(F) +------------------------------------------- + +Declaration: integralOnlyFriend +Location: Line 192, Column 5 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#TintegralOnlyFriend#&1>@ST>1#T@ConditionalFriends1t1.0#S2_# +Armor NSR: c:@F@integralOnlyFriend# +------------------------------------------- + +Declaration: integralOnlyFriend +Location: Line 192, Column 5 +Kind: Function +Clang USR: c:@FT@>1#TintegralOnlyFriend#&1>@ST>1#T@ConditionalFriends1t1.0#S2_# +Armor NSR: c:@F@integralOnlyFriend# +------------------------------------------- + +Declaration: Friend +Location: Line 199, Column 5 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@floatOnlyFriend#(F) +------------------------------------------- + +Declaration: floatOnlyFriend +Location: Line 199, Column 5 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#TfloatOnlyFriend#&1>@ST>1#T@ConditionalFriends1t1.0#v# +Armor NSR: c:@F@floatOnlyFriend# +------------------------------------------- + +Declaration: floatOnlyFriend +Location: Line 199, Column 5 +Kind: Function +Clang USR: c:@FT@>1#TfloatOnlyFriend#&1>@ST>1#T@ConditionalFriends1t1.0#v# +Armor NSR: c:@F@floatOnlyFriend# +------------------------------------------- + +Declaration: RecursiveTemplate +Location: Line 206, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#Nl@RecursiveTemplate +Armor NSR: c:@S@RecursiveTemplate +------------------------------------------- + +Declaration: RecursiveTemplate +Location: Line 206, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>2#T#Nl@RecursiveTemplate +Armor NSR: c:@S@RecursiveTemplate +------------------------------------------- + +Declaration: data +Location: Line 208, Column 7 +Kind: Field +Clang USR: c:@ST>2#T#Nl@RecursiveTemplate@FI@data +Armor NSR: c:@S@RecursiveTemplate@FI@data +------------------------------------------- + +Declaration: RecursiveTemplate +Location: Line 211, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>2#T#Nl@RecursiveTemplate@F@RecursiveTemplate#t0.0# +Armor NSR: c:@S@RecursiveTemplate@F@RecursiveTemplate# +------------------------------------------- + +Declaration: i +Location: Line 212, Column 21 +Kind: Var +Clang USR: c:cxx_friends.cpp@5369@ST>2#T#Nl@RecursiveTemplate@F@RecursiveTemplate#t0.0#@i +Armor NSR: c:cxx_friends.cpp@5369@S@RecursiveTemplate@F@RecursiveTemplate#@i +------------------------------------------- + +Declaration: Friend +Location: Line 218, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@RecursiveTemplate(F) +------------------------------------------- + +Declaration: accessSmallerTemplate +Location: Line 221, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>2#T#Nl@RecursiveTemplate@F@accessSmallerTemplate#&1>@ST>2#T#Nl@RecursiveTemplate2t0.0# +Armor NSR: c:@S@RecursiveTemplate@F@accessSmallerTemplate# +------------------------------------------- + +Declaration: RecursiveTemplate +Location: Line 228, Column 7 +Kind: ClassTemplatePartialSpecialization +Clang USR: c:@SP>1#T@RecursiveTemplate>#t0.0#Vl0 +Armor NSR: c:@S@RecursiveTemplate +------------------------------------------- + +Declaration: dummy +Location: Line 230, Column 7 +Kind: Field +Clang USR: c:@SP>1#T@RecursiveTemplate>#t0.0#Vl0@FI@dummy +Armor NSR: c:@S@RecursiveTemplate@FI@dummy +------------------------------------------- + +Declaration: RecursiveTemplate +Location: Line 233, Column 5 +Kind: CXXConstructor +Clang USR: c:@SP>1#T@RecursiveTemplate>#t0.0#Vl0@F@RecursiveTemplate#S0_# +Armor NSR: c:@S@RecursiveTemplate@F@RecursiveTemplate# +------------------------------------------- + +Declaration: Friend +Location: Line 236, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@RecursiveTemplate(F) +------------------------------------------- + +Declaration: Friend +Location: Line 247, Column 17 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@perfectForwardingFriend#(F) +------------------------------------------- + +Declaration: perfectForwardingFriend +Location: Line 247, Column 17 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#pTperfectForwardingFriend#&$@S@PerfectForwardingClass#P&&t0.0# # +Armor NSR: c:@F@perfectForwardingFriend# +------------------------------------------- + +Declaration: perfectForwardingFriend +Location: Line 247, Column 17 +Kind: Function +Clang USR: c:@FT@>1#pTperfectForwardingFriend#&$@S@PerfectForwardingClass#P&&t0.0# # +Armor NSR: c:@F@perfectForwardingFriend# +------------------------------------------- + +Declaration: OperatorFriendClass +Location: Line 255, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@OperatorFriendClass +Armor NSR: c:@S@OperatorFriendClass +------------------------------------------- + +Declaration: OperatorFriendClass +Location: Line 255, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@OperatorFriendClass +Armor NSR: c:@S@OperatorFriendClass +------------------------------------------- + +Declaration: value +Location: Line 257, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@OperatorFriendClass@FI@value +Armor NSR: c:@S@OperatorFriendClass@FI@value +------------------------------------------- + +Declaration: OperatorFriendClass +Location: Line 260, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@OperatorFriendClass@F@OperatorFriendClass#t0.0# +Armor NSR: c:@S@OperatorFriendClass@F@OperatorFriendClass# +------------------------------------------- + +Declaration: Friend +Location: Line 264, Column 35 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@operator+#(F) +------------------------------------------- + +Declaration: operator+ +Location: Line 264, Column 35 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Toperator+#&1>@ST>1#T@OperatorFriendClass1t1.0#S0_#S1_# +Armor NSR: c:@F@operator+# +------------------------------------------- + +Declaration: operator+ +Location: Line 264, Column 35 +Kind: Function +Clang USR: c:@FT@>1#Toperator+#&1>@ST>1#T@OperatorFriendClass1t1.0#S0_#S1_# +Armor NSR: c:@F@operator+# +------------------------------------------- + +Declaration: Friend +Location: Line 269, Column 26 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@operator<<#(F) +------------------------------------------- + +Declaration: operator<< +Location: Line 269, Column 26 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Toperator<<#&$@N@std@S@basic_ostream>#C#$@N@std@S@char_traits>#C#&1>@ST>1#T@OperatorFriendClass1t1.0#S0_# +Armor NSR: c:@F@operator<<# +------------------------------------------- + +Declaration: operator<< +Location: Line 269, Column 26 +Kind: Function +Clang USR: c:@FT@>1#Toperator<<#&$@N@std@S@basic_ostream>#C#$@N@std@S@char_traits>#C#&1>@ST>1#T@OperatorFriendClass1t1.0#S0_# +Armor NSR: c:@F@operator<<# +------------------------------------------- + +Declaration: Friend +Location: Line 276, Column 5 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@operator==#(F) +------------------------------------------- + +Declaration: operator== +Location: Line 276, Column 5 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Toperator==#&1>@ST>1#T@OperatorFriendClass1t1.0#S0_#b# +Armor NSR: c:@F@operator==# +------------------------------------------- + +Declaration: operator== +Location: Line 276, Column 5 +Kind: Function +Clang USR: c:@FT@>1#Toperator==#&1>@ST>1#T@OperatorFriendClass1t1.0#S0_#b# +Armor NSR: c:@F@operator==# +------------------------------------------- + +Declaration: TypeTraitsFriendClass +Location: Line 283, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@TypeTraitsFriendClass +Armor NSR: c:@S@TypeTraitsFriendClass +------------------------------------------- + +Declaration: TypeTraitsFriendClass +Location: Line 283, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@TypeTraitsFriendClass +Armor NSR: c:@S@TypeTraitsFriendClass +------------------------------------------- + +Declaration: data +Location: Line 285, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@TypeTraitsFriendClass@FI@data +Armor NSR: c:@S@TypeTraitsFriendClass@FI@data +------------------------------------------- + +Declaration: TypeTraitsFriendClass +Location: Line 288, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@TypeTraitsFriendClass@F@TypeTraitsFriendClass#t0.0# +Armor NSR: c:@S@TypeTraitsFriendClass@F@TypeTraitsFriendClass# +------------------------------------------- + +Declaration: Friend +Location: Line 293, Column 5 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@getArithmeticData#(F) +------------------------------------------- + +Declaration: getArithmeticData +Location: Line 293, Column 5 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#TgetArithmeticData#&1>@ST>1#T@TypeTraitsFriendClass1t1.0#S2_# +Armor NSR: c:@F@getArithmeticData# +------------------------------------------- + +Declaration: getArithmeticData +Location: Line 293, Column 5 +Kind: Function +Clang USR: c:@FT@>1#TgetArithmeticData#&1>@ST>1#T@TypeTraitsFriendClass1t1.0#S2_# +Armor NSR: c:@F@getArithmeticData# +------------------------------------------- + +Declaration: Friend +Location: Line 300, Column 5 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@getClassData#(F) +------------------------------------------- + +Declaration: getClassData +Location: Line 300, Column 5 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#TgetClassData#&1>@ST>1#T@TypeTraitsFriendClass1t1.0#&1S2_# +Armor NSR: c:@F@getClassData# +------------------------------------------- + +Declaration: getClassData +Location: Line 300, Column 5 +Kind: Function +Clang USR: c:@FT@>1#TgetClassData#&1>@ST>1#T@TypeTraitsFriendClass1t1.0#&1S2_# +Armor NSR: c:@F@getClassData# +------------------------------------------- + +Declaration: AliasTemplateFriendClass +Location: Line 307, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@AliasTemplateFriendClass +Armor NSR: c:@S@AliasTemplateFriendClass +------------------------------------------- + +Declaration: AliasTemplateFriendClass +Location: Line 307, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@AliasTemplateFriendClass +Armor NSR: c:@S@AliasTemplateFriendClass +------------------------------------------- + +Declaration: data +Location: Line 309, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@AliasTemplateFriendClass@FI@data +Armor NSR: c:@S@AliasTemplateFriendClass@FI@data +------------------------------------------- + +Declaration: AliasTemplateFriendClass +Location: Line 312, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@AliasTemplateFriendClass@F@AliasTemplateFriendClass#t0.0# +Armor NSR: c:@S@AliasTemplateFriendClass@F@AliasTemplateFriendClass# +------------------------------------------- + +Declaration: showData +Location: Line 315, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@AliasTemplateFriendClass@F@showData#1 +Armor NSR: c:@S@AliasTemplateFriendClass@F@showData# +------------------------------------------- + +Declaration: demonstrateAliasTemplateFriendship +Location: Line 322, Column 6 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#TdemonstrateAliasTemplateFriendship#v# +Armor NSR: c:@F@demonstrateAliasTemplateFriendship# +------------------------------------------- + +Declaration: demonstrateAliasTemplateFriendship +Location: Line 322, Column 6 +Kind: Function +Clang USR: c:@FT@>1#TdemonstrateAliasTemplateFriendship#v# +Armor NSR: c:@F@demonstrateAliasTemplateFriendship# +------------------------------------------- + +Declaration: obj +Location: Line 323, Column 33 +Kind: Var +Clang USR: c:cxx_friends.cpp@8295@FT@>1#TdemonstrateAliasTemplateFriendship#v#@obj +Armor NSR: c:cxx_friends.cpp@8295@F@demonstrateAliasTemplateFriendship#@obj +------------------------------------------- + +Declaration: ptr +Location: Line 324, Column 38 +Kind: Var +Clang USR: c:cxx_friends.cpp@8336@FT@>1#TdemonstrateAliasTemplateFriendship#v#@ptr +Armor NSR: c:cxx_friends.cpp@8336@F@demonstrateAliasTemplateFriendship#@ptr +------------------------------------------- + +Declaration: Friend +Location: Line 335, Column 39 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@SpecializedFriend(F) +------------------------------------------- + +Declaration: SpecializedFriend +Location: Line 335, Column 39 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@SpecializedFriend +Armor NSR: c:@S@SpecializedFriend +------------------------------------------- + +Declaration: SpecializedFriend +Location: Line 335, Column 39 +Kind: CXXRecord +Clang USR: c:@ST>1#T@SpecializedFriend +Armor NSR: c:@S@SpecializedFriend +------------------------------------------- + +Declaration: SpecializedFriend +Location: Line 340, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@SpecializedFriend +Armor NSR: c:@S@SpecializedFriend +------------------------------------------- + +Declaration: SpecializedFriend +Location: Line 340, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@SpecializedFriend +Armor NSR: c:@S@SpecializedFriend +------------------------------------------- + +Declaration: doSomething +Location: Line 342, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@SpecializedFriend@F@doSomething# +Armor NSR: c:@S@SpecializedFriend@F@doSomething# +------------------------------------------- + +Declaration: SpecializedFriend +Location: Line 349, Column 7 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@SpecializedFriend>#I +Armor NSR: c:@S@SpecializedFriend +------------------------------------------- + +Declaration: accessBaseData +Location: Line 351, Column 10 +Kind: CXXMethod +Clang USR: c:@S@SpecializedFriend>#I@F@accessBaseData#&$@S@SpecializedFriendBase# +Armor NSR: c:@S@SpecializedFriend@F@accessBaseData# +------------------------------------------- + diff --git a/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/test_cxx_friends.py b/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/test_cxx_friends.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_cxx_friends/test_cxx_friends.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/armor_function_overloading.cpp b/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/armor_function_overloading.cpp new file mode 100644 index 0000000..bc14a4c --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/armor_function_overloading.cpp @@ -0,0 +1,40 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include +#include +#include + +// Basic function overloading with different parameter types +void print(int value); +void print(double value); +void print(const std::string& value); + +// Function overloading with different number of parameters +void calculate(int a); +void calculate(int a, int b); +void calculate(int a, int b, int c); + +// Function template overloading +template +T add(T a, T b); + +// Template specialization +template<> +std::string add(std::string a, std::string b); + +// Overloading with template and non-template functions +void process(int value); + +template +void process(T value); + +// Template function with friend function templates +template +struct WithFriendTemplates; + +template +WithFriendTemplates transform(const WithFriendTemplates& obj, U (*func)(U)); + +// Specialization for int +template<> +WithFriendTemplates transform(const WithFriendTemplates& obj, int (*func)(int)); diff --git a/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/expected.txt b/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/expected.txt new file mode 100644 index 0000000..3435705 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/expected.txt @@ -0,0 +1,119 @@ +Declaration: print +Location: Line 6, Column 6 +Kind: Function +Clang USR: c:@F@print#I# +Armor NSR: c:@F@print# +------------------------------------------- + +Declaration: print +Location: Line 7, Column 6 +Kind: Function +Clang USR: c:@F@print#d# +Armor NSR: c:@F@print# +------------------------------------------- + +Declaration: print +Location: Line 8, Column 6 +Kind: Function +Clang USR: c:@F@print#&1$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C# +Armor NSR: c:@F@print# +------------------------------------------- + +Declaration: calculate +Location: Line 11, Column 6 +Kind: Function +Clang USR: c:@F@calculate#I# +Armor NSR: c:@F@calculate# +------------------------------------------- + +Declaration: calculate +Location: Line 12, Column 6 +Kind: Function +Clang USR: c:@F@calculate#I#I# +Armor NSR: c:@F@calculate# +------------------------------------------- + +Declaration: calculate +Location: Line 13, Column 6 +Kind: Function +Clang USR: c:@F@calculate#I#I#I# +Armor NSR: c:@F@calculate# +------------------------------------------- + +Declaration: add +Location: Line 17, Column 3 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Tadd#t0.0#S0_#S0_# +Armor NSR: c:@F@add# +------------------------------------------- + +Declaration: add +Location: Line 17, Column 3 +Kind: Function +Clang USR: c:@FT@>1#Tadd#t0.0#S0_#S0_# +Armor NSR: c:@F@add# +------------------------------------------- + +Declaration: add +Location: Line 21, Column 13 +Kind: Function +Clang USR: c:@F@add<#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C>#S0_#S0_# +Armor NSR: c:@F@add# +------------------------------------------- + +Declaration: process +Location: Line 24, Column 6 +Kind: Function +Clang USR: c:@F@process#I# +Armor NSR: c:@F@process# +------------------------------------------- + +Declaration: process +Location: Line 27, Column 6 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Tprocess#t0.0#v# +Armor NSR: c:@F@process# +------------------------------------------- + +Declaration: process +Location: Line 27, Column 6 +Kind: Function +Clang USR: c:@FT@>1#Tprocess#t0.0#v# +Armor NSR: c:@F@process# +------------------------------------------- + +Declaration: WithFriendTemplates +Location: Line 31, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@WithFriendTemplates +Armor NSR: c:@S@WithFriendTemplates +------------------------------------------- + +Declaration: WithFriendTemplates +Location: Line 31, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@WithFriendTemplates +Armor NSR: c:@S@WithFriendTemplates +------------------------------------------- + +Declaration: transform +Location: Line 34, Column 24 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Ttransform#&1>@ST>1#T@WithFriendTemplates1t0.0#*FS2_(#S2_)#S1_# +Armor NSR: c:@F@transform# +------------------------------------------- + +Declaration: transform +Location: Line 34, Column 24 +Kind: Function +Clang USR: c:@FT@>1#Ttransform#&1>@ST>1#T@WithFriendTemplates1t0.0#*FS2_(#S2_)#S1_# +Armor NSR: c:@F@transform# +------------------------------------------- + +Declaration: transform +Location: Line 38, Column 26 +Kind: Function +Clang USR: c:@F@transform<#I>#&1$@S@WithFriendTemplates>#I#*FI(#I)# +Armor NSR: c:@F@transform# +------------------------------------------- + diff --git a/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/test_function_overloading.py b/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/test_function_overloading.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_function_overloading/test_function_overloading.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/armor_struct_overloading.cpp b/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/armor_struct_overloading.cpp new file mode 100644 index 0000000..4141f72 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/armor_struct_overloading.cpp @@ -0,0 +1,311 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include +#include +#include +#include +#include + +// Forward declarations for template friends +template struct TemplateStruct; +template struct TemplateStructFriend; + +// Overloaded struct with template parameters +template +struct TemplateStruct { + T value; + + // Constructor overloading + TemplateStruct() : value{} {} + explicit TemplateStruct(T val) : value(val) {} + + // Method overloading + void set(T val); + + T get() const; + + // Friend declaration + friend struct TemplateStructFriend; +}; + +// Template specialization for pointer types +template +struct TemplateStruct { + T* value; + bool ownsPointer; + + // Constructor overloading + TemplateStruct() : value(nullptr), ownsPointer(false) {} + explicit TemplateStruct(T* val, bool takeOwnership = false) + : value(val), ownsPointer(takeOwnership) {} + + ~TemplateStruct(); + + // Method overloading + void set(T* val, bool takeOwnership = false); + + T* get() const; + + // Friend declaration + friend struct TemplateStructFriend; +}; + +// Complete specialization for int +template<> +struct TemplateStruct { + int value; + + TemplateStruct() : value(0) {} + explicit TemplateStruct(int val) : value(val) {} + + void set(int val); + + // Overloaded method specific to int specialization + bool isEven() const; + + int get() const; + + // Friend declaration + friend struct TemplateStructFriend; +}; + +// Friend struct template +template +struct TemplateStructFriend { + void inspect(const TemplateStruct& ts); +}; + +// Variadic template struct +template +struct VariadicStruct { + std::tuple data; + + VariadicStruct(Ts... args) : data(args...) {} + + // Overloaded methods with parameter packs + template + auto get() const; + + template + bool contains() const; +}; + +// Struct with tag dispatch overloading +struct IntTag {}; +struct FloatTag {}; +struct StringTag {}; + +struct TagDispatcher { + template + static auto dispatch(T value); + + static void process(int value, IntTag); + + static void process(float value, FloatTag); +}; + +// Struct with std::variant and overloaded pattern +template +struct overloaded : Ts... { + using Ts::operator()...; +}; + +// Struct with virtual method overloading +struct BaseVirtual { + virtual void method(int value); + + virtual void method(double value); + + virtual void method(const std::string& value); + + virtual ~BaseVirtual() = default; +}; + +struct DerivedVirtual : BaseVirtual { + void method(int value) override; + + void method(double value) override; + + // Additional overload not in base + void method(bool value); +}; + +// Storage policies +struct DirectStorage { + using ValueType = int; + using StorageType = int; + + static void store(StorageType& storage, const ValueType& value); + + static ValueType retrieve(const StorageType& storage) { + return storage; + } +}; + +struct PointerStorage { + using ValueType = int; + using StorageType = std::unique_ptr; + + static void store(StorageType& storage, const ValueType& value) { + storage = std::make_unique(value); + } + + static ValueType retrieve(const StorageType& storage) { + return *storage; + } +}; + +// Recursive template struct +template +struct Factorial { + static constexpr unsigned value = N * Factorial::value; +}; + +template<> +struct Factorial<0> { + static constexpr unsigned value = 1; +}; + +// Template struct with non-type template parameters +template +struct FixedArray { + T data[Size]; + + // Constructor overloading + FixedArray(); + + explicit FixedArray(const T& defaultValue); +}; + +// Specialization for bool arrays +template +struct FixedArray { + + FixedArray(); + + explicit FixedArray(bool defaultValue); + + // Overloaded operators + int operator[](size_t index); + bool operator[](size_t index) const; +}; + +// Recursive template struct with specializations +template +struct NestedContainer { + using type = std::vector::type>; +}; + +template +struct NestedContainer { + using type = T; +}; + +// Template struct with explicit instantiation control +template +struct ExplicitControl { + T value; + + explicit ExplicitControl(T val) : value(val) {} + + void display() const; + +}; + +// Template struct with friend function templates +template +struct WithFriendTemplates { + T value; + + WithFriendTemplates(T val) : value(val) {} + +private: + // Friend function template + template + friend WithFriendTemplates transform(const WithFriendTemplates& obj, U (*func)(U)); +}; + +// Template struct with static member specialization +template +struct StaticSpecialization { + static T defaultValue; + + static T getDefault() { + return defaultValue; + } +}; + +// Type traits with overloaded values +template +struct CustomTraits { + static constexpr bool is_custom = false; + static constexpr size_t size = sizeof(T); + using promoted_type = T; +}; + +template<> +struct CustomTraits { + static constexpr bool is_custom = true; + static constexpr size_t size = 1; + using promoted_type = int; // Char promotes to int +}; + +template<> +struct CustomTraits { + static constexpr bool is_custom = true; + static constexpr size_t size = sizeof(float); + using promoted_type = double; // Float promotes to double +}; + +// Struct with overloaded nested types +template +struct NestedTypes { + struct Inner { + T value; + }; + + using InnerRef = Inner&; + using ValueType = T; +}; + +template<> +struct NestedTypes { + struct Inner { + bool value; + size_t count; // Additional field for bool specialization + }; + + using InnerRef = const Inner&; // Different reference type + using ValueType = int; // Different value type +}; + + +struct { int x; } *const*volatile*&& field = nullptr; + +struct {int y;} *** gamma[30]; + +struct SomeClass; +struct { int x; } SomeClass::* class_member_ptr; + +enum { I } *****const**volatile** beta = nullptr; + +struct { + int a; +} zeta; + +struct zeta{ + int a; + int b; +} alpha1; + +typedef struct { + int a; + int b; +} *****const**********alpha6[100]; + +alpha6 ok; + +typedef enum { + a, + b +} *****const**********alpha7[100]; diff --git a/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/expected.txt b/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/expected.txt new file mode 100644 index 0000000..52aac27 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/expected.txt @@ -0,0 +1,1022 @@ +Declaration: TemplateStruct +Location: Line 8, Column 29 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@TemplateStruct +Armor NSR: c:@S@TemplateStruct +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 8, Column 29 +Kind: CXXRecord +Clang USR: c:@ST>1#T@TemplateStruct +Armor NSR: c:@S@TemplateStruct +------------------------------------------- + +Declaration: TemplateStructFriend +Location: Line 9, Column 29 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@TemplateStructFriend +Armor NSR: c:@S@TemplateStructFriend +------------------------------------------- + +Declaration: TemplateStructFriend +Location: Line 9, Column 29 +Kind: CXXRecord +Clang USR: c:@ST>1#T@TemplateStructFriend +Armor NSR: c:@S@TemplateStructFriend +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 13, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@TemplateStruct +Armor NSR: c:@S@TemplateStruct +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 13, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@TemplateStruct +Armor NSR: c:@S@TemplateStruct +------------------------------------------- + +Declaration: value +Location: Line 14, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@TemplateStruct@FI@value +Armor NSR: c:@S@TemplateStruct@FI@value +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 17, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@TemplateStruct@F@TemplateStruct# +Armor NSR: c:@S@TemplateStruct@F@TemplateStruct# +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 18, Column 14 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@TemplateStruct@F@TemplateStruct#t0.0# +Armor NSR: c:@S@TemplateStruct@F@TemplateStruct# +------------------------------------------- + +Declaration: set +Location: Line 21, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@TemplateStruct@F@set#t0.0# +Armor NSR: c:@S@TemplateStruct@F@set# +------------------------------------------- + +Declaration: get +Location: Line 23, Column 7 +Kind: CXXMethod +Clang USR: c:@ST>1#T@TemplateStruct@F@get#1 +Armor NSR: c:@S@TemplateStruct@F@get# +------------------------------------------- + +Declaration: Friend +Location: Line 26, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@TemplateStructFriend(F) +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 31, Column 8 +Kind: ClassTemplatePartialSpecialization +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0 +Armor NSR: c:@S@TemplateStruct +------------------------------------------- + +Declaration: value +Location: Line 32, Column 8 +Kind: Field +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0@FI@value +Armor NSR: c:@S@TemplateStruct@FI@value +------------------------------------------- + +Declaration: ownsPointer +Location: Line 33, Column 10 +Kind: Field +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0@FI@ownsPointer +Armor NSR: c:@S@TemplateStruct@FI@ownsPointer +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 36, Column 5 +Kind: CXXConstructor +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0@F@TemplateStruct# +Armor NSR: c:@S@TemplateStruct@F@TemplateStruct# +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 37, Column 14 +Kind: CXXConstructor +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0@F@TemplateStruct#S0_#b# +Armor NSR: c:@S@TemplateStruct@F@TemplateStruct# +------------------------------------------- + +Declaration: ~TemplateStruct +Location: Line 40, Column 5 +Kind: CXXDestructor +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0@F@~TemplateStruct# +Armor NSR: c:@S@TemplateStruct@F@~TemplateStruct# +------------------------------------------- + +Declaration: set +Location: Line 43, Column 10 +Kind: CXXMethod +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0@F@set#S0_#b# +Armor NSR: c:@S@TemplateStruct@F@set# +------------------------------------------- + +Declaration: get +Location: Line 45, Column 8 +Kind: CXXMethod +Clang USR: c:@SP>1#T@TemplateStruct>#*t0.0@F@get#1 +Armor NSR: c:@S@TemplateStruct@F@get# +------------------------------------------- + +Declaration: Friend +Location: Line 48, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@TemplateStructFriend(F) +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 53, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@TemplateStruct>#I +Armor NSR: c:@S@TemplateStruct +------------------------------------------- + +Declaration: value +Location: Line 54, Column 9 +Kind: Field +Clang USR: c:@S@TemplateStruct>#I@FI@value +Armor NSR: c:@S@TemplateStruct@FI@value +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 56, Column 5 +Kind: CXXConstructor +Clang USR: c:@S@TemplateStruct>#I@F@TemplateStruct# +Armor NSR: c:@S@TemplateStruct@F@TemplateStruct# +------------------------------------------- + +Declaration: TemplateStruct +Location: Line 57, Column 14 +Kind: CXXConstructor +Clang USR: c:@S@TemplateStruct>#I@F@TemplateStruct#I# +Armor NSR: c:@S@TemplateStruct@F@TemplateStruct# +------------------------------------------- + +Declaration: set +Location: Line 59, Column 10 +Kind: CXXMethod +Clang USR: c:@S@TemplateStruct>#I@F@set#I# +Armor NSR: c:@S@TemplateStruct@F@set# +------------------------------------------- + +Declaration: isEven +Location: Line 62, Column 10 +Kind: CXXMethod +Clang USR: c:@S@TemplateStruct>#I@F@isEven#1 +Armor NSR: c:@S@TemplateStruct@F@isEven# +------------------------------------------- + +Declaration: get +Location: Line 64, Column 9 +Kind: CXXMethod +Clang USR: c:@S@TemplateStruct>#I@F@get#1 +Armor NSR: c:@S@TemplateStruct@F@get# +------------------------------------------- + +Declaration: Friend +Location: Line 67, Column 12 +Kind: Friend +Clang USR: c: +Armor NSR: c:@S@TemplateStructFriend(F) +------------------------------------------- + +Declaration: TemplateStructFriend +Location: Line 72, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@TemplateStructFriend +Armor NSR: c:@S@TemplateStructFriend +------------------------------------------- + +Declaration: TemplateStructFriend +Location: Line 72, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@TemplateStructFriend +Armor NSR: c:@S@TemplateStructFriend +------------------------------------------- + +Declaration: inspect +Location: Line 73, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@TemplateStructFriend@F@inspect#&1>@ST>1#T@TemplateStruct1t0.0# +Armor NSR: c:@S@TemplateStructFriend@F@inspect# +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 78, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#pT@VariadicStruct +Armor NSR: c:@S@VariadicStruct +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 78, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#pT@VariadicStruct +Armor NSR: c:@S@VariadicStruct +------------------------------------------- + +Declaration: data +Location: Line 79, Column 23 +Kind: Field +Clang USR: c:@ST>1#pT@VariadicStruct@FI@data +Armor NSR: c:@S@VariadicStruct@FI@data +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 81, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#pT@VariadicStruct@F@VariadicStruct#Pt0.0# +Armor NSR: c:@S@VariadicStruct@F@VariadicStruct# +------------------------------------------- + +Declaration: get +Location: Line 85, Column 10 +Kind: FunctionTemplate +Clang USR: c:@ST>1#pT@VariadicStruct@FT@>1#Nlget# #1 +Armor NSR: c:@S@VariadicStruct@F@get# +------------------------------------------- + +Declaration: get +Location: Line 85, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#pT@VariadicStruct@FT@>1#Nlget# #1 +Armor NSR: c:@S@VariadicStruct@F@get# +------------------------------------------- + +Declaration: contains +Location: Line 88, Column 10 +Kind: FunctionTemplate +Clang USR: c:@ST>1#pT@VariadicStruct@FT@>1#Tcontains#b#1 +Armor NSR: c:@S@VariadicStruct@F@contains# +------------------------------------------- + +Declaration: contains +Location: Line 88, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#pT@VariadicStruct@FT@>1#Tcontains#b#1 +Armor NSR: c:@S@VariadicStruct@F@contains# +------------------------------------------- + +Declaration: dispatch +Location: Line 98, Column 17 +Kind: FunctionTemplate +Clang USR: c:@S@TagDispatcher@FT@>1#Tdispatch#t0.0# #S +Armor NSR: c:@S@TagDispatcher@F@dispatch# +------------------------------------------- + +Declaration: dispatch +Location: Line 98, Column 17 +Kind: CXXMethod +Clang USR: c:@S@TagDispatcher@FT@>1#Tdispatch#t0.0# #S +Armor NSR: c:@S@TagDispatcher@F@dispatch# +------------------------------------------- + +Declaration: process +Location: Line 100, Column 17 +Kind: CXXMethod +Clang USR: c:@S@TagDispatcher@F@process#I#$@S@IntTag#S +Armor NSR: c:@S@TagDispatcher@F@process# +------------------------------------------- + +Declaration: process +Location: Line 102, Column 17 +Kind: CXXMethod +Clang USR: c:@S@TagDispatcher@F@process#f#$@S@FloatTag#S +Armor NSR: c:@S@TagDispatcher@F@process# +------------------------------------------- + +Declaration: overloaded +Location: Line 107, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#pT@overloaded +Armor NSR: c:@S@overloaded +------------------------------------------- + +Declaration: overloaded +Location: Line 107, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#pT@overloaded +Armor NSR: c:@S@overloaded +------------------------------------------- + +Declaration: operator() +Location: Line 108, Column 15 +Kind: UnresolvedUsingValue +Clang USR: c:armor_struct_overloading.cpp@ST>1#pT@overloaded@UUV@Ts::operator() +Armor NSR: c:@S@overloaded@UUV@Ts::operator() +------------------------------------------- + +Declaration: method +Location: Line 113, Column 18 +Kind: CXXMethod +Clang USR: c:@S@BaseVirtual@F@method#I# +Armor NSR: c:@S@BaseVirtual@F@method# +------------------------------------------- + +Declaration: method +Location: Line 115, Column 18 +Kind: CXXMethod +Clang USR: c:@S@BaseVirtual@F@method#d# +Armor NSR: c:@S@BaseVirtual@F@method# +------------------------------------------- + +Declaration: method +Location: Line 117, Column 18 +Kind: CXXMethod +Clang USR: c:@S@BaseVirtual@F@method#&1$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C# +Armor NSR: c:@S@BaseVirtual@F@method# +------------------------------------------- + +Declaration: method +Location: Line 123, Column 10 +Kind: CXXMethod +Clang USR: c:@S@DerivedVirtual@F@method#I# +Armor NSR: c:@S@DerivedVirtual@F@method# +------------------------------------------- + +Declaration: method +Location: Line 125, Column 10 +Kind: CXXMethod +Clang USR: c:@S@DerivedVirtual@F@method#d# +Armor NSR: c:@S@DerivedVirtual@F@method# +------------------------------------------- + +Declaration: method +Location: Line 128, Column 10 +Kind: CXXMethod +Clang USR: c:@S@DerivedVirtual@F@method#b# +Armor NSR: c:@S@DerivedVirtual@F@method# +------------------------------------------- + +Declaration: ValueType +Location: Line 133, Column 11 +Kind: TypeAlias +Clang USR: c:@S@DirectStorage@ValueType +Armor NSR: c:@S@DirectStorage@T@ValueType +------------------------------------------- + +Declaration: StorageType +Location: Line 134, Column 11 +Kind: TypeAlias +Clang USR: c:@S@DirectStorage@StorageType +Armor NSR: c:@S@DirectStorage@T@StorageType +------------------------------------------- + +Declaration: store +Location: Line 136, Column 17 +Kind: CXXMethod +Clang USR: c:@S@DirectStorage@F@store#&I#&1I#S +Armor NSR: c:@S@DirectStorage@F@store# +------------------------------------------- + +Declaration: retrieve +Location: Line 138, Column 22 +Kind: CXXMethod +Clang USR: c:@S@DirectStorage@F@retrieve#&1I#S +Armor NSR: c:@S@DirectStorage@F@retrieve# +------------------------------------------- + +Declaration: ValueType +Location: Line 144, Column 11 +Kind: TypeAlias +Clang USR: c:@S@PointerStorage@ValueType +Armor NSR: c:@S@PointerStorage@T@ValueType +------------------------------------------- + +Declaration: StorageType +Location: Line 145, Column 11 +Kind: TypeAlias +Clang USR: c:@S@PointerStorage@StorageType +Armor NSR: c:@S@PointerStorage@T@StorageType +------------------------------------------- + +Declaration: store +Location: Line 147, Column 17 +Kind: CXXMethod +Clang USR: c:@S@PointerStorage@F@store#&$@N@std@S@unique_ptr>#I#$@N@std@S@default_delete>#I#&1I#S +Armor NSR: c:@S@PointerStorage@F@store# +------------------------------------------- + +Declaration: retrieve +Location: Line 151, Column 22 +Kind: CXXMethod +Clang USR: c:@S@PointerStorage@F@retrieve#&1$@N@std@S@unique_ptr>#I#$@N@std@S@default_delete>#I#S +Armor NSR: c:@S@PointerStorage@F@retrieve# +------------------------------------------- + +Declaration: Factorial +Location: Line 158, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#Ni@Factorial +Armor NSR: c:@S@Factorial +------------------------------------------- + +Declaration: Factorial +Location: Line 158, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#Ni@Factorial +Armor NSR: c:@S@Factorial +------------------------------------------- + +Declaration: value +Location: Line 159, Column 31 +Kind: Var +Clang USR: c:@ST>1#Ni@Factorial@value +Armor NSR: c:@S@Factorial@FI@value +------------------------------------------- + +Declaration: Factorial +Location: Line 163, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@Factorial>#Vi0 +Armor NSR: c:@S@Factorial +------------------------------------------- + +Declaration: value +Location: Line 164, Column 31 +Kind: Var +Clang USR: c:@S@Factorial>#Vi0@value +Armor NSR: c:@S@Factorial@FI@value +------------------------------------------- + +Declaration: FixedArray +Location: Line 169, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#Nl@FixedArray +Armor NSR: c:@S@FixedArray +------------------------------------------- + +Declaration: FixedArray +Location: Line 169, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>2#T#Nl@FixedArray +Armor NSR: c:@S@FixedArray +------------------------------------------- + +Declaration: data +Location: Line 170, Column 7 +Kind: Field +Clang USR: c:@ST>2#T#Nl@FixedArray@FI@data +Armor NSR: c:@S@FixedArray@FI@data +------------------------------------------- + +Declaration: FixedArray +Location: Line 173, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>2#T#Nl@FixedArray@F@FixedArray# +Armor NSR: c:@S@FixedArray@F@FixedArray# +------------------------------------------- + +Declaration: FixedArray +Location: Line 175, Column 14 +Kind: CXXConstructor +Clang USR: c:@ST>2#T#Nl@FixedArray@F@FixedArray#&1t0.0# +Armor NSR: c:@S@FixedArray@F@FixedArray# +------------------------------------------- + +Declaration: FixedArray +Location: Line 180, Column 8 +Kind: ClassTemplatePartialSpecialization +Clang USR: c:@SP>1#Nl@FixedArray>#b# +Armor NSR: c:@S@FixedArray +------------------------------------------- + +Declaration: FixedArray +Location: Line 182, Column 5 +Kind: CXXConstructor +Clang USR: c:@SP>1#Nl@FixedArray>#b#@F@FixedArray# +Armor NSR: c:@S@FixedArray@F@FixedArray# +------------------------------------------- + +Declaration: FixedArray +Location: Line 184, Column 14 +Kind: CXXConstructor +Clang USR: c:@SP>1#Nl@FixedArray>#b#@F@FixedArray#b# +Armor NSR: c:@S@FixedArray@F@FixedArray# +------------------------------------------- + +Declaration: operator[] +Location: Line 187, Column 9 +Kind: CXXMethod +Clang USR: c:@SP>1#Nl@FixedArray>#b#@F@operator[]#l# +Armor NSR: c:@S@FixedArray@F@operator[]# +------------------------------------------- + +Declaration: operator[] +Location: Line 188, Column 10 +Kind: CXXMethod +Clang USR: c:@SP>1#Nl@FixedArray>#b#@F@operator[]#l#1 +Armor NSR: c:@S@FixedArray@F@operator[]# +------------------------------------------- + +Declaration: NestedContainer +Location: Line 193, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#Nl@NestedContainer +Armor NSR: c:@S@NestedContainer +------------------------------------------- + +Declaration: NestedContainer +Location: Line 193, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>2#T#Nl@NestedContainer +Armor NSR: c:@S@NestedContainer +------------------------------------------- + +Declaration: type +Location: Line 194, Column 11 +Kind: TypeAlias +Clang USR: c:@ST>2#T#Nl@NestedContainer@type +Armor NSR: c:@S@NestedContainer@T@type +------------------------------------------- + +Declaration: NestedContainer +Location: Line 198, Column 8 +Kind: ClassTemplatePartialSpecialization +Clang USR: c:@SP>1#T@NestedContainer>#t0.0#Vl0 +Armor NSR: c:@S@NestedContainer +------------------------------------------- + +Declaration: type +Location: Line 199, Column 11 +Kind: TypeAlias +Clang USR: c:@SP>1#T@NestedContainer>#t0.0#Vl0@type +Armor NSR: c:@S@NestedContainer@T@type +------------------------------------------- + +Declaration: ExplicitControl +Location: Line 204, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@ExplicitControl +Armor NSR: c:@S@ExplicitControl +------------------------------------------- + +Declaration: ExplicitControl +Location: Line 204, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@ExplicitControl +Armor NSR: c:@S@ExplicitControl +------------------------------------------- + +Declaration: value +Location: Line 205, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@ExplicitControl@FI@value +Armor NSR: c:@S@ExplicitControl@FI@value +------------------------------------------- + +Declaration: ExplicitControl +Location: Line 207, Column 14 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@ExplicitControl@F@ExplicitControl#t0.0# +Armor NSR: c:@S@ExplicitControl@F@ExplicitControl# +------------------------------------------- + +Declaration: display +Location: Line 209, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@ExplicitControl@F@display#1 +Armor NSR: c:@S@ExplicitControl@F@display# +------------------------------------------- + +Declaration: WithFriendTemplates +Location: Line 215, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@WithFriendTemplates +Armor NSR: c:@S@WithFriendTemplates +------------------------------------------- + +Declaration: WithFriendTemplates +Location: Line 215, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@WithFriendTemplates +Armor NSR: c:@S@WithFriendTemplates +------------------------------------------- + +Declaration: value +Location: Line 216, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@WithFriendTemplates@FI@value +Armor NSR: c:@S@WithFriendTemplates@FI@value +------------------------------------------- + +Declaration: WithFriendTemplates +Location: Line 218, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@WithFriendTemplates@F@WithFriendTemplates#t0.0# +Armor NSR: c:@S@WithFriendTemplates@F@WithFriendTemplates# +------------------------------------------- + +Declaration: Friend +Location: Line 223, Column 35 +Kind: Friend +Clang USR: c: +Armor NSR: c:@F@transform#(F) +------------------------------------------- + +Declaration: transform +Location: Line 223, Column 35 +Kind: FunctionTemplate +Clang USR: c:@FT@>1#Ttransform#&1>@ST>1#T@WithFriendTemplates1t1.0#*FS2_(#S2_)#S1_# +Armor NSR: c:@F@transform# +------------------------------------------- + +Declaration: transform +Location: Line 223, Column 35 +Kind: Function +Clang USR: c:@FT@>1#Ttransform#&1>@ST>1#T@WithFriendTemplates1t1.0#*FS2_(#S2_)#S1_# +Armor NSR: c:@F@transform# +------------------------------------------- + +Declaration: StaticSpecialization +Location: Line 228, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@StaticSpecialization +Armor NSR: c:@S@StaticSpecialization +------------------------------------------- + +Declaration: StaticSpecialization +Location: Line 228, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@StaticSpecialization +Armor NSR: c:@S@StaticSpecialization +------------------------------------------- + +Declaration: defaultValue +Location: Line 229, Column 14 +Kind: Var +Clang USR: c:@ST>1#T@StaticSpecialization@defaultValue +Armor NSR: c:@S@StaticSpecialization@FI@defaultValue +------------------------------------------- + +Declaration: getDefault +Location: Line 231, Column 14 +Kind: CXXMethod +Clang USR: c:@ST>1#T@StaticSpecialization@F@getDefault#S +Armor NSR: c:@S@StaticSpecialization@F@getDefault# +------------------------------------------- + +Declaration: CustomTraits +Location: Line 238, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@CustomTraits +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: CustomTraits +Location: Line 238, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@CustomTraits +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: is_custom +Location: Line 239, Column 27 +Kind: Var +Clang USR: c:@ST>1#T@CustomTraits@is_custom +Armor NSR: c:@S@CustomTraits@FI@is_custom +------------------------------------------- + +Declaration: size +Location: Line 240, Column 29 +Kind: Var +Clang USR: c:@ST>1#T@CustomTraits@size +Armor NSR: c:@S@CustomTraits@FI@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 241, Column 11 +Kind: TypeAlias +Clang USR: c:@ST>1#T@CustomTraits@promoted_type +Armor NSR: c:@S@CustomTraits@T@promoted_type +------------------------------------------- + +Declaration: CustomTraits +Location: Line 245, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@CustomTraits>#C +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: is_custom +Location: Line 246, Column 27 +Kind: Var +Clang USR: c:@S@CustomTraits>#C@is_custom +Armor NSR: c:@S@CustomTraits@FI@is_custom +------------------------------------------- + +Declaration: size +Location: Line 247, Column 29 +Kind: Var +Clang USR: c:@S@CustomTraits>#C@size +Armor NSR: c:@S@CustomTraits@FI@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 248, Column 11 +Kind: TypeAlias +Clang USR: c:@S@CustomTraits>#C@promoted_type +Armor NSR: c:@S@CustomTraits@T@promoted_type +------------------------------------------- + +Declaration: CustomTraits +Location: Line 252, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@CustomTraits>#f +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: is_custom +Location: Line 253, Column 27 +Kind: Var +Clang USR: c:@S@CustomTraits>#f@is_custom +Armor NSR: c:@S@CustomTraits@FI@is_custom +------------------------------------------- + +Declaration: size +Location: Line 254, Column 29 +Kind: Var +Clang USR: c:@S@CustomTraits>#f@size +Armor NSR: c:@S@CustomTraits@FI@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 255, Column 11 +Kind: TypeAlias +Clang USR: c:@S@CustomTraits>#f@promoted_type +Armor NSR: c:@S@CustomTraits@T@promoted_type +------------------------------------------- + +Declaration: NestedTypes +Location: Line 260, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@NestedTypes +Armor NSR: c:@S@NestedTypes +------------------------------------------- + +Declaration: NestedTypes +Location: Line 260, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@NestedTypes +Armor NSR: c:@S@NestedTypes +------------------------------------------- + +Declaration: Inner +Location: Line 261, Column 12 +Kind: CXXRecord +Clang USR: c:@ST>1#T@NestedTypes@S@Inner +Armor NSR: c:@S@NestedTypes@S@Inner +------------------------------------------- + +Declaration: value +Location: Line 262, Column 11 +Kind: Field +Clang USR: c:@ST>1#T@NestedTypes@S@Inner@FI@value +Armor NSR: c:@S@NestedTypes@S@Inner@FI@value +------------------------------------------- + +Declaration: InnerRef +Location: Line 265, Column 11 +Kind: TypeAlias +Clang USR: c:@ST>1#T@NestedTypes@InnerRef +Armor NSR: c:@S@NestedTypes@T@InnerRef +------------------------------------------- + +Declaration: ValueType +Location: Line 266, Column 11 +Kind: TypeAlias +Clang USR: c:@ST>1#T@NestedTypes@ValueType +Armor NSR: c:@S@NestedTypes@T@ValueType +------------------------------------------- + +Declaration: NestedTypes +Location: Line 270, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@NestedTypes>#b +Armor NSR: c:@S@NestedTypes +------------------------------------------- + +Declaration: Inner +Location: Line 271, Column 12 +Kind: CXXRecord +Clang USR: c:@S@NestedTypes>#b@S@Inner +Armor NSR: c:@S@NestedTypes@S@Inner +------------------------------------------- + +Declaration: value +Location: Line 272, Column 14 +Kind: Field +Clang USR: c:@S@NestedTypes>#b@S@Inner@FI@value +Armor NSR: c:@S@NestedTypes@S@Inner@FI@value +------------------------------------------- + +Declaration: count +Location: Line 273, Column 16 +Kind: Field +Clang USR: c:@S@NestedTypes>#b@S@Inner@FI@count +Armor NSR: c:@S@NestedTypes@S@Inner@FI@count +------------------------------------------- + +Declaration: InnerRef +Location: Line 276, Column 11 +Kind: TypeAlias +Clang USR: c:@S@NestedTypes>#b@InnerRef +Armor NSR: c:@S@NestedTypes@T@InnerRef +------------------------------------------- + +Declaration: ValueType +Location: Line 277, Column 11 +Kind: TypeAlias +Clang USR: c:@S@NestedTypes>#b@ValueType +Armor NSR: c:@S@NestedTypes@T@ValueType +------------------------------------------- + +Declaration: +Location: Line 281, Column 1 +Kind: CXXRecord +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6267 +Armor NSR: c:@S@#vf#field +------------------------------------------- + +Declaration: x +Location: Line 281, Column 14 +Kind: Field +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6267@FI@x +Armor NSR: c:@S@#vf#field@FI@x +------------------------------------------- + +Declaration: field +Location: Line 281, Column 38 +Kind: Var +Clang USR: c:armor_struct_overloading.cpp@field +Armor NSR: c:@field +------------------------------------------- + +Declaration: +Location: Line 283, Column 1 +Kind: CXXRecord +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6322 +Armor NSR: c:@S@#vf#gamma +------------------------------------------- + +Declaration: y +Location: Line 283, Column 13 +Kind: Field +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6322@FI@y +Armor NSR: c:@S@#vf#gamma@FI@y +------------------------------------------- + +Declaration: gamma +Location: Line 283, Column 21 +Kind: Var +Clang USR: c:armor_struct_overloading.cpp@gamma +Armor NSR: c:@gamma +------------------------------------------- + +Declaration: +Location: Line 286, Column 1 +Kind: CXXRecord +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6372 +Armor NSR: c:@S@#vf#class_member_ptr +------------------------------------------- + +Declaration: x +Location: Line 286, Column 14 +Kind: Field +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6372@FI@x +Armor NSR: c:@S@#vf#class_member_ptr@FI@x +------------------------------------------- + +Declaration: class_member_ptr +Location: Line 286, Column 32 +Kind: Var +Clang USR: c:armor_struct_overloading.cpp@class_member_ptr +Armor NSR: c:@class_member_ptr +------------------------------------------- + +Declaration: +Location: Line 288, Column 1 +Kind: Enum +Clang USR: c:@E@armor_struct_overloading.cpp@6422 +Armor NSR: c:@E@#vf#beta +------------------------------------------- + +Declaration: I +Location: Line 288, Column 8 +Kind: EnumConstant +Clang USR: c:@E@armor_struct_overloading.cpp@6422@I +Armor NSR: c:@E@#vf#beta@I +------------------------------------------- + +Declaration: beta +Location: Line 288, Column 35 +Kind: Var +Clang USR: c:armor_struct_overloading.cpp@beta +Armor NSR: c:@beta +------------------------------------------- + +Declaration: +Location: Line 290, Column 1 +Kind: CXXRecord +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6473 +Armor NSR: c:@S@#vf#zeta +------------------------------------------- + +Declaration: a +Location: Line 291, Column 7 +Kind: Field +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6473@FI@a +Armor NSR: c:@S@#vf#zeta@FI@a +------------------------------------------- + +Declaration: zeta +Location: Line 292, Column 3 +Kind: Var +Clang USR: c:armor_struct_overloading.cpp@zeta +Armor NSR: c:@zeta +------------------------------------------- + +Declaration: +Location: Line 299, Column 9 +Kind: CXXRecord +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6550 +Armor NSR: c:@SA@alpha6 +------------------------------------------- + +Declaration: a +Location: Line 300, Column 7 +Kind: Field +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6550@FI@a +Armor NSR: c:@SA@alpha6@FI@a +------------------------------------------- + +Declaration: b +Location: Line 301, Column 7 +Kind: Field +Clang USR: c:armor_struct_overloading.cpp@S@armor_struct_overloading.cpp@6550@FI@b +Armor NSR: c:@SA@alpha6@FI@b +------------------------------------------- + +Declaration: alpha6 +Location: Line 302, Column 23 +Kind: Typedef +Clang USR: c:armor_struct_overloading.cpp@T@alpha6 +Armor NSR: c:@T@alpha6 +------------------------------------------- + +Declaration: ok +Location: Line 304, Column 8 +Kind: Var +Clang USR: c:armor_struct_overloading.cpp@ok +Armor NSR: c:@ok +------------------------------------------- + +Declaration: +Location: Line 306, Column 9 +Kind: Enum +Clang USR: c:@E@armor_struct_overloading.cpp@6633 +Armor NSR: c:@EA@alpha7 +------------------------------------------- + +Declaration: a +Location: Line 307, Column 3 +Kind: EnumConstant +Clang USR: c:@E@armor_struct_overloading.cpp@6633@a +Armor NSR: c:@EA@alpha7@a +------------------------------------------- + +Declaration: b +Location: Line 308, Column 3 +Kind: EnumConstant +Clang USR: c:@E@armor_struct_overloading.cpp@6633@b +Armor NSR: c:@EA@alpha7@b +------------------------------------------- + +Declaration: alpha7 +Location: Line 309, Column 23 +Kind: Typedef +Clang USR: c:armor_struct_overloading.cpp@T@alpha7 +Armor NSR: c:@T@alpha7 +------------------------------------------- + diff --git a/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/test_struct_overloading.py b/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/test_struct_overloading.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_struct_overloading/test_struct_overloading.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/armor_type_alias/armor_type_alias.cpp b/src/tests/common/unit/nsr_generator/armor/armor_type_alias/armor_type_alias.cpp new file mode 100644 index 0000000..7bc7888 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_type_alias/armor_type_alias.cpp @@ -0,0 +1,272 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +// ============================================================================= +// 1. PRIMITIVE TYPE ALIASES +// ============================================================================= + +using Byte = unsigned char; +using Int8 = signed char; +using Int16 = short; +using Int32 = int; +using Int64 = long long; +using UInt8 = unsigned char; +using UInt16 = unsigned short; +using UInt32 = unsigned int; +using UInt64 = unsigned long long; +using Float32 = float; +using Float64 = double; +using Char = char; +using Bool = bool; + +// ============================================================================= +// 2. CHAINED PRIMITIVE ALIASES (alias of alias of alias) +// ============================================================================= + +using Size = UInt64; // chain depth 1 +using Index = Size; // chain depth 2 +using Offset = Index; // chain depth 3 +using Handle = UInt32; // chain depth 1 +using SubHandle = Handle; // chain depth 2 +using Token = SubHandle; // chain depth 3 + +// ============================================================================= +// 3. POINTER & REFERENCE ALIASES +// ============================================================================= + +using BytePtr = Byte *; +using ConstBytePtr = const Byte *; +using Int32Ptr = Int32 *; +using Int32Ref = Int32 &; // reference alias +using VoidPtr = void *; +using ConstVoidPtr = const void *; + +// Chained pointer aliases +using RawBuffer = BytePtr; // alias of pointer alias +using ConstBuffer = ConstBytePtr; // alias of const-pointer alias +using BufferHandle = RawBuffer; // alias of alias of pointer alias + +// ============================================================================= +// 4. STD CONTAINER ALIASES (single-level) +// ============================================================================= + +using IntVec = std::vector; +using FloatVec = std::vector; +using DoubleVec = std::vector; +using StringVec = std::vector; +using ByteVec = std::vector; +using IntIntMap = std::map; +using StringIntMap = std::map; +using IntStringMap = std::map; +using StringStrMap = std::map; +using IntIntUMap = std::unordered_map; +using StrIntUMap = std::unordered_map; +using IntPair = std::pair; +using StrIntPair = std::pair; +using IntTriple = std::tuple; +using MixedTuple = std::tuple; +using IntArr4 = std::array; +using FloatArr3 = std::array; + +// ============================================================================= +// 5. CHAINED CONTAINER ALIASES (alias of alias) +// ============================================================================= + +using Row = IntVec; // chain depth 1 +using Matrix = std::vector; // container of aliased type +using Cube = std::vector; // container of container alias + +using Record = StringIntMap; // chain depth 1 +using RecordSet = std::vector; // container of aliased map +using RecordIndex = std::map; // map of aliased vector + +using Pair = IntPair; // chain depth 1 +using PairVec = std::vector; // container of aliased pair +using PairMap = std::map; // map with aliased value + +// ============================================================================= +// 6. NESTED CONTAINER ALIASES (containers of containers) +// ============================================================================= + +using VecOfVecInt = std::vector>; +using VecOfVecFloat = std::vector>; +using MapOfVecInt = std::map>; +using MapOfMapInt = std::map>; +using VecOfMapStrInt = std::vector>; +using UMapOfVecStr = std::unordered_map>; +using VecOfPair = std::vector>; +using MapOfTuple = std::map>; + +// Chained nested container aliases +using Grid = VecOfVecInt; // alias of nested container +using GridRow = IntVec; // alias of inner container +using SparseGrid = MapOfVecInt; // alias of map-of-vec +using SparseGridIndex = std::map;// map of aliased map-of-vec + +// ============================================================================= +// 7. SMART POINTER ALIASES +// ============================================================================= + +using IntShared = std::shared_ptr; +using IntUnique = std::unique_ptr; +using IntWeak = std::weak_ptr; +using VoidShared = std::shared_ptr; + +// Chained smart pointer aliases +using SharedInt = IntShared; // chain depth 1 +using SharedIntVec = std::vector; // container of aliased smart ptr +using SharedIntMap = std::map; // map of aliased smart ptr + +// ============================================================================= +// 8. FUNCTION / CALLABLE ALIASES +// ============================================================================= + +using VoidFn = std::function; +using IntFn = std::function; +using IntIntFn = std::function; +using IntIntIntFn = std::function; +using BoolIntFn = std::function; +using VoidIntFn = std::function; +using VoidStrFn = std::function; +using StrStrFn = std::function; + +// Function aliases using aliased types +using SizeFn = std::function; // uses primitive alias +using IndexMapFn = std::function; // uses chained alias +using RowTransformFn = std::function; // uses container alias +using MatrixFn = std::function; // uses chained container alias + +// Chained function aliases +using Callback = VoidFn; // chain depth 1 +using EventHandler = Callback; // chain depth 2 +using SignalHandler = EventHandler; // chain depth 3 + +using Predicate = BoolIntFn; // chain depth 1 +using Filter = Predicate; // chain depth 2 + +using Transformer = IntIntFn; // chain depth 1 +using Mapper = Transformer; // chain depth 2 +using Reducer = Mapper; // chain depth 3 + +// ============================================================================= +// 9. TEMPLATE TYPE ALIAS (alias templates) +// ============================================================================= + +template +using Vec = std::vector; + +template +using Ptr = std::shared_ptr; + +template +using UniquePtr = std::unique_ptr; + +template +using Dict = std::map; + +template +using HashMap = std::unordered_map; + +template +using Opt = std::pair; // lightweight optional-like + +template +using Grid2D = std::vector>; + +template +using Grid3D = std::vector>; // chained template alias + +template +using MultiDict = std::map>; + +template +using Fn = std::function; // generic callable alias + +template +using PtrVec = Vec>; // chained template aliases + +template +using PtrDict = Dict>; // chained template aliases + +// ============================================================================= +// 10. COMBINATIONS: MIXING PRIMITIVE, CONTAINER, SMART-PTR, FUNCTION ALIASES +// ============================================================================= + +// Primitive alias inside containers +using IndexVec = Vec; // template alias + chained primitive +using HandleMap = Dict; // template alias + chained primitives +using TokenSet = std::vector; // container of depth-3 chained alias + +// Smart pointer of aliased container +using SharedRow = Ptr; // smart ptr of container alias +using SharedMatrix = Ptr; // smart ptr of chained container alias +using UniqueGrid = UniquePtr; // unique ptr of aliased nested container + +// Container of smart pointers of aliased types +using SharedRowVec = Vec; // vec of (shared ptr of alias) +using SharedMatrixVec = Vec; // vec of (shared ptr of chained alias) + +// Function aliases using template aliases +using IndexTransform = Fn; // template fn alias + chained primitive +using RowFn = Fn; // template fn alias + container alias +using MatrixBuilder = Fn; // template fn alias + chained container +using GridReducer = Fn; // template fn alias + nested alias + +// Map of function aliases +using CallbackMap = Dict; // map of chained fn alias +using HandlerRegistry = HashMap; // hashmap of depth-2 fn alias + +// Tuple combining aliased types +using RecordTuple = std::tuple; // tuple of mixed aliases +using FullRecord = std::tuple; // tuple of depth-3 aliases + +// ============================================================================= +// 11. DEEP CHAINING (5+ levels) +// ============================================================================= + +// Primitive chain +using L1 = int; +using L2 = L1; +using L3 = L2; +using L4 = L3; +using L5 = L4; +using L6 = L5; + +// Container chain +using C1 = std::vector; +using C2 = C1; +using C3 = C2; +using C4 = C3; +using C5 = C4; + +// Function chain +using F1 = std::function; +using F2 = F1; +using F3 = F2; +using F4 = F3; +using F5 = F4; + +// Smart pointer chain +using S1 = std::shared_ptr; +using S2 = S1; +using S3 = S2; +using S4 = S3; +using S5 = S4; + +// Cross-kind chaining: primitive -> container -> smart ptr -> function +using XBase = UInt32; // primitive alias +using XVec = std::vector; // container of primitive alias +using XShared = std::shared_ptr; // smart ptr of container alias +using XFn = std::function; // function using smart ptr + primitive alias +using XCallback = XFn; // alias of cross-kind chain +using XHandler = XCallback; // alias of alias of cross-kind chain diff --git a/src/tests/common/unit/nsr_generator/armor/armor_type_alias/expected.txt b/src/tests/common/unit/nsr_generator/armor/armor_type_alias/expected.txt new file mode 100644 index 0000000..bd18761 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_type_alias/expected.txt @@ -0,0 +1,1036 @@ +Declaration: Byte +Location: Line 16, Column 7 +Kind: TypeAlias +Clang USR: c:@Byte +Armor NSR: c:@T@Byte +------------------------------------------- + +Declaration: Int8 +Location: Line 17, Column 7 +Kind: TypeAlias +Clang USR: c:@Int8 +Armor NSR: c:@T@Int8 +------------------------------------------- + +Declaration: Int16 +Location: Line 18, Column 7 +Kind: TypeAlias +Clang USR: c:@Int16 +Armor NSR: c:@T@Int16 +------------------------------------------- + +Declaration: Int32 +Location: Line 19, Column 7 +Kind: TypeAlias +Clang USR: c:@Int32 +Armor NSR: c:@T@Int32 +------------------------------------------- + +Declaration: Int64 +Location: Line 20, Column 7 +Kind: TypeAlias +Clang USR: c:@Int64 +Armor NSR: c:@T@Int64 +------------------------------------------- + +Declaration: UInt8 +Location: Line 21, Column 7 +Kind: TypeAlias +Clang USR: c:@UInt8 +Armor NSR: c:@T@UInt8 +------------------------------------------- + +Declaration: UInt16 +Location: Line 22, Column 7 +Kind: TypeAlias +Clang USR: c:@UInt16 +Armor NSR: c:@T@UInt16 +------------------------------------------- + +Declaration: UInt32 +Location: Line 23, Column 7 +Kind: TypeAlias +Clang USR: c:@UInt32 +Armor NSR: c:@T@UInt32 +------------------------------------------- + +Declaration: UInt64 +Location: Line 24, Column 7 +Kind: TypeAlias +Clang USR: c:@UInt64 +Armor NSR: c:@T@UInt64 +------------------------------------------- + +Declaration: Float32 +Location: Line 25, Column 7 +Kind: TypeAlias +Clang USR: c:@Float32 +Armor NSR: c:@T@Float32 +------------------------------------------- + +Declaration: Float64 +Location: Line 26, Column 7 +Kind: TypeAlias +Clang USR: c:@Float64 +Armor NSR: c:@T@Float64 +------------------------------------------- + +Declaration: Char +Location: Line 27, Column 7 +Kind: TypeAlias +Clang USR: c:@Char +Armor NSR: c:@T@Char +------------------------------------------- + +Declaration: Bool +Location: Line 28, Column 7 +Kind: TypeAlias +Clang USR: c:@Bool +Armor NSR: c:@T@Bool +------------------------------------------- + +Declaration: Size +Location: Line 34, Column 7 +Kind: TypeAlias +Clang USR: c:@Size +Armor NSR: c:@T@Size +------------------------------------------- + +Declaration: Index +Location: Line 35, Column 7 +Kind: TypeAlias +Clang USR: c:@Index +Armor NSR: c:@T@Index +------------------------------------------- + +Declaration: Offset +Location: Line 36, Column 7 +Kind: TypeAlias +Clang USR: c:@Offset +Armor NSR: c:@T@Offset +------------------------------------------- + +Declaration: Handle +Location: Line 37, Column 7 +Kind: TypeAlias +Clang USR: c:@Handle +Armor NSR: c:@T@Handle +------------------------------------------- + +Declaration: SubHandle +Location: Line 38, Column 7 +Kind: TypeAlias +Clang USR: c:@SubHandle +Armor NSR: c:@T@SubHandle +------------------------------------------- + +Declaration: Token +Location: Line 39, Column 7 +Kind: TypeAlias +Clang USR: c:@Token +Armor NSR: c:@T@Token +------------------------------------------- + +Declaration: BytePtr +Location: Line 45, Column 7 +Kind: TypeAlias +Clang USR: c:@BytePtr +Armor NSR: c:@T@BytePtr +------------------------------------------- + +Declaration: ConstBytePtr +Location: Line 46, Column 7 +Kind: TypeAlias +Clang USR: c:@ConstBytePtr +Armor NSR: c:@T@ConstBytePtr +------------------------------------------- + +Declaration: Int32Ptr +Location: Line 47, Column 7 +Kind: TypeAlias +Clang USR: c:@Int32Ptr +Armor NSR: c:@T@Int32Ptr +------------------------------------------- + +Declaration: Int32Ref +Location: Line 48, Column 7 +Kind: TypeAlias +Clang USR: c:@Int32Ref +Armor NSR: c:@T@Int32Ref +------------------------------------------- + +Declaration: VoidPtr +Location: Line 49, Column 7 +Kind: TypeAlias +Clang USR: c:@VoidPtr +Armor NSR: c:@T@VoidPtr +------------------------------------------- + +Declaration: ConstVoidPtr +Location: Line 50, Column 7 +Kind: TypeAlias +Clang USR: c:@ConstVoidPtr +Armor NSR: c:@T@ConstVoidPtr +------------------------------------------- + +Declaration: RawBuffer +Location: Line 53, Column 7 +Kind: TypeAlias +Clang USR: c:@RawBuffer +Armor NSR: c:@T@RawBuffer +------------------------------------------- + +Declaration: ConstBuffer +Location: Line 54, Column 7 +Kind: TypeAlias +Clang USR: c:@ConstBuffer +Armor NSR: c:@T@ConstBuffer +------------------------------------------- + +Declaration: BufferHandle +Location: Line 55, Column 7 +Kind: TypeAlias +Clang USR: c:@BufferHandle +Armor NSR: c:@T@BufferHandle +------------------------------------------- + +Declaration: IntVec +Location: Line 61, Column 7 +Kind: TypeAlias +Clang USR: c:@IntVec +Armor NSR: c:@T@IntVec +------------------------------------------- + +Declaration: FloatVec +Location: Line 62, Column 7 +Kind: TypeAlias +Clang USR: c:@FloatVec +Armor NSR: c:@T@FloatVec +------------------------------------------- + +Declaration: DoubleVec +Location: Line 63, Column 7 +Kind: TypeAlias +Clang USR: c:@DoubleVec +Armor NSR: c:@T@DoubleVec +------------------------------------------- + +Declaration: StringVec +Location: Line 64, Column 7 +Kind: TypeAlias +Clang USR: c:@StringVec +Armor NSR: c:@T@StringVec +------------------------------------------- + +Declaration: ByteVec +Location: Line 65, Column 7 +Kind: TypeAlias +Clang USR: c:@ByteVec +Armor NSR: c:@T@ByteVec +------------------------------------------- + +Declaration: IntIntMap +Location: Line 66, Column 7 +Kind: TypeAlias +Clang USR: c:@IntIntMap +Armor NSR: c:@T@IntIntMap +------------------------------------------- + +Declaration: StringIntMap +Location: Line 67, Column 7 +Kind: TypeAlias +Clang USR: c:@StringIntMap +Armor NSR: c:@T@StringIntMap +------------------------------------------- + +Declaration: IntStringMap +Location: Line 68, Column 7 +Kind: TypeAlias +Clang USR: c:@IntStringMap +Armor NSR: c:@T@IntStringMap +------------------------------------------- + +Declaration: StringStrMap +Location: Line 69, Column 7 +Kind: TypeAlias +Clang USR: c:@StringStrMap +Armor NSR: c:@T@StringStrMap +------------------------------------------- + +Declaration: IntIntUMap +Location: Line 70, Column 7 +Kind: TypeAlias +Clang USR: c:@IntIntUMap +Armor NSR: c:@T@IntIntUMap +------------------------------------------- + +Declaration: StrIntUMap +Location: Line 71, Column 7 +Kind: TypeAlias +Clang USR: c:@StrIntUMap +Armor NSR: c:@T@StrIntUMap +------------------------------------------- + +Declaration: IntPair +Location: Line 72, Column 7 +Kind: TypeAlias +Clang USR: c:@IntPair +Armor NSR: c:@T@IntPair +------------------------------------------- + +Declaration: StrIntPair +Location: Line 73, Column 7 +Kind: TypeAlias +Clang USR: c:@StrIntPair +Armor NSR: c:@T@StrIntPair +------------------------------------------- + +Declaration: IntTriple +Location: Line 74, Column 7 +Kind: TypeAlias +Clang USR: c:@IntTriple +Armor NSR: c:@T@IntTriple +------------------------------------------- + +Declaration: MixedTuple +Location: Line 75, Column 7 +Kind: TypeAlias +Clang USR: c:@MixedTuple +Armor NSR: c:@T@MixedTuple +------------------------------------------- + +Declaration: IntArr4 +Location: Line 76, Column 7 +Kind: TypeAlias +Clang USR: c:@IntArr4 +Armor NSR: c:@T@IntArr4 +------------------------------------------- + +Declaration: FloatArr3 +Location: Line 77, Column 7 +Kind: TypeAlias +Clang USR: c:@FloatArr3 +Armor NSR: c:@T@FloatArr3 +------------------------------------------- + +Declaration: Row +Location: Line 83, Column 7 +Kind: TypeAlias +Clang USR: c:@Row +Armor NSR: c:@T@Row +------------------------------------------- + +Declaration: Matrix +Location: Line 84, Column 7 +Kind: TypeAlias +Clang USR: c:@Matrix +Armor NSR: c:@T@Matrix +------------------------------------------- + +Declaration: Cube +Location: Line 85, Column 7 +Kind: TypeAlias +Clang USR: c:@Cube +Armor NSR: c:@T@Cube +------------------------------------------- + +Declaration: Record +Location: Line 87, Column 7 +Kind: TypeAlias +Clang USR: c:@Record +Armor NSR: c:@T@Record +------------------------------------------- + +Declaration: RecordSet +Location: Line 88, Column 7 +Kind: TypeAlias +Clang USR: c:@RecordSet +Armor NSR: c:@T@RecordSet +------------------------------------------- + +Declaration: RecordIndex +Location: Line 89, Column 7 +Kind: TypeAlias +Clang USR: c:@RecordIndex +Armor NSR: c:@T@RecordIndex +------------------------------------------- + +Declaration: Pair +Location: Line 91, Column 7 +Kind: TypeAlias +Clang USR: c:@Pair +Armor NSR: c:@T@Pair +------------------------------------------- + +Declaration: PairVec +Location: Line 92, Column 7 +Kind: TypeAlias +Clang USR: c:@PairVec +Armor NSR: c:@T@PairVec +------------------------------------------- + +Declaration: PairMap +Location: Line 93, Column 7 +Kind: TypeAlias +Clang USR: c:@PairMap +Armor NSR: c:@T@PairMap +------------------------------------------- + +Declaration: VecOfVecInt +Location: Line 99, Column 7 +Kind: TypeAlias +Clang USR: c:@VecOfVecInt +Armor NSR: c:@T@VecOfVecInt +------------------------------------------- + +Declaration: VecOfVecFloat +Location: Line 100, Column 7 +Kind: TypeAlias +Clang USR: c:@VecOfVecFloat +Armor NSR: c:@T@VecOfVecFloat +------------------------------------------- + +Declaration: MapOfVecInt +Location: Line 101, Column 7 +Kind: TypeAlias +Clang USR: c:@MapOfVecInt +Armor NSR: c:@T@MapOfVecInt +------------------------------------------- + +Declaration: MapOfMapInt +Location: Line 102, Column 7 +Kind: TypeAlias +Clang USR: c:@MapOfMapInt +Armor NSR: c:@T@MapOfMapInt +------------------------------------------- + +Declaration: VecOfMapStrInt +Location: Line 103, Column 7 +Kind: TypeAlias +Clang USR: c:@VecOfMapStrInt +Armor NSR: c:@T@VecOfMapStrInt +------------------------------------------- + +Declaration: UMapOfVecStr +Location: Line 104, Column 7 +Kind: TypeAlias +Clang USR: c:@UMapOfVecStr +Armor NSR: c:@T@UMapOfVecStr +------------------------------------------- + +Declaration: VecOfPair +Location: Line 105, Column 7 +Kind: TypeAlias +Clang USR: c:@VecOfPair +Armor NSR: c:@T@VecOfPair +------------------------------------------- + +Declaration: MapOfTuple +Location: Line 106, Column 7 +Kind: TypeAlias +Clang USR: c:@MapOfTuple +Armor NSR: c:@T@MapOfTuple +------------------------------------------- + +Declaration: Grid +Location: Line 109, Column 7 +Kind: TypeAlias +Clang USR: c:@Grid +Armor NSR: c:@T@Grid +------------------------------------------- + +Declaration: GridRow +Location: Line 110, Column 7 +Kind: TypeAlias +Clang USR: c:@GridRow +Armor NSR: c:@T@GridRow +------------------------------------------- + +Declaration: SparseGrid +Location: Line 111, Column 7 +Kind: TypeAlias +Clang USR: c:@SparseGrid +Armor NSR: c:@T@SparseGrid +------------------------------------------- + +Declaration: SparseGridIndex +Location: Line 112, Column 7 +Kind: TypeAlias +Clang USR: c:@SparseGridIndex +Armor NSR: c:@T@SparseGridIndex +------------------------------------------- + +Declaration: IntShared +Location: Line 118, Column 7 +Kind: TypeAlias +Clang USR: c:@IntShared +Armor NSR: c:@T@IntShared +------------------------------------------- + +Declaration: IntUnique +Location: Line 119, Column 7 +Kind: TypeAlias +Clang USR: c:@IntUnique +Armor NSR: c:@T@IntUnique +------------------------------------------- + +Declaration: IntWeak +Location: Line 120, Column 7 +Kind: TypeAlias +Clang USR: c:@IntWeak +Armor NSR: c:@T@IntWeak +------------------------------------------- + +Declaration: VoidShared +Location: Line 121, Column 7 +Kind: TypeAlias +Clang USR: c:@VoidShared +Armor NSR: c:@T@VoidShared +------------------------------------------- + +Declaration: SharedInt +Location: Line 124, Column 7 +Kind: TypeAlias +Clang USR: c:@SharedInt +Armor NSR: c:@T@SharedInt +------------------------------------------- + +Declaration: SharedIntVec +Location: Line 125, Column 7 +Kind: TypeAlias +Clang USR: c:@SharedIntVec +Armor NSR: c:@T@SharedIntVec +------------------------------------------- + +Declaration: SharedIntMap +Location: Line 126, Column 7 +Kind: TypeAlias +Clang USR: c:@SharedIntMap +Armor NSR: c:@T@SharedIntMap +------------------------------------------- + +Declaration: VoidFn +Location: Line 132, Column 7 +Kind: TypeAlias +Clang USR: c:@VoidFn +Armor NSR: c:@T@VoidFn +------------------------------------------- + +Declaration: IntFn +Location: Line 133, Column 7 +Kind: TypeAlias +Clang USR: c:@IntFn +Armor NSR: c:@T@IntFn +------------------------------------------- + +Declaration: IntIntFn +Location: Line 134, Column 7 +Kind: TypeAlias +Clang USR: c:@IntIntFn +Armor NSR: c:@T@IntIntFn +------------------------------------------- + +Declaration: IntIntIntFn +Location: Line 135, Column 7 +Kind: TypeAlias +Clang USR: c:@IntIntIntFn +Armor NSR: c:@T@IntIntIntFn +------------------------------------------- + +Declaration: BoolIntFn +Location: Line 136, Column 7 +Kind: TypeAlias +Clang USR: c:@BoolIntFn +Armor NSR: c:@T@BoolIntFn +------------------------------------------- + +Declaration: VoidIntFn +Location: Line 137, Column 7 +Kind: TypeAlias +Clang USR: c:@VoidIntFn +Armor NSR: c:@T@VoidIntFn +------------------------------------------- + +Declaration: VoidStrFn +Location: Line 138, Column 7 +Kind: TypeAlias +Clang USR: c:@VoidStrFn +Armor NSR: c:@T@VoidStrFn +------------------------------------------- + +Declaration: StrStrFn +Location: Line 139, Column 7 +Kind: TypeAlias +Clang USR: c:@StrStrFn +Armor NSR: c:@T@StrStrFn +------------------------------------------- + +Declaration: SizeFn +Location: Line 142, Column 7 +Kind: TypeAlias +Clang USR: c:@SizeFn +Armor NSR: c:@T@SizeFn +------------------------------------------- + +Declaration: IndexMapFn +Location: Line 143, Column 7 +Kind: TypeAlias +Clang USR: c:@IndexMapFn +Armor NSR: c:@T@IndexMapFn +------------------------------------------- + +Declaration: RowTransformFn +Location: Line 144, Column 7 +Kind: TypeAlias +Clang USR: c:@RowTransformFn +Armor NSR: c:@T@RowTransformFn +------------------------------------------- + +Declaration: MatrixFn +Location: Line 145, Column 7 +Kind: TypeAlias +Clang USR: c:@MatrixFn +Armor NSR: c:@T@MatrixFn +------------------------------------------- + +Declaration: Callback +Location: Line 148, Column 7 +Kind: TypeAlias +Clang USR: c:@Callback +Armor NSR: c:@T@Callback +------------------------------------------- + +Declaration: EventHandler +Location: Line 149, Column 7 +Kind: TypeAlias +Clang USR: c:@EventHandler +Armor NSR: c:@T@EventHandler +------------------------------------------- + +Declaration: SignalHandler +Location: Line 150, Column 7 +Kind: TypeAlias +Clang USR: c:@SignalHandler +Armor NSR: c:@T@SignalHandler +------------------------------------------- + +Declaration: Predicate +Location: Line 152, Column 7 +Kind: TypeAlias +Clang USR: c:@Predicate +Armor NSR: c:@T@Predicate +------------------------------------------- + +Declaration: Filter +Location: Line 153, Column 7 +Kind: TypeAlias +Clang USR: c:@Filter +Armor NSR: c:@T@Filter +------------------------------------------- + +Declaration: Transformer +Location: Line 155, Column 7 +Kind: TypeAlias +Clang USR: c:@Transformer +Armor NSR: c:@T@Transformer +------------------------------------------- + +Declaration: Mapper +Location: Line 156, Column 7 +Kind: TypeAlias +Clang USR: c:@Mapper +Armor NSR: c:@T@Mapper +------------------------------------------- + +Declaration: Reducer +Location: Line 157, Column 7 +Kind: TypeAlias +Clang USR: c:@Reducer +Armor NSR: c:@T@Reducer +------------------------------------------- + +Declaration: Vec +Location: Line 164, Column 7 +Kind: TypeAlias +Clang USR: c:@Vec +Armor NSR: c:@T@Vec +------------------------------------------- + +Declaration: Ptr +Location: Line 167, Column 7 +Kind: TypeAlias +Clang USR: c:@Ptr +Armor NSR: c:@T@Ptr +------------------------------------------- + +Declaration: UniquePtr +Location: Line 170, Column 7 +Kind: TypeAlias +Clang USR: c:@UniquePtr +Armor NSR: c:@T@UniquePtr +------------------------------------------- + +Declaration: Dict +Location: Line 173, Column 7 +Kind: TypeAlias +Clang USR: c:@Dict +Armor NSR: c:@T@Dict +------------------------------------------- + +Declaration: HashMap +Location: Line 176, Column 7 +Kind: TypeAlias +Clang USR: c:@HashMap +Armor NSR: c:@T@HashMap +------------------------------------------- + +Declaration: Opt +Location: Line 179, Column 7 +Kind: TypeAlias +Clang USR: c:@Opt +Armor NSR: c:@T@Opt +------------------------------------------- + +Declaration: Grid2D +Location: Line 182, Column 7 +Kind: TypeAlias +Clang USR: c:@Grid2D +Armor NSR: c:@T@Grid2D +------------------------------------------- + +Declaration: Grid3D +Location: Line 185, Column 7 +Kind: TypeAlias +Clang USR: c:@Grid3D +Armor NSR: c:@T@Grid3D +------------------------------------------- + +Declaration: MultiDict +Location: Line 188, Column 7 +Kind: TypeAlias +Clang USR: c:@MultiDict +Armor NSR: c:@T@MultiDict +------------------------------------------- + +Declaration: Fn +Location: Line 191, Column 7 +Kind: TypeAlias +Clang USR: c:@Fn +Armor NSR: c:@T@Fn +------------------------------------------- + +Declaration: PtrVec +Location: Line 194, Column 7 +Kind: TypeAlias +Clang USR: c:@PtrVec +Armor NSR: c:@T@PtrVec +------------------------------------------- + +Declaration: PtrDict +Location: Line 197, Column 7 +Kind: TypeAlias +Clang USR: c:@PtrDict +Armor NSR: c:@T@PtrDict +------------------------------------------- + +Declaration: IndexVec +Location: Line 204, Column 7 +Kind: TypeAlias +Clang USR: c:@IndexVec +Armor NSR: c:@T@IndexVec +------------------------------------------- + +Declaration: HandleMap +Location: Line 205, Column 7 +Kind: TypeAlias +Clang USR: c:@HandleMap +Armor NSR: c:@T@HandleMap +------------------------------------------- + +Declaration: TokenSet +Location: Line 206, Column 7 +Kind: TypeAlias +Clang USR: c:@TokenSet +Armor NSR: c:@T@TokenSet +------------------------------------------- + +Declaration: SharedRow +Location: Line 209, Column 7 +Kind: TypeAlias +Clang USR: c:@SharedRow +Armor NSR: c:@T@SharedRow +------------------------------------------- + +Declaration: SharedMatrix +Location: Line 210, Column 7 +Kind: TypeAlias +Clang USR: c:@SharedMatrix +Armor NSR: c:@T@SharedMatrix +------------------------------------------- + +Declaration: UniqueGrid +Location: Line 211, Column 7 +Kind: TypeAlias +Clang USR: c:@UniqueGrid +Armor NSR: c:@T@UniqueGrid +------------------------------------------- + +Declaration: SharedRowVec +Location: Line 214, Column 7 +Kind: TypeAlias +Clang USR: c:@SharedRowVec +Armor NSR: c:@T@SharedRowVec +------------------------------------------- + +Declaration: SharedMatrixVec +Location: Line 215, Column 7 +Kind: TypeAlias +Clang USR: c:@SharedMatrixVec +Armor NSR: c:@T@SharedMatrixVec +------------------------------------------- + +Declaration: IndexTransform +Location: Line 218, Column 7 +Kind: TypeAlias +Clang USR: c:@IndexTransform +Armor NSR: c:@T@IndexTransform +------------------------------------------- + +Declaration: RowFn +Location: Line 219, Column 7 +Kind: TypeAlias +Clang USR: c:@RowFn +Armor NSR: c:@T@RowFn +------------------------------------------- + +Declaration: MatrixBuilder +Location: Line 220, Column 7 +Kind: TypeAlias +Clang USR: c:@MatrixBuilder +Armor NSR: c:@T@MatrixBuilder +------------------------------------------- + +Declaration: GridReducer +Location: Line 221, Column 7 +Kind: TypeAlias +Clang USR: c:@GridReducer +Armor NSR: c:@T@GridReducer +------------------------------------------- + +Declaration: CallbackMap +Location: Line 224, Column 7 +Kind: TypeAlias +Clang USR: c:@CallbackMap +Armor NSR: c:@T@CallbackMap +------------------------------------------- + +Declaration: HandlerRegistry +Location: Line 225, Column 7 +Kind: TypeAlias +Clang USR: c:@HandlerRegistry +Armor NSR: c:@T@HandlerRegistry +------------------------------------------- + +Declaration: RecordTuple +Location: Line 228, Column 7 +Kind: TypeAlias +Clang USR: c:@RecordTuple +Armor NSR: c:@T@RecordTuple +------------------------------------------- + +Declaration: FullRecord +Location: Line 229, Column 7 +Kind: TypeAlias +Clang USR: c:@FullRecord +Armor NSR: c:@T@FullRecord +------------------------------------------- + +Declaration: L1 +Location: Line 236, Column 7 +Kind: TypeAlias +Clang USR: c:@L1 +Armor NSR: c:@T@L1 +------------------------------------------- + +Declaration: L2 +Location: Line 237, Column 7 +Kind: TypeAlias +Clang USR: c:@L2 +Armor NSR: c:@T@L2 +------------------------------------------- + +Declaration: L3 +Location: Line 238, Column 7 +Kind: TypeAlias +Clang USR: c:@L3 +Armor NSR: c:@T@L3 +------------------------------------------- + +Declaration: L4 +Location: Line 239, Column 7 +Kind: TypeAlias +Clang USR: c:@L4 +Armor NSR: c:@T@L4 +------------------------------------------- + +Declaration: L5 +Location: Line 240, Column 7 +Kind: TypeAlias +Clang USR: c:@L5 +Armor NSR: c:@T@L5 +------------------------------------------- + +Declaration: L6 +Location: Line 241, Column 7 +Kind: TypeAlias +Clang USR: c:@L6 +Armor NSR: c:@T@L6 +------------------------------------------- + +Declaration: C1 +Location: Line 244, Column 7 +Kind: TypeAlias +Clang USR: c:@C1 +Armor NSR: c:@T@C1 +------------------------------------------- + +Declaration: C2 +Location: Line 245, Column 7 +Kind: TypeAlias +Clang USR: c:@C2 +Armor NSR: c:@T@C2 +------------------------------------------- + +Declaration: C3 +Location: Line 246, Column 7 +Kind: TypeAlias +Clang USR: c:@C3 +Armor NSR: c:@T@C3 +------------------------------------------- + +Declaration: C4 +Location: Line 247, Column 7 +Kind: TypeAlias +Clang USR: c:@C4 +Armor NSR: c:@T@C4 +------------------------------------------- + +Declaration: C5 +Location: Line 248, Column 7 +Kind: TypeAlias +Clang USR: c:@C5 +Armor NSR: c:@T@C5 +------------------------------------------- + +Declaration: F1 +Location: Line 251, Column 7 +Kind: TypeAlias +Clang USR: c:@F1 +Armor NSR: c:@T@F1 +------------------------------------------- + +Declaration: F2 +Location: Line 252, Column 7 +Kind: TypeAlias +Clang USR: c:@F2 +Armor NSR: c:@T@F2 +------------------------------------------- + +Declaration: F3 +Location: Line 253, Column 7 +Kind: TypeAlias +Clang USR: c:@F3 +Armor NSR: c:@T@F3 +------------------------------------------- + +Declaration: F4 +Location: Line 254, Column 7 +Kind: TypeAlias +Clang USR: c:@F4 +Armor NSR: c:@T@F4 +------------------------------------------- + +Declaration: F5 +Location: Line 255, Column 7 +Kind: TypeAlias +Clang USR: c:@F5 +Armor NSR: c:@T@F5 +------------------------------------------- + +Declaration: S1 +Location: Line 258, Column 7 +Kind: TypeAlias +Clang USR: c:@S1 +Armor NSR: c:@T@S1 +------------------------------------------- + +Declaration: S2 +Location: Line 259, Column 7 +Kind: TypeAlias +Clang USR: c:@S2 +Armor NSR: c:@T@S2 +------------------------------------------- + +Declaration: S3 +Location: Line 260, Column 7 +Kind: TypeAlias +Clang USR: c:@S3 +Armor NSR: c:@T@S3 +------------------------------------------- + +Declaration: S4 +Location: Line 261, Column 7 +Kind: TypeAlias +Clang USR: c:@S4 +Armor NSR: c:@T@S4 +------------------------------------------- + +Declaration: S5 +Location: Line 262, Column 7 +Kind: TypeAlias +Clang USR: c:@S5 +Armor NSR: c:@T@S5 +------------------------------------------- + +Declaration: XBase +Location: Line 265, Column 7 +Kind: TypeAlias +Clang USR: c:@XBase +Armor NSR: c:@T@XBase +------------------------------------------- + +Declaration: XVec +Location: Line 266, Column 7 +Kind: TypeAlias +Clang USR: c:@XVec +Armor NSR: c:@T@XVec +------------------------------------------- + +Declaration: XShared +Location: Line 267, Column 7 +Kind: TypeAlias +Clang USR: c:@XShared +Armor NSR: c:@T@XShared +------------------------------------------- + +Declaration: XFn +Location: Line 268, Column 7 +Kind: TypeAlias +Clang USR: c:@XFn +Armor NSR: c:@T@XFn +------------------------------------------- + +Declaration: XCallback +Location: Line 269, Column 7 +Kind: TypeAlias +Clang USR: c:@XCallback +Armor NSR: c:@T@XCallback +------------------------------------------- + +Declaration: XHandler +Location: Line 270, Column 7 +Kind: TypeAlias +Clang USR: c:@XHandler +Armor NSR: c:@T@XHandler +------------------------------------------- + diff --git a/src/tests/common/unit/nsr_generator/armor/armor_type_alias/test_nsr_type_alias.py b/src/tests/common/unit/nsr_generator/armor/armor_type_alias/test_nsr_type_alias.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_type_alias/test_nsr_type_alias.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/armor_union_overloading.cpp b/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/armor_union_overloading.cpp new file mode 100644 index 0000000..33a46f2 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/armor_union_overloading.cpp @@ -0,0 +1,87 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include +#include + +// Union with overloaded methods +union OverloadedUnion { + int intValue; + float floatValue; + double doubleValue; + + // Unions can have constructors in C++11 and later + OverloadedUnion() : intValue(0) {} + + // Overloaded methods to set values + void setValue(int val) { + intValue = val; + } + + void setValue(float val) { + floatValue = val; + } + + void setValue(double val) { + doubleValue = val; + } + + // Overloaded methods to get values + int getInt() const { + return intValue; + } + + float getFloat() const { + return floatValue; + } + + double getDouble() const { + return doubleValue; + } +}; + +// Template overloaded union with specializations +template +union TemplateUnion { + T value; + int intRep; + char buffer[sizeof(T)]; + + TemplateUnion() : intRep(0) {} + explicit TemplateUnion(T val) : value(val) {} + + T getValue() const { return value; } + void setValue(T val) { value = val; } + + int getIntRep() const { return intRep; } +}; + +// Specialization for pointer types +template +union TemplateUnion { + T* value; + uintptr_t ptrValue; + void* voidPtr; + + TemplateUnion() : value(nullptr) {} + explicit TemplateUnion(T* val) : value(val) {} + + T* getValue() const { return value; } + void setValue(T* val) { value = val; } + + uintptr_t getAddress() const { return ptrValue; } +}; + +// Specialization for bool +template<> +union TemplateUnion { + bool value; + char charRep; + + TemplateUnion() : value(false) {} + explicit TemplateUnion(bool val) : value(val) {} + + bool getValue() const { return value; } + void setValue(bool val) { value = val; } + + char getCharRep() const { return charRep; } +}; diff --git a/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/expected.txt b/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/expected.txt new file mode 100644 index 0000000..67daa06 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/expected.txt @@ -0,0 +1,231 @@ +Declaration: setValue +Location: Line 14, Column 10 +Kind: CXXMethod +Clang USR: c:@U@OverloadedUnion@F@setValue#I# +Armor NSR: c:@U@OverloadedUnion@F@setValue# +------------------------------------------- + +Declaration: setValue +Location: Line 18, Column 10 +Kind: CXXMethod +Clang USR: c:@U@OverloadedUnion@F@setValue#f# +Armor NSR: c:@U@OverloadedUnion@F@setValue# +------------------------------------------- + +Declaration: setValue +Location: Line 22, Column 10 +Kind: CXXMethod +Clang USR: c:@U@OverloadedUnion@F@setValue#d# +Armor NSR: c:@U@OverloadedUnion@F@setValue# +------------------------------------------- + +Declaration: getInt +Location: Line 27, Column 9 +Kind: CXXMethod +Clang USR: c:@U@OverloadedUnion@F@getInt#1 +Armor NSR: c:@U@OverloadedUnion@F@getInt# +------------------------------------------- + +Declaration: getFloat +Location: Line 31, Column 11 +Kind: CXXMethod +Clang USR: c:@U@OverloadedUnion@F@getFloat#1 +Armor NSR: c:@U@OverloadedUnion@F@getFloat# +------------------------------------------- + +Declaration: getDouble +Location: Line 35, Column 12 +Kind: CXXMethod +Clang USR: c:@U@OverloadedUnion@F@getDouble#1 +Armor NSR: c:@U@OverloadedUnion@F@getDouble# +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 42, Column 7 +Kind: ClassTemplate +Clang USR: c:@UT>1#T@TemplateUnion +Armor NSR: c:@U@TemplateUnion +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 42, Column 7 +Kind: CXXRecord +Clang USR: c:@UT>1#T@TemplateUnion +Armor NSR: c:@U@TemplateUnion +------------------------------------------- + +Declaration: value +Location: Line 43, Column 7 +Kind: Field +Clang USR: c:@UT>1#T@TemplateUnion@FI@value +Armor NSR: c:@U@TemplateUnion@FI@value +------------------------------------------- + +Declaration: intRep +Location: Line 44, Column 9 +Kind: Field +Clang USR: c:@UT>1#T@TemplateUnion@FI@intRep +Armor NSR: c:@U@TemplateUnion@FI@intRep +------------------------------------------- + +Declaration: buffer +Location: Line 45, Column 10 +Kind: Field +Clang USR: c:@UT>1#T@TemplateUnion@FI@buffer +Armor NSR: c:@U@TemplateUnion@FI@buffer +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 47, Column 5 +Kind: CXXConstructor +Clang USR: c:@UT>1#T@TemplateUnion@F@TemplateUnion# +Armor NSR: c:@U@TemplateUnion@F@TemplateUnion# +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 48, Column 14 +Kind: CXXConstructor +Clang USR: c:@UT>1#T@TemplateUnion@F@TemplateUnion#t0.0# +Armor NSR: c:@U@TemplateUnion@F@TemplateUnion# +------------------------------------------- + +Declaration: getValue +Location: Line 50, Column 7 +Kind: CXXMethod +Clang USR: c:@UT>1#T@TemplateUnion@F@getValue#1 +Armor NSR: c:@U@TemplateUnion@F@getValue# +------------------------------------------- + +Declaration: setValue +Location: Line 51, Column 10 +Kind: CXXMethod +Clang USR: c:@UT>1#T@TemplateUnion@F@setValue#t0.0# +Armor NSR: c:@U@TemplateUnion@F@setValue# +------------------------------------------- + +Declaration: getIntRep +Location: Line 53, Column 9 +Kind: CXXMethod +Clang USR: c:@UT>1#T@TemplateUnion@F@getIntRep#1 +Armor NSR: c:@U@TemplateUnion@F@getIntRep# +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 58, Column 7 +Kind: ClassTemplatePartialSpecialization +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0 +Armor NSR: c:@U@TemplateUnion +------------------------------------------- + +Declaration: value +Location: Line 59, Column 8 +Kind: Field +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@FI@value +Armor NSR: c:@U@TemplateUnion@FI@value +------------------------------------------- + +Declaration: ptrValue +Location: Line 60, Column 15 +Kind: Field +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@FI@ptrValue +Armor NSR: c:@U@TemplateUnion@FI@ptrValue +------------------------------------------- + +Declaration: voidPtr +Location: Line 61, Column 11 +Kind: Field +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@FI@voidPtr +Armor NSR: c:@U@TemplateUnion@FI@voidPtr +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 63, Column 5 +Kind: CXXConstructor +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@F@TemplateUnion# +Armor NSR: c:@U@TemplateUnion@F@TemplateUnion# +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 64, Column 14 +Kind: CXXConstructor +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@F@TemplateUnion#S0_# +Armor NSR: c:@U@TemplateUnion@F@TemplateUnion# +------------------------------------------- + +Declaration: getValue +Location: Line 66, Column 8 +Kind: CXXMethod +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@F@getValue#1 +Armor NSR: c:@U@TemplateUnion@F@getValue# +------------------------------------------- + +Declaration: setValue +Location: Line 67, Column 10 +Kind: CXXMethod +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@F@setValue#S0_# +Armor NSR: c:@U@TemplateUnion@F@setValue# +------------------------------------------- + +Declaration: getAddress +Location: Line 69, Column 15 +Kind: CXXMethod +Clang USR: c:@UP>1#T@TemplateUnion>#*t0.0@F@getAddress#1 +Armor NSR: c:@U@TemplateUnion@F@getAddress# +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 74, Column 7 +Kind: ClassTemplateSpecialization +Clang USR: c:@U@TemplateUnion>#b +Armor NSR: c:@U@TemplateUnion +------------------------------------------- + +Declaration: value +Location: Line 75, Column 10 +Kind: Field +Clang USR: c:@U@TemplateUnion>#b@FI@value +Armor NSR: c:@U@TemplateUnion@FI@value +------------------------------------------- + +Declaration: charRep +Location: Line 76, Column 10 +Kind: Field +Clang USR: c:@U@TemplateUnion>#b@FI@charRep +Armor NSR: c:@U@TemplateUnion@FI@charRep +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 78, Column 5 +Kind: CXXConstructor +Clang USR: c:@U@TemplateUnion>#b@F@TemplateUnion# +Armor NSR: c:@U@TemplateUnion@F@TemplateUnion# +------------------------------------------- + +Declaration: TemplateUnion +Location: Line 79, Column 14 +Kind: CXXConstructor +Clang USR: c:@U@TemplateUnion>#b@F@TemplateUnion#b# +Armor NSR: c:@U@TemplateUnion@F@TemplateUnion# +------------------------------------------- + +Declaration: getValue +Location: Line 81, Column 10 +Kind: CXXMethod +Clang USR: c:@U@TemplateUnion>#b@F@getValue#1 +Armor NSR: c:@U@TemplateUnion@F@getValue# +------------------------------------------- + +Declaration: setValue +Location: Line 82, Column 10 +Kind: CXXMethod +Clang USR: c:@U@TemplateUnion>#b@F@setValue#b# +Armor NSR: c:@U@TemplateUnion@F@setValue# +------------------------------------------- + +Declaration: getCharRep +Location: Line 84, Column 10 +Kind: CXXMethod +Clang USR: c:@U@TemplateUnion>#b@F@getCharRep#1 +Armor NSR: c:@U@TemplateUnion@F@getCharRep# +------------------------------------------- + diff --git a/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/test_union_overloading.py b/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/test_union_overloading.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_union_overloading/test_union_overloading.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/armor_variable_overloading.cpp b/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/armor_variable_overloading.cpp new file mode 100644 index 0000000..72fcb21 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/armor_variable_overloading.cpp @@ -0,0 +1,103 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include +#include + +// Variable templates (C++14) with overloading +template +constexpr static T pi = T(3.1415926535897932385); + +template<> +constexpr static float pi = 3.14159f; + +template<> +constexpr static int pi = 3; + +// Overloaded variable templates with different types +template +constexpr static bool is_small = sizeof(T) <= 4; + +template +constexpr static const char* type_name = "unknown"; + +template<> +constexpr static const char* type_name = "int"; + +template<> +constexpr static const char* type_name = "double"; + +template<> +constexpr static const char* type_name = "string"; + +// Type traits with overloaded values +template +struct CustomTraits { + static constexpr bool is_custom = false; + static constexpr size_t size = sizeof(T); + using promoted_type = T; +}; + +template<> +struct CustomTraits { + static constexpr bool is_custom = true; + static constexpr size_t size = 1; + using promoted_type = int; // Char promotes to int +}; + +template<> +struct CustomTraits { + static constexpr bool is_custom = true; + static constexpr size_t size = sizeof(float); + using promoted_type = double; // Float promotes to double +}; + +// Template struct with static member specialization +template +struct StaticSpecialization { + static T defaultValue; + + static T getDefault() { + return defaultValue; + } +}; + +// Overloaded type aliases and typedefs +template +struct NestedTypes { + struct Inner { + T value; + }; + + using InnerRef = Inner&; + using ValueType = T; +}; + +template<> +struct NestedTypes { + struct Inner { + bool value; + size_t count; // Additional field for bool specialization + }; + + using InnerRef = const Inner&; // Different reference type + using ValueType = int; // Different value type +}; + +typedef struct DALSYSPropertyVar DALSYSPropertyVar; + +struct DALSYSPropertyVar +{ + int dwType; + int dwLen; + union + { + int *pbVal; + char *pszVal; + int dwVal; + int *pdwVal; + const void *pStruct; + int qwVal; /* ADDED: 64-bit value */ + float fVal; /* ADDED: Float value */ + }Val; + int reserved[2]; /* ADDED: Reserved array */ +}; diff --git a/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/expected.txt b/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/expected.txt new file mode 100644 index 0000000..5f3fa86 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/expected.txt @@ -0,0 +1,322 @@ +Declaration: pi +Location: Line 6, Column 20 +Kind: Var +Clang USR: c:armor_variable_overloading.cpp@VT>1#T@pi +Armor NSR: c:@pi +------------------------------------------- + +Declaration: pi +Location: Line 9, Column 24 +Kind: VarTemplateSpecialization +Clang USR: c:armor_variable_overloading.cpp@pi>#f +Armor NSR: c:@pi +------------------------------------------- + +Declaration: pi +Location: Line 12, Column 22 +Kind: VarTemplateSpecialization +Clang USR: c:armor_variable_overloading.cpp@pi>#I +Armor NSR: c:@pi +------------------------------------------- + +Declaration: is_small +Location: Line 16, Column 23 +Kind: Var +Clang USR: c:armor_variable_overloading.cpp@VT>1#T@is_small +Armor NSR: c:@is_small +------------------------------------------- + +Declaration: type_name +Location: Line 19, Column 30 +Kind: Var +Clang USR: c:armor_variable_overloading.cpp@VT>1#T@type_name +Armor NSR: c:@type_name +------------------------------------------- + +Declaration: type_name +Location: Line 22, Column 30 +Kind: VarTemplateSpecialization +Clang USR: c:armor_variable_overloading.cpp@type_name>#I +Armor NSR: c:@type_name +------------------------------------------- + +Declaration: type_name +Location: Line 25, Column 30 +Kind: VarTemplateSpecialization +Clang USR: c:armor_variable_overloading.cpp@type_name>#d +Armor NSR: c:@type_name +------------------------------------------- + +Declaration: type_name +Location: Line 28, Column 30 +Kind: VarTemplateSpecialization +Clang USR: c:armor_variable_overloading.cpp@type_name>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C +Armor NSR: c:@type_name +------------------------------------------- + +Declaration: CustomTraits +Location: Line 32, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@CustomTraits +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: CustomTraits +Location: Line 32, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@CustomTraits +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: is_custom +Location: Line 33, Column 27 +Kind: Var +Clang USR: c:@ST>1#T@CustomTraits@is_custom +Armor NSR: c:@S@CustomTraits@FI@is_custom +------------------------------------------- + +Declaration: size +Location: Line 34, Column 29 +Kind: Var +Clang USR: c:@ST>1#T@CustomTraits@size +Armor NSR: c:@S@CustomTraits@FI@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 35, Column 11 +Kind: TypeAlias +Clang USR: c:@ST>1#T@CustomTraits@promoted_type +Armor NSR: c:@S@CustomTraits@T@promoted_type +------------------------------------------- + +Declaration: CustomTraits +Location: Line 39, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@CustomTraits>#C +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: is_custom +Location: Line 40, Column 27 +Kind: Var +Clang USR: c:@S@CustomTraits>#C@is_custom +Armor NSR: c:@S@CustomTraits@FI@is_custom +------------------------------------------- + +Declaration: size +Location: Line 41, Column 29 +Kind: Var +Clang USR: c:@S@CustomTraits>#C@size +Armor NSR: c:@S@CustomTraits@FI@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 42, Column 11 +Kind: TypeAlias +Clang USR: c:@S@CustomTraits>#C@promoted_type +Armor NSR: c:@S@CustomTraits@T@promoted_type +------------------------------------------- + +Declaration: CustomTraits +Location: Line 46, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@CustomTraits>#f +Armor NSR: c:@S@CustomTraits +------------------------------------------- + +Declaration: is_custom +Location: Line 47, Column 27 +Kind: Var +Clang USR: c:@S@CustomTraits>#f@is_custom +Armor NSR: c:@S@CustomTraits@FI@is_custom +------------------------------------------- + +Declaration: size +Location: Line 48, Column 29 +Kind: Var +Clang USR: c:@S@CustomTraits>#f@size +Armor NSR: c:@S@CustomTraits@FI@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 49, Column 11 +Kind: TypeAlias +Clang USR: c:@S@CustomTraits>#f@promoted_type +Armor NSR: c:@S@CustomTraits@T@promoted_type +------------------------------------------- + +Declaration: StaticSpecialization +Location: Line 54, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@StaticSpecialization +Armor NSR: c:@S@StaticSpecialization +------------------------------------------- + +Declaration: StaticSpecialization +Location: Line 54, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@StaticSpecialization +Armor NSR: c:@S@StaticSpecialization +------------------------------------------- + +Declaration: defaultValue +Location: Line 55, Column 14 +Kind: Var +Clang USR: c:@ST>1#T@StaticSpecialization@defaultValue +Armor NSR: c:@S@StaticSpecialization@FI@defaultValue +------------------------------------------- + +Declaration: getDefault +Location: Line 57, Column 14 +Kind: CXXMethod +Clang USR: c:@ST>1#T@StaticSpecialization@F@getDefault#S +Armor NSR: c:@S@StaticSpecialization@F@getDefault# +------------------------------------------- + +Declaration: NestedTypes +Location: Line 64, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@NestedTypes +Armor NSR: c:@S@NestedTypes +------------------------------------------- + +Declaration: NestedTypes +Location: Line 64, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#T@NestedTypes +Armor NSR: c:@S@NestedTypes +------------------------------------------- + +Declaration: Inner +Location: Line 65, Column 12 +Kind: CXXRecord +Clang USR: c:@ST>1#T@NestedTypes@S@Inner +Armor NSR: c:@S@NestedTypes@S@Inner +------------------------------------------- + +Declaration: value +Location: Line 66, Column 11 +Kind: Field +Clang USR: c:@ST>1#T@NestedTypes@S@Inner@FI@value +Armor NSR: c:@S@NestedTypes@S@Inner@FI@value +------------------------------------------- + +Declaration: InnerRef +Location: Line 69, Column 11 +Kind: TypeAlias +Clang USR: c:@ST>1#T@NestedTypes@InnerRef +Armor NSR: c:@S@NestedTypes@T@InnerRef +------------------------------------------- + +Declaration: ValueType +Location: Line 70, Column 11 +Kind: TypeAlias +Clang USR: c:@ST>1#T@NestedTypes@ValueType +Armor NSR: c:@S@NestedTypes@T@ValueType +------------------------------------------- + +Declaration: NestedTypes +Location: Line 74, Column 8 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@NestedTypes>#b +Armor NSR: c:@S@NestedTypes +------------------------------------------- + +Declaration: Inner +Location: Line 75, Column 12 +Kind: CXXRecord +Clang USR: c:@S@NestedTypes>#b@S@Inner +Armor NSR: c:@S@NestedTypes@S@Inner +------------------------------------------- + +Declaration: value +Location: Line 76, Column 14 +Kind: Field +Clang USR: c:@S@NestedTypes>#b@S@Inner@FI@value +Armor NSR: c:@S@NestedTypes@S@Inner@FI@value +------------------------------------------- + +Declaration: count +Location: Line 77, Column 16 +Kind: Field +Clang USR: c:@S@NestedTypes>#b@S@Inner@FI@count +Armor NSR: c:@S@NestedTypes@S@Inner@FI@count +------------------------------------------- + +Declaration: InnerRef +Location: Line 80, Column 11 +Kind: TypeAlias +Clang USR: c:@S@NestedTypes>#b@InnerRef +Armor NSR: c:@S@NestedTypes@T@InnerRef +------------------------------------------- + +Declaration: ValueType +Location: Line 81, Column 11 +Kind: TypeAlias +Clang USR: c:@S@NestedTypes>#b@ValueType +Armor NSR: c:@S@NestedTypes@T@ValueType +------------------------------------------- + +Declaration: DALSYSPropertyVar +Location: Line 84, Column 34 +Kind: Typedef +Clang USR: c:armor_variable_overloading.cpp@T@DALSYSPropertyVar +Armor NSR: c:@T@DALSYSPropertyVar +------------------------------------------- + +Declaration: +Location: Line 90, Column 3 +Kind: CXXRecord +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035 +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val +------------------------------------------- + +Declaration: pbVal +Location: Line 92, Column 10 +Kind: Field +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035@FI@pbVal +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val@FI@pbVal +------------------------------------------- + +Declaration: pszVal +Location: Line 93, Column 11 +Kind: Field +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035@FI@pszVal +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val@FI@pszVal +------------------------------------------- + +Declaration: dwVal +Location: Line 94, Column 9 +Kind: Field +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035@FI@dwVal +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val@FI@dwVal +------------------------------------------- + +Declaration: pdwVal +Location: Line 95, Column 10 +Kind: Field +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035@FI@pdwVal +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val@FI@pdwVal +------------------------------------------- + +Declaration: pStruct +Location: Line 96, Column 17 +Kind: Field +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035@FI@pStruct +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val@FI@pStruct +------------------------------------------- + +Declaration: qwVal +Location: Line 97, Column 9 +Kind: Field +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035@FI@qwVal +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val@FI@qwVal +------------------------------------------- + +Declaration: fVal +Location: Line 98, Column 11 +Kind: Field +Clang USR: c:@S@DALSYSPropertyVar@U@armor_variable_overloading.cpp@2035@FI@fVal +Armor NSR: c:@S@DALSYSPropertyVar@U@#vf#Val@FI@fVal +------------------------------------------- + diff --git a/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/test_variable_overlading.py b/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/test_variable_overlading.py new file mode 100644 index 0000000..84932e9 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/armor_variable_overloading/test_variable_overlading.py @@ -0,0 +1,35 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + print(actual_lines) + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/nsr_generator/armor/conftest.py b/src/tests/common/unit/nsr_generator/armor/conftest.py new file mode 100644 index 0000000..88ab003 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/armor/conftest.py @@ -0,0 +1,34 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import glob +import pytest + +def find_path_from_project_root(marker): + while True: + current = os.getcwd() + if os.path.exists(os.path.join(current, marker)): + return os.path.join(current, marker) + parent = os.path.dirname(current) + if parent == current: + break # Reached the filesystem root + os.chdir(parent) + raise RuntimeError(f"Project root with marker '{marker}' not found.") + +def get_build_dir(): + return find_path_from_project_root("build") + +@pytest.fixture +def binary_path(): + """Returns the absolute path to the binary.""" + return os.path.join(get_build_dir(), "src/tests/common/unit/nsr_generator/nsr_generator_debug") + +@pytest.fixture +def get_cpp_files(request): + curr_dir = os.path.dirname(request.fspath) + return glob.glob(os.path.join(curr_dir, "*.cpp")) + +@pytest.fixture +def binary_args(request): + """Returns the arguments for the binary with debug and JSON output enabled.""" + return ["output.txt", "true"] diff --git a/src/tests/common/unit/nsr_generator/src/main.cpp b/src/tests/common/unit/nsr_generator/src/main.cpp new file mode 100644 index 0000000..d03f7a8 --- /dev/null +++ b/src/tests/common/unit/nsr_generator/src/main.cpp @@ -0,0 +1,171 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include "nsr_generator.hpp" +#include "clang/AST/Decl.h" +#include "clang/AST/DeclBase.h" +#include "clang/AST/DeclCXX.h" +#include "clang/Index/USRGeneration.h" +#include "clang/Tooling/CompilationDatabase.h" +#include "clang/Tooling/Tooling.h" +#include "clang/Frontend/FrontendActions.h" +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Frontend/CompilerInstance.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/ADT/SmallString.h" +#include +#include +#include +#include + +using namespace clang; +using namespace clang::tooling; +using namespace llvm; + +#ifndef CLANG_FLAGS +#define CLANG_FLAGS "" +#endif + +std::vector getClangFlags() { + std::vector flags; + std::istringstream iss(CLANG_FLAGS); + std::string flag; + while (iss >> flag) { + flags.emplace_back(std::move(flag)); + } + return flags; +} + +namespace { +class NSRGenVisitor : public RecursiveASTVisitor { +private: + ASTContext *Context; + llvm::raw_fd_ostream os_output; + std::error_code EC; + bool ShowDiff; + +public: + NSRGenVisitor(ASTContext *Context, StringRef OutputFile, bool ShowDiff) + : Context(Context), os_output(OutputFile, EC, llvm::sys::fs::OF_None), ShowDiff(ShowDiff) {} + + void ProcessDecl(const clang::Decl *Decl, StringRef DeclName) { + SourceLocation Loc = Decl->getLocation(); + unsigned Line = -1; + unsigned Column = -1; + + SourceManager &SM = Context->getSourceManager(); + Line = SM.getSpellingLineNumber(Loc); + Column = SM.getSpellingColumnNumber(Loc); + + SmallString<256> ClangUSR; + bool ClangSuccess = index::generateUSRForDecl(Decl, ClangUSR); + + SmallString<256> ArmorNSR; + bool ArmorSuccess = armor::generateNSRForDecl(Decl, ArmorNSR); + + if (ShowDiff && ArmorNSR.equals(ClangUSR)) return; + + os_output << "Declaration: " << DeclName << "\n"; + os_output << "Location: Line " << Line << ", Column " << Column << "\n"; + os_output << "Kind: " << Decl->getDeclKindName() << "\n"; + + os_output << "Clang USR: " << (!ClangSuccess ? ClangUSR.str() : llvm::StringRef("ERROR")) << "\n"; + os_output << "Armor NSR: " << (!ArmorSuccess ? ArmorNSR.str() : llvm::StringRef("ERROR")) << "\n"; + os_output << "-------------------------------------------\n\n"; + } + + bool VisitNamedDecl(clang::NamedDecl *Decl) { + if (!IsFromMainFile(Decl) || isa(Decl) || isa(Decl) || + isa(Decl) || isa(Decl)) + return true; + + ProcessDecl(Decl, Decl->getNameAsString()); + return true; + } + + bool VisitFriendDecl(clang::FriendDecl *Decl) { + if (!IsFromMainFile(Decl)) + return true; + + ProcessDecl(Decl, "Friend"); + return true; + } + + inline bool IsFromMainFile(const clang::Decl *Decl) { + clang::ASTContext *clangContext = &Decl->getASTContext(); + return clangContext->getSourceManager().isInMainFile(Decl->getLocation()); + } + + ~NSRGenVisitor() { os_output.close(); } +}; + +class NSRGenConsumer : public ASTConsumer { +private: + NSRGenVisitor Visitor; +public: + explicit NSRGenConsumer(ASTContext *Context, const std::string &OutputFile, bool ShowDiff) + : Visitor(Context, OutputFile, ShowDiff) {} + + void HandleTranslationUnit(ASTContext &Context) override { + Visitor.TraverseDecl(Context.getTranslationUnitDecl()); + } +}; + +class NSRGenAction : public ASTFrontendAction { +private: + std::string OutputFile; + bool ShowDiff; +public: + NSRGenAction(const std::string &OutputFile, bool ShowDiff) : OutputFile(OutputFile), ShowDiff(ShowDiff) {} + + std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef file) override { + return std::make_unique(&CI.getASTContext(), OutputFile, ShowDiff); + } +}; + +class NSRGenActionFactory : public FrontendActionFactory { +private: + std::string OutputFile; + bool ShowDiff; +public: + NSRGenActionFactory(const std::string &OutputFile, bool ShowDiff) : OutputFile(OutputFile), ShowDiff(ShowDiff) {} + + std::unique_ptr create() override { + return std::make_unique(OutputFile, ShowDiff); + } +}; + +} + +int main(int argc, const char **argv) { + std::vector CompileCommands = getClangFlags(); + + std::string CurrentDir = "."; + std::unique_ptr Compilations = + std::make_unique(CurrentDir, CompileCommands); + + if (argc < 3) { + llvm::errs() << "Usage: " << argv[0] << " [show-diff]\n"; + llvm::errs() << " input-file: C++ source or header file to process\n"; + llvm::errs() << " output-file: File to write NSR information to\n"; + llvm::errs() << " show-diff: Optional. If 'true', only show declarations with different USR/NSR\n"; + return 1; + } + + std::string fileToProcess = argv[1]; + std::string outputFile = argv[2]; + + bool showDiff = false; + if (argc >= 4) { + std::string showDiffArg = argv[3]; + showDiff = (showDiffArg == "true" || showDiffArg == "1" || + showDiffArg == "yes" || showDiffArg == "y"); + } + + ClangTool Tool(*Compilations, fileToProcess); + + auto Factory = std::make_unique(outputFile, showDiff); + + return Tool.run(Factory.get()); +} diff --git a/src/tests/common/unit/qualified_name_generator/CMakeLists.txt b/src/tests/common/unit/qualified_name_generator/CMakeLists.txt new file mode 100644 index 0000000..df64431 --- /dev/null +++ b/src/tests/common/unit/qualified_name_generator/CMakeLists.txt @@ -0,0 +1,23 @@ +file(GLOB_RECURSE QUALIFIED_NAME_GENERATOR_DEBUG_SOURCES "src/*.cpp") + +add_executable(qualified_name_generator_debug + ${QUALIFIED_NAME_GENERATOR_DEBUG_SOURCES} +) + +target_compile_definitions(qualified_name_generator_debug PRIVATE + CLANG_FLAGS="${CLANG_EXTRA_FLAGS_CPP_ESCAPED}" +) + +target_include_directories(qualified_name_generator_debug PRIVATE + ${CMAKE_SOURCE_DIR}/src/common/include + ${LLVM_INCLUDE_DIRS} + ${CLANG_INCLUDE_DIRS} +) + +target_link_libraries(qualified_name_generator_debug + common_lib_test + ${LLVM_LIBS} + clangTooling + clangIndex + clangFrontend +) diff --git a/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/armor_all_in.cpp b/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/armor_all_in.cpp new file mode 100644 index 0000000..3d4ceb4 --- /dev/null +++ b/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/armor_all_in.cpp @@ -0,0 +1,603 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#ifndef MYLIB_H +#define MYLIB_H + +#include +#include +#include +#include +#include +#include +#include + +using IntVector = std::vector; + +namespace mylib { + +// Type aliases +using StringMap = std::map; +using IntVector = std::vector; +using StringCallback = std::function; + +// Template type aliases +template +using Vector = std::vector; + +template +using Dictionary = std::map; + +template +using UniquePtr = std::unique_ptr; + +// Templated variables with templated types +template +inline Vector empty_vector{}; + +Vector zeta; + +template +inline Dictionary empty_dictionary{}; + +template class Container = Vector> +inline Container empty_container{}; + +// Constants +constexpr int MAX_SIZE = 100; +constexpr double PI = 3.14159265358979323846; + +// Enumerations +enum class Color { + Red, + Green, + Blue, + Yellow +}; + +// Regular function declarations +void printMessage(const char* message); + +// Function template +template +T max(T a, T b) { + return (a > b) ? a : b; +} + +// Function template with multiple parameters +template +auto add(T a, U b) -> decltype(a + b) { + return a + b; +} + +// Simplified - removed variadic template function + +// Simple class +class Point { +private: + double x; + double y; + +public: + Point(double x = 0.0, double y = 0.0); + double getX() const; + double getY() const; + void setX(double x); + void setY(double y); + double distance(const Point& other) const; +}; + +// Class template +template +class Container { +private: + std::vector elements; + +public: + Container() = default; + void add(const T& element); + void remove(size_t index); + T& get(size_t index); + size_t size() const; + bool isEmpty() const; +}; + +// Class template implementation +template +void Container::add(const T& element) { + elements.push_back(element); +} + +template +void Container::remove(size_t index) { + if (index < elements.size()) { + elements.erase(elements.begin() + index); + } +} + +template +T& Container::get(size_t index) { + return elements.at(index); +} + +template +size_t Container::size() const { + return elements.size(); +} + +template +bool Container::isEmpty() const { + return elements.empty(); +} + +// // Template with default parameter +template +class NumericValue { +private: + T value; + +public: + NumericValue(T val = T{}) : value(val) {} + T getValue() const { return value; } + void setValue(T val) { value = val; } +}; + +// Template specialization +// Simplified - removed class template specialization +template<> +class Container { +private: + std::vector elements; + +public: + Container() = default; + void add(bool element); + bool get(size_t index) const; + size_t size() const; +}; + +// Templated variable +template +constexpr T DEFAULT_VALUE = T{}; + +// Specialized templated variables +template<> +constexpr int DEFAULT_VALUE = 0; + +template<> +constexpr double DEFAULT_VALUE = 0.0; + +template<> +constexpr char DEFAULT_VALUE = '\0'; + +// Templated variable with templated type +template +inline Vector DEFAULT_COLLECTION = Vector(3, DEFAULT_VALUE); + +// Templated variable with multiple template parameters +template +inline Dictionary DEFAULT_MAP = {{DEFAULT_VALUE, DEFAULT_VALUE}}; + +// // Class with templated fields +template +class Pair { +public: + T first; + U second; + + Pair() : first(DEFAULT_VALUE), second(DEFAULT_VALUE) {} + Pair(T f, U s) : first(f), second(s) {} + + // Template method within a template class + template + V convert() const { + return static_cast(first + second); + } +}; + +struct alpha{ + int a; +}; + + +// Variable template for compile-time type checking +template +constexpr bool is_numeric_v = std::is_arithmetic::value; + +// Template variable that depends on the type's properties +template +constexpr size_t type_size = sizeof(T); + +// Templated variable with nested template types +template +inline std::pair, Dictionary> default_data_structure = { + Vector(2, DEFAULT_VALUE), + {{DEFAULT_VALUE, DEFAULT_VALUE}} +}; + +int add(int a, int b, int c); + +// Templated variable with conditional type +template +inline std::conditional_t, Vector, Dictionary> + type_appropriate_container = {}; + +template<> +int add(int,int); + +typedef struct{ + int a; +} anon_alpha; + +typedef struct{ + int a; +} ******const***volatile********const const volatile anon_beta[30]; + +struct { + int a; +} gamma; + +struct { + int a; +} ******const***volatile**const******&& anon_gamma = nullptr; + + +} // namespace mylib + +double calculateArea(double radius); + +class Point { +private: + double x; + double y; + +public: + Point(double x = 0.0, double y = 0.0); + double getX() const; + double getY() const; + void setX(double x); + void setY(double y); + double distance(const Point& other) const; +}; + +int add(int,int); + +typedef struct{ + int a; +} anon_alpha; + +typedef struct{ + int a; +} ******const***volatile********const const volatile anon_beta[30]; + +struct { + int a; +} gamma; + +struct { + int a; +} ******const***volatile**const******&& anon_gamma = nullptr; + + +typedef int (*fun) (int,int); + +template<> +class mylib::Container { + int fun(); +}; + +// First, let's create a template class that will be used as a parameter +template +class InnerTemplate { +public: + T value; + + InnerTemplate() : value(T()) {} + explicit InnerTemplate(T val) : value(val) {} + + T getValue() const { return value; } +}; + +// Now, let's create the Container class that accepts a template class as its parameter +template class T, template class U> +class ok { +public: + // Using the template parameter to create an instance with int + T intInstance; + + // Using the template parameter to create an instance with double + T doubleInstance; + + int fun() { + return static_cast(intInstance.getValue() + doubleInstance.getValue()); + } +}; + +typedef InnerTemplate<> alpha; + +// You can also specialize Container if needed +template<> +class ok { +public: + InnerTemplate specializedInstance; + + int fun() { + return specializedInstance.getValue() * 2; + } +}; + +// Basic template class with type parameter +template +class SimpleTemplate { +public: + T value; + SimpleTemplate(T val) : value(val) {} +}; + +// Template with multiple parameters including a non-type parameter +template +class ArrayTemplate { +public: + T array[N]; +}; + +// Template with a template template parameter +template class TemplateParam> +class MetaTemplate { +public: + TemplateParam instance; + TemplateParam doubleInstance; +}; + +// Template with parameter pack +template +class VariadicTemplate { +public: + template + void method(T value, Args... args) {} +}; + +// Template with template template parameter that is itself a parameter pack +template class... Templates> +class VariadicMetaTemplate {}; + +// Nested template example +template +class Outer { +public: + template + class Inner { + public: + T outerValue; + U innerValue; + }; + + Inner innerInstance; +}; + +// Function template +template +T add(T a, T b) { + return a + b; +} + +// Function template with non-type parameter +template +int multiply(int value) { + return value * N; +} + +// Variable template (C++14) +template +constexpr T pi = T(3.1415926535897932385); + + +template class TT> +class ComplexTemplate { +public: + T value; + T array[N]; + TT templateInstance; +}; + +template class TemplateParam> +class AdvancedMetaTemplate { +public: + TemplateParam instance; +}; + +// Basic declarations to test VisitNamedDecl +namespace test_namespace { + int simple_var = 42; + + void simple_function() {} + + class SimpleClass { + public: + int field; + static int static_field; + void method() {} + static void static_method() {} + }; + + // Test namespace alias + namespace ns1 { + int ns1_var = 1; + } + namespace ns_alias = ns1; +} + +// Anonymous namespace to test VisitNamespaceDecl +namespace { + int anon_var = 10; +} + +// Test for anonymous struct in field declaration +struct ContainsAnonymousStruct { + struct { + int anonymous_field; + } field_with_anonymous_struct; + + union { + int i; + float f; + } field_with_anonymous_union; + + enum { + VAL1, + VAL2 + } field_with_anonymous_enum; +}; + +// Test for anonymous struct with typedef +typedef struct { + int data; +} TypedefForAnonymousStruct; + +// Test for embedded anonymous struct +struct OuterStruct { + struct { + int inner_field; + }; // Anonymous struct directly embedded +}; + +// Test for function templates +template +T template_function(T a, T b) { + return a + b; +} + +// Test for class templates +template +class TemplateClass { +public: + T value; + TemplateClass(T val) : value(val) {} +}; + +// Test for template specialization +template<> +class TemplateClass { +public: + void* ptr; + TemplateClass(void* p) : ptr(p) {} +}; + +// Test for partial template specialization +template +class TemplateClass { +public: + T* ptr; + TemplateClass(T* p) : ptr(p) {} +}; + +// Test for template with default parameter values +template +class DefaultParamTemplate { +public: + T values[N]; +}; + +// Test for linkage specification +extern "C" { + void c_function(); +} + +// Test for using declarations and directives +namespace other_ns { + void other_function() {} +} +using other_ns::other_function; +using namespace other_ns; + +// Test for binding declarations (C++17) +void test_binding() { + auto [x, y] = std::pair(1, 2); +} + +// Test for UnresolvedUsingValueDecl and UnresolvedUsingTypenameDecl +template +class Base { +public: + void base_method() {} + typedef int base_type; +}; + +template +class Derived : public Base { +public: + using Base::base_method; // UnresolvedUsingValueDecl + using typename Base::base_type; // UnresolvedUsingTypenameDecl +}; + +// Test for function with variadic arguments +void variadic_function(int first, ...) {} + +// Test for function with parameter that has no name +void function_with_unnamed_param(int) {} + +// Test for function pointer type +void function_with_function_pointer(void (*f)(void*)) {} + +// Test for template specialization with template arguments +template +struct TemplateWithSpecialization { + T value; +}; + +template<> +struct TemplateWithSpecialization { + int specialized_value; +}; + +// Test for class template specialization with multiple template arguments +template +class MultiArgTemplate { +public: + T first; + U second; +}; + +template<> +class MultiArgTemplate { +public: + int specialized_first; + double specialized_second; +}; + +// Test for variable template specialization +template +T static_var = T(0); + +template<> +int static_var = 42; + + // Instantiate templates to ensure they're processed +int result1 = template_function(5, 10); +double result2 = template_function(3.14, 2.71); + +TemplateClass tc1(42); +TemplateClass tc2(3.14); +TemplateClass tc3(nullptr); +TemplateClass tc4(nullptr); + +ArrayTemplate array_template; + +Outer outer; +Outer::Inner inner_explicit; + +VariadicTemplate variadic; + +VariadicMetaTemplate variadic_meta; + +DefaultParamTemplate<> default_template; + +AdvancedMetaTemplate advanced_meta; + +TemplateWithSpecialization specialized_template; + +MultiArgTemplate multi_arg_specialized; + +double pi_value = pi; + + +#endif // MYLIB_H \ No newline at end of file diff --git a/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/expected.txt b/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/expected.txt new file mode 100644 index 0000000..3ff494d --- /dev/null +++ b/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/expected.txt @@ -0,0 +1,440 @@ +Declaration: Container +Location: Line 94, Column 5 +Kind: CXXConstructor +Armor QualifiedName: mylib::Container::Container +Clang QUalifiedName: mylib::Container::Container +Clang USR : c:@N@mylib@ST>1#T@Container@F@Container# +------------------------------------------- + +Declaration: NumericValue +Location: Line 137, Column 5 +Kind: CXXConstructor +Armor QualifiedName: mylib::NumericValue::NumericValue +Clang QUalifiedName: mylib::NumericValue::NumericValue +Clang USR : c:@N@mylib@ST>1#T@NumericValue@F@NumericValue#t0.0# +------------------------------------------- + +Declaration: Container +Location: Line 145, Column 7 +Kind: ClassTemplateSpecialization +Armor QualifiedName: mylib::Container +Clang QUalifiedName: mylib::Container +Clang USR : c:@N@mylib@S@Container>#b +------------------------------------------- + +Declaration: DEFAULT_VALUE +Location: Line 162, Column 15 +Kind: VarTemplateSpecialization +Armor QualifiedName: mylib::DEFAULT_VALUE +Clang QUalifiedName: mylib::DEFAULT_VALUE +Clang USR : c:@N@mylib@DEFAULT_VALUE>#I +------------------------------------------- + +Declaration: DEFAULT_VALUE +Location: Line 165, Column 18 +Kind: VarTemplateSpecialization +Armor QualifiedName: mylib::DEFAULT_VALUE +Clang QUalifiedName: mylib::DEFAULT_VALUE +Clang USR : c:@N@mylib@DEFAULT_VALUE>#d +------------------------------------------- + +Declaration: DEFAULT_VALUE +Location: Line 168, Column 16 +Kind: VarTemplateSpecialization +Armor QualifiedName: mylib::DEFAULT_VALUE +Clang QUalifiedName: mylib::DEFAULT_VALUE +Clang USR : c:@N@mylib@DEFAULT_VALUE>#C +------------------------------------------- + +Declaration: Pair +Location: Line 185, Column 5 +Kind: CXXConstructor +Armor QualifiedName: mylib::Pair::Pair +Clang QUalifiedName: mylib::Pair::Pair +Clang USR : c:@N@mylib@ST>2#T#T@Pair@F@Pair# +------------------------------------------- + +Declaration: Pair +Location: Line 186, Column 5 +Kind: CXXConstructor +Armor QualifiedName: mylib::Pair::Pair +Clang QUalifiedName: mylib::Pair::Pair +Clang USR : c:@N@mylib@ST>2#T#T@Pair@F@Pair#t0.0#t0.1# +------------------------------------------- + +Declaration: add +Location: Line 223, Column 5 +Kind: Function +Armor QualifiedName: mylib::add +Clang QUalifiedName: mylib::add +Clang USR : c:@N@mylib@F@add<#I#I>#I#I# +------------------------------------------- + +Declaration: +Location: Line 225, Column 9 +Kind: CXXRecord +Armor QualifiedName: mylib::anon_alpha +Clang QUalifiedName: mylib::(anonymous) +Clang USR : c:@N@mylib@SA@anon_alpha +------------------------------------------- + +Declaration: a +Location: Line 226, Column 9 +Kind: Field +Armor QualifiedName: mylib::anon_alpha::a +Clang QUalifiedName: mylib::(anonymous struct)::a +Clang USR : c:@N@mylib@SA@anon_alpha@FI@a +------------------------------------------- + +Declaration: +Location: Line 229, Column 9 +Kind: CXXRecord +Armor QualifiedName: mylib::anon_beta +Clang QUalifiedName: mylib::(anonymous) +Clang USR : c:armor_all_in.cpp@N@mylib@S@armor_all_in.cpp@4864 +------------------------------------------- + +Declaration: a +Location: Line 230, Column 9 +Kind: Field +Armor QualifiedName: mylib::anon_beta::a +Clang QUalifiedName: mylib::(anonymous struct)::a +Clang USR : c:armor_all_in.cpp@N@mylib@S@armor_all_in.cpp@4864@FI@a +------------------------------------------- + +Declaration: +Location: Line 233, Column 1 +Kind: CXXRecord +Armor QualifiedName: mylib::gamma +Clang QUalifiedName: mylib::(anonymous) +Clang USR : c:armor_all_in.cpp@N@mylib@S@armor_all_in.cpp@4952 +------------------------------------------- + +Declaration: a +Location: Line 234, Column 9 +Kind: Field +Armor QualifiedName: mylib::gamma::a +Clang QUalifiedName: mylib::(anonymous struct)::a +Clang USR : c:armor_all_in.cpp@N@mylib@S@armor_all_in.cpp@4952@FI@a +------------------------------------------- + +Declaration: +Location: Line 237, Column 1 +Kind: CXXRecord +Armor QualifiedName: mylib::anon_gamma +Clang QUalifiedName: mylib::(anonymous) +Clang USR : c:armor_all_in.cpp@N@mylib@S@armor_all_in.cpp@4982 +------------------------------------------- + +Declaration: a +Location: Line 238, Column 9 +Kind: Field +Armor QualifiedName: mylib::anon_gamma::a +Clang QUalifiedName: mylib::(anonymous struct)::a +Clang USR : c:armor_all_in.cpp@N@mylib@S@armor_all_in.cpp@4982@FI@a +------------------------------------------- + +Declaration: +Location: Line 262, Column 9 +Kind: CXXRecord +Armor QualifiedName: anon_alpha +Clang QUalifiedName: (anonymous) +Clang USR : c:@SA@anon_alpha +------------------------------------------- + +Declaration: a +Location: Line 263, Column 9 +Kind: Field +Armor QualifiedName: anon_alpha::a +Clang QUalifiedName: (anonymous struct)::a +Clang USR : c:@SA@anon_alpha@FI@a +------------------------------------------- + +Declaration: +Location: Line 266, Column 9 +Kind: CXXRecord +Armor QualifiedName: anon_beta +Clang QUalifiedName: (anonymous) +Clang USR : c:armor_all_in.cpp@S@armor_all_in.cpp@5449 +------------------------------------------- + +Declaration: a +Location: Line 267, Column 9 +Kind: Field +Armor QualifiedName: anon_beta::a +Clang QUalifiedName: (anonymous struct)::a +Clang USR : c:armor_all_in.cpp@S@armor_all_in.cpp@5449@FI@a +------------------------------------------- + +Declaration: +Location: Line 270, Column 1 +Kind: CXXRecord +Armor QualifiedName: gamma +Clang QUalifiedName: (anonymous) +Clang USR : c:armor_all_in.cpp@S@armor_all_in.cpp@5537 +------------------------------------------- + +Declaration: a +Location: Line 271, Column 9 +Kind: Field +Armor QualifiedName: gamma::a +Clang QUalifiedName: (anonymous struct)::a +Clang USR : c:armor_all_in.cpp@S@armor_all_in.cpp@5537@FI@a +------------------------------------------- + +Declaration: +Location: Line 274, Column 1 +Kind: CXXRecord +Armor QualifiedName: anon_gamma +Clang QUalifiedName: (anonymous) +Clang USR : c:armor_all_in.cpp@S@armor_all_in.cpp@5567 +------------------------------------------- + +Declaration: a +Location: Line 275, Column 9 +Kind: Field +Armor QualifiedName: anon_gamma::a +Clang QUalifiedName: (anonymous struct)::a +Clang USR : c:armor_all_in.cpp@S@armor_all_in.cpp@5567@FI@a +------------------------------------------- + +Declaration: Container +Location: Line 282, Column 14 +Kind: ClassTemplateSpecialization +Armor QualifiedName: mylib::Container +Clang QUalifiedName: mylib::Container +Clang USR : c:@N@mylib@S@Container>#*FI(#I#I) +------------------------------------------- + +Declaration: InnerTemplate +Location: Line 292, Column 5 +Kind: CXXConstructor +Armor QualifiedName: InnerTemplate::InnerTemplate +Clang QUalifiedName: InnerTemplate::InnerTemplate +Clang USR : c:@ST>1#T@InnerTemplate@F@InnerTemplate# +------------------------------------------- + +Declaration: InnerTemplate +Location: Line 293, Column 14 +Kind: CXXConstructor +Armor QualifiedName: InnerTemplate::InnerTemplate +Clang QUalifiedName: InnerTemplate::InnerTemplate +Clang USR : c:@ST>1#T@InnerTemplate@F@InnerTemplate#t0.0# +------------------------------------------- + +Declaration: ok +Location: Line 317, Column 7 +Kind: ClassTemplateSpecialization +Armor QualifiedName: ok +Clang QUalifiedName: ok +Clang USR : c:@S@ok>#@ST>1#T@InnerTemplate#@ST>1#T@InnerTemplate +------------------------------------------- + +Declaration: SimpleTemplate +Location: Line 331, Column 5 +Kind: CXXConstructor +Armor QualifiedName: SimpleTemplate::SimpleTemplate +Clang QUalifiedName: SimpleTemplate::SimpleTemplate +Clang USR : c:@ST>1#T@SimpleTemplate@F@SimpleTemplate#t0.0# +------------------------------------------- + +Declaration: +Location: Line 428, Column 11 +Kind: Namespace +Armor QualifiedName: (anonymous namespace) +Clang QUalifiedName: (anonymous) +Clang USR : c:@aN +------------------------------------------- + +Declaration: +Location: Line 434, Column 5 +Kind: CXXRecord +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_struct +Clang QUalifiedName: ContainsAnonymousStruct::(anonymous) +Clang USR : c:@S@ContainsAnonymousStruct@S@armor_all_in.cpp@8975 +------------------------------------------- + +Declaration: anonymous_field +Location: Line 435, Column 13 +Kind: Field +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_struct::anonymous_field +Clang QUalifiedName: ContainsAnonymousStruct::(anonymous struct)::anonymous_field +Clang USR : c:@S@ContainsAnonymousStruct@S@armor_all_in.cpp@8975@FI@anonymous_field +------------------------------------------- + +Declaration: +Location: Line 438, Column 5 +Kind: CXXRecord +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_union +Clang QUalifiedName: ContainsAnonymousStruct::(anonymous) +Clang USR : c:@S@ContainsAnonymousStruct@U@armor_all_in.cpp@9057 +------------------------------------------- + +Declaration: i +Location: Line 439, Column 13 +Kind: Field +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_union::i +Clang QUalifiedName: ContainsAnonymousStruct::(anonymous union)::i +Clang USR : c:@S@ContainsAnonymousStruct@U@armor_all_in.cpp@9057@FI@i +------------------------------------------- + +Declaration: f +Location: Line 440, Column 15 +Kind: Field +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_union::f +Clang QUalifiedName: ContainsAnonymousStruct::(anonymous union)::f +Clang USR : c:@S@ContainsAnonymousStruct@U@armor_all_in.cpp@9057@FI@f +------------------------------------------- + +Declaration: +Location: Line 443, Column 5 +Kind: Enum +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_enum +Clang QUalifiedName: ContainsAnonymousStruct::(anonymous) +Clang USR : c:@S@ContainsAnonymousStruct@E@armor_all_in.cpp@9140 +------------------------------------------- + +Declaration: VAL1 +Location: Line 444, Column 9 +Kind: EnumConstant +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_enum::VAL1 +Clang QUalifiedName: ContainsAnonymousStruct::VAL1 +Clang USR : c:@S@ContainsAnonymousStruct@E@armor_all_in.cpp@9140@VAL1 +------------------------------------------- + +Declaration: VAL2 +Location: Line 445, Column 9 +Kind: EnumConstant +Armor QualifiedName: ContainsAnonymousStruct::field_with_anonymous_enum::VAL2 +Clang QUalifiedName: ContainsAnonymousStruct::VAL2 +Clang USR : c:@S@ContainsAnonymousStruct@E@armor_all_in.cpp@9140@VAL2 +------------------------------------------- + +Declaration: +Location: Line 450, Column 9 +Kind: CXXRecord +Armor QualifiedName: TypedefForAnonymousStruct +Clang QUalifiedName: (anonymous) +Clang USR : c:@SA@TypedefForAnonymousStruct +------------------------------------------- + +Declaration: data +Location: Line 451, Column 9 +Kind: Field +Armor QualifiedName: TypedefForAnonymousStruct::data +Clang QUalifiedName: (anonymous struct)::data +Clang USR : c:@SA@TypedefForAnonymousStruct@FI@data +------------------------------------------- + +Declaration: +Location: Line 456, Column 5 +Kind: CXXRecord +Armor QualifiedName: OuterStruct::(Anon::Struct) +Clang QUalifiedName: OuterStruct::(anonymous) +Clang USR : c:@S@OuterStruct@Sa +------------------------------------------- + +Declaration: inner_field +Location: Line 457, Column 13 +Kind: Field +Armor QualifiedName: OuterStruct::(Anon::Struct)::inner_field +Clang QUalifiedName: OuterStruct::(anonymous struct)::inner_field +Clang USR : c:@S@OuterStruct@Sa@FI@inner_field +------------------------------------------- + +Declaration: TemplateClass +Location: Line 472, Column 5 +Kind: CXXConstructor +Armor QualifiedName: TemplateClass::TemplateClass +Clang QUalifiedName: TemplateClass::TemplateClass +Clang USR : c:@ST>1#T@TemplateClass@F@TemplateClass#t0.0# +------------------------------------------- + +Declaration: TemplateClass +Location: Line 477, Column 7 +Kind: ClassTemplateSpecialization +Armor QualifiedName: TemplateClass +Clang QUalifiedName: TemplateClass +Clang USR : c:@S@TemplateClass>#*v +------------------------------------------- + +Declaration: TemplateClass +Location: Line 485, Column 7 +Kind: ClassTemplatePartialSpecialization +Armor QualifiedName: TemplateClass +Clang QUalifiedName: TemplateClass +Clang USR : c:@SP>1#T@TemplateClass>#*t0.0 +------------------------------------------- + +Declaration: TemplateClass +Location: Line 488, Column 5 +Kind: CXXConstructor +Armor QualifiedName: TemplateClass::TemplateClass +Clang QUalifiedName: TemplateClass::TemplateClass +Clang USR : c:@SP>1#T@TemplateClass>#*t0.0@F@TemplateClass#S0_# +------------------------------------------- + +Declaration: +Location: Line 508, Column 17 +Kind: UsingDirective +Armor QualifiedName: ERROR +Clang QUalifiedName: +Clang USR : c: +------------------------------------------- + +Declaration: +Location: Line 512, Column 10 +Kind: Decomposition +Armor QualifiedName: ERROR +Clang QUalifiedName: [x, y] +Clang USR : c:armor_all_in.cpp@10441@F@test_binding# +------------------------------------------- + +Declaration: x +Location: Line 512, Column 11 +Kind: Binding +Armor QualifiedName: test_binding::x +Clang QUalifiedName: x +Clang USR : c:armor_all_in.cpp@10447@F@test_binding#@x +------------------------------------------- + +Declaration: y +Location: Line 512, Column 14 +Kind: Binding +Armor QualifiedName: test_binding::y +Clang QUalifiedName: y +Clang USR : c:armor_all_in.cpp@10450@F@test_binding#@y +------------------------------------------- + +Declaration: TemplateWithSpecialization +Location: Line 546, Column 8 +Kind: ClassTemplateSpecialization +Armor QualifiedName: TemplateWithSpecialization +Clang QUalifiedName: TemplateWithSpecialization +Clang USR : c:@S@TemplateWithSpecialization>#I +------------------------------------------- + +Declaration: MultiArgTemplate +Location: Line 559, Column 7 +Kind: ClassTemplateSpecialization +Armor QualifiedName: MultiArgTemplate +Clang QUalifiedName: MultiArgTemplate +Clang USR : c:@S@MultiArgTemplate>#I#d +------------------------------------------- + +Declaration: static_var +Location: Line 570, Column 5 +Kind: VarTemplateSpecialization +Armor QualifiedName: static_var +Clang QUalifiedName: static_var +Clang USR : c:@static_var>#I +------------------------------------------- + +Declaration: pi +Location: Line 389, Column 13 +Kind: VarTemplateSpecialization +Armor QualifiedName: pi +Clang QUalifiedName: pi +Clang USR : c:@pi>#d +------------------------------------------- + diff --git a/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/test_all_in.py b/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/test_all_in.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/qualified_name_generator/armor/armor_all_in/test_all_in.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/qualified_name_generator/armor/conftest.py b/src/tests/common/unit/qualified_name_generator/armor/conftest.py new file mode 100644 index 0000000..e55c585 --- /dev/null +++ b/src/tests/common/unit/qualified_name_generator/armor/conftest.py @@ -0,0 +1,34 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import glob +import pytest + +def find_path_from_project_root(marker): + while True: + current = os.getcwd() + if os.path.exists(os.path.join(current, marker)): + return os.path.join(current, marker) + parent = os.path.dirname(current) + if parent == current: + break # Reached the filesystem root + os.chdir(parent) + raise RuntimeError(f"Project root with marker '{marker}' not found.") + +def get_build_dir(): + return find_path_from_project_root("build") + +@pytest.fixture +def binary_path(): + """Returns the absolute path to the binary.""" + return os.path.join(get_build_dir(), "src/tests/common/unit/qualified_name_generator/qualified_name_generator_debug") + +@pytest.fixture +def get_cpp_files(request): + curr_dir = os.path.dirname(request.fspath) + return glob.glob(os.path.join(curr_dir, "*.cpp")) + +@pytest.fixture +def binary_args(request): + """Returns the arguments for the binary with debug and JSON output enabled.""" + return ["output.txt", "true"] diff --git a/src/tests/common/unit/qualified_name_generator/src/main.cpp b/src/tests/common/unit/qualified_name_generator/src/main.cpp new file mode 100644 index 0000000..b96689b --- /dev/null +++ b/src/tests/common/unit/qualified_name_generator/src/main.cpp @@ -0,0 +1,162 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include "qualified_name_generator.hpp" +#include "clang/AST/Decl.h" +#include "clang/AST/DeclBase.h" +#include "clang/AST/DeclCXX.h" +#include "clang/Index/USRGeneration.h" +#include "clang/Tooling/CompilationDatabase.h" +#include "clang/Tooling/Tooling.h" +#include "clang/Frontend/FrontendActions.h" +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Frontend/CompilerInstance.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/ADT/SmallString.h" +#include +#include +#include +#include + +using namespace clang; +using namespace clang::tooling; +using namespace llvm; + +#ifndef CLANG_FLAGS +#define CLANG_FLAGS "" +#endif + +std::vector getClangFlags() { + std::vector flags; + std::istringstream iss(CLANG_FLAGS); + std::string flag; + while (iss >> flag) { + flags.emplace_back(std::move(flag)); + } + return flags; +} + +namespace { +class QualifiedNameGenVisitor : public RecursiveASTVisitor { +private: + ASTContext *Context; + llvm::raw_fd_ostream os_output; + std::error_code EC; + bool ShowDiff; + +public: + QualifiedNameGenVisitor(ASTContext *Context, StringRef OutputFile, bool ShowDiff) + : Context(Context), os_output(OutputFile, EC, llvm::sys::fs::OF_None), ShowDiff(ShowDiff) {} + + bool VisitNamedDecl(clang::NamedDecl *Decl) { + if (!IsFromMainFile(Decl) || isa(Decl) || isa(Decl) || + isa(Decl) || isa(Decl)) + return true; + + SourceLocation Loc = Decl->getLocation(); + unsigned Line = -1; + unsigned Column = -1; + + SourceManager &SM = Context->getSourceManager(); + Line = SM.getSpellingLineNumber(Loc); + Column = SM.getSpellingColumnNumber(Loc); + + const std::string clangQualifiedName = Decl->getQualifiedNameAsString(); + + SmallString<256> armorQualifiedName; + bool ArmorSuccess = armor::generateQualifiedNameForDecl(Decl, armorQualifiedName); + + if (ShowDiff && armorQualifiedName.equals(clangQualifiedName)) return true; + + SmallString<256> clangUSR; + index::generateUSRForDecl(Decl, clangUSR); + + os_output << "Declaration: " << Decl->getNameAsString() << "\n"; + os_output << "Location: Line " << Line << ", Column " << Column << "\n"; + os_output << "Kind: " << Decl->getDeclKindName() << "\n"; + os_output << "Armor QualifiedName: " << (!ArmorSuccess ? armorQualifiedName.str() : llvm::StringRef("ERROR")) << "\n"; + os_output << "Clang QUalifiedName: " << clangQualifiedName << "\n"; + os_output << "Clang USR : " << clangUSR << "\n"; + os_output << "-------------------------------------------\n\n"; + + return true; + } + + inline bool IsFromMainFile(const clang::Decl *Decl) { + clang::ASTContext *clangContext = &Decl->getASTContext(); + return clangContext->getSourceManager().isInMainFile(Decl->getLocation()); + } + + ~QualifiedNameGenVisitor() { os_output.close(); } +}; + +class QualifiedNameGenConsumer : public ASTConsumer { +private: + QualifiedNameGenVisitor Visitor; +public: + explicit QualifiedNameGenConsumer(ASTContext *Context, const std::string &OutputFile, bool ShowDiff) + : Visitor(Context, OutputFile, ShowDiff) {} + + void HandleTranslationUnit(ASTContext &Context) override { + Visitor.TraverseDecl(Context.getTranslationUnitDecl()); + } +}; + +class QualifiedNameGenAction : public ASTFrontendAction { +private: + std::string OutputFile; + bool ShowDiff; +public: + QualifiedNameGenAction(const std::string &OutputFile, bool ShowDiff) : OutputFile(OutputFile), ShowDiff(ShowDiff) {} + + std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef file) override { + return std::make_unique(&CI.getASTContext(), OutputFile, ShowDiff); + } +}; + +class QualifiedNameGenActionFactory : public FrontendActionFactory { +private: + std::string OutputFile; + bool ShowDiff; +public: + QualifiedNameGenActionFactory(const std::string &OutputFile, bool ShowDiff) : OutputFile(OutputFile), ShowDiff(ShowDiff) {} + + std::unique_ptr create() override { + return std::make_unique(OutputFile, ShowDiff); + } +}; + +} + +int main(int argc, const char **argv) { + std::vector CompileCommands = getClangFlags(); + + std::string CurrentDir = "."; + std::unique_ptr Compilations = + std::make_unique(CurrentDir, CompileCommands); + + if (argc < 3) { + llvm::errs() << "Usage: " << argv[0] << " [show-diff]\n"; + llvm::errs() << " input-file: C++ source or header file to process\n"; + llvm::errs() << " output-file: File to write qualified-name information to\n"; + llvm::errs() << " show-diff: Optional. If 'true', only show declarations with different qualified names\n"; + return 1; + } + + std::string fileToProcess = argv[1]; + std::string outputFile = argv[2]; + + bool showDiff = false; + if (argc >= 4) { + std::string showDiffArg = argv[3]; + showDiff = (showDiffArg == "true" || showDiffArg == "1" || + showDiffArg == "yes" || showDiffArg == "y"); + } + + ClangTool Tool(*Compilations, fileToProcess); + + auto Factory = std::make_unique(outputFile, showDiff); + + return Tool.run(Factory.get()); +} diff --git a/src/tests/common/unit/usr_generator/CMakeLists.txt b/src/tests/common/unit/usr_generator/CMakeLists.txt new file mode 100644 index 0000000..a6b15ec --- /dev/null +++ b/src/tests/common/unit/usr_generator/CMakeLists.txt @@ -0,0 +1,23 @@ +file(GLOB_RECURSE USR_GENERATOR_DEBUG_SOURCES "src/*.cpp") + +add_executable(usr_generator_debug + ${USR_GENERATOR_DEBUG_SOURCES} +) + +target_compile_definitions(usr_generator_debug PRIVATE + CLANG_FLAGS="${CLANG_EXTRA_FLAGS_CPP_ESCAPED}" +) + +target_include_directories(usr_generator_debug PRIVATE + ${CMAKE_SOURCE_DIR}/src/common/include + ${LLVM_INCLUDE_DIRS} + ${CLANG_INCLUDE_DIRS} +) + +target_link_libraries(usr_generator_debug + common_lib_test + ${LLVM_LIBS} + clangTooling + clangIndex + clangFrontend +) diff --git a/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/armor_cxx_functions.cpp b/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/armor_cxx_functions.cpp new file mode 100644 index 0000000..d94e616 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/armor_cxx_functions.cpp @@ -0,0 +1,64 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +// test_overloaded_functions.cpp +#include +#include +#include +#include +#include +#include + +template +class ComplexContainer; + +template +struct VariadicStruct; + +enum class ProcessingMode { + Fast, + Accurate, + Balanced +}; + +// First overloaded function with complex parameters +template +std::tuple processData( + const std::vector& inputData, + std::map& configMap, + const std::function& transformFunc, + const ComplexContainer* container, + ProcessingMode mode = ProcessingMode::Balanced, + const std::shared_ptr>& extraData = nullptr); + +// Second overloaded function with different complex parameters +template +std::pair, U> processData( + const std::map>& inputMap, + std::function modifierFunc, + const std::tuple& additionalArgs, + int priority, + const ComplexContainer& settings, + ProcessingMode mode = ProcessingMode::Fast); + +// Definition of the custom types used in the functions +template +class ComplexContainer { +public: + T primary; + U secondary; + std::vector> elements; + + ComplexContainer(T p, U s) : primary(p), secondary(s) {} + + void add(const T& t, const U& u); + + std::size_t size() const; +}; + +template +struct VariadicStruct { + std::tuple data; + + template + VariadicStruct(Ts&&... args); +}; diff --git a/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/expected.txt b/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/expected.txt new file mode 100644 index 0000000..9cdb11e --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/expected.txt @@ -0,0 +1,322 @@ +Declaration: ComplexContainer +Location: Line 10, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#T@ComplexContainer +Armor USR: c:@ST>2#T#T@ComplexContainer +------------------------------------------- + +Declaration: ComplexContainer +Location: Line 10, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>2#T#T@ComplexContainer +Armor USR: c:@ST>2#T#T@ComplexContainer +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 13, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#pT@VariadicStruct +Armor USR: c:@ST>1#pT@VariadicStruct +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 13, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#pT@VariadicStruct +Armor USR: c:@ST>1#pT@VariadicStruct +------------------------------------------- + +Declaration: ProcessingMode +Location: Line 15, Column 12 +Kind: Enum +Clang USR: c:@E@ProcessingMode +Armor USR: c:@E@ProcessingMode +------------------------------------------- + +Declaration: Fast +Location: Line 16, Column 5 +Kind: EnumConstant +Clang USR: c:@E@ProcessingMode@Fast +Armor USR: c:@E@ProcessingMode@Fast +------------------------------------------- + +Declaration: Accurate +Location: Line 17, Column 5 +Kind: EnumConstant +Clang USR: c:@E@ProcessingMode@Accurate +Armor USR: c:@E@ProcessingMode@Accurate +------------------------------------------- + +Declaration: Balanced +Location: Line 18, Column 5 +Kind: EnumConstant +Clang USR: c:@E@ProcessingMode@Balanced +Armor USR: c:@E@ProcessingMode@Balanced +------------------------------------------- + +Declaration: processData +Location: Line 23, Column 24 +Kind: FunctionTemplate +Clang USR: c:@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b# +Armor USR: c:@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b# +------------------------------------------- + +Declaration: processData +Location: Line 23, Column 24 +Kind: Function +Clang USR: c:@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b# +Armor USR: c:@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b# +------------------------------------------- + +Declaration: inputData +Location: Line 24, Column 27 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@453@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@inputData +Armor USR: c:armor_cxx_functions.cpp@453@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@inputData +------------------------------------------- + +Declaration: configMap +Location: Line 25, Column 31 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@490@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@configMap +Armor USR: c:armor_cxx_functions.cpp@490@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@configMap +------------------------------------------- + +Declaration: transformFunc +Location: Line 26, Column 37 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@531@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@transformFunc +Armor USR: c:armor_cxx_functions.cpp@531@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@transformFunc +------------------------------------------- + +Declaration: +Location: Line 26, Column 28 +Kind: ParmVar +Clang USR: ERROR +Armor USR: ERROR +------------------------------------------- + +Declaration: +Location: Line 26, Column 33 +Kind: ParmVar +Clang USR: ERROR +Armor USR: ERROR +------------------------------------------- + +Declaration: container +Location: Line 27, Column 35 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@582@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@container +Armor USR: c:armor_cxx_functions.cpp@582@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@container +------------------------------------------- + +Declaration: mode +Location: Line 28, Column 20 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@627@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@mode +Armor USR: c:armor_cxx_functions.cpp@627@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@mode +------------------------------------------- + +Declaration: extraData +Location: Line 29, Column 68 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@679@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@extraData +Armor USR: c:armor_cxx_functions.cpp@679@FT@>3#T#T#NIprocessData#&1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S2_#&>@N@std@ST>4#T#T#T#T@map4$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#Ct0.1$@N@std@S@less>#S6_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S6_S9_#&1>@N@std@ST>1#T@function1FS9_(#S2_#I)#*1>@ST>2#T#T@ComplexContainer2S2_S9_#$@E@ProcessingMode#&1>@N@std@ST>1#T@shared_ptr1>@ST>1#pT@VariadicStruct1p3S2_dS6_#>@N@std@ST>1#pT@tuple1p3S2_S9_b#@extraData +------------------------------------------- + +Declaration: processData +Location: Line 33, Column 30 +Kind: FunctionTemplate +Clang USR: c:@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_# +Armor USR: c:@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_# +------------------------------------------- + +Declaration: processData +Location: Line 33, Column 30 +Kind: Function +Clang USR: c:@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_# +Armor USR: c:@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_# +------------------------------------------- + +Declaration: inputMap +Location: Line 34, Column 40 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@933@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@inputMap +Armor USR: c:armor_cxx_functions.cpp@933@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@inputMap +------------------------------------------- + +Declaration: modifierFunc +Location: Line 35, Column 38 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@982@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@modifierFunc +Armor USR: c:armor_cxx_functions.cpp@982@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@modifierFunc +------------------------------------------- + +Declaration: +Location: Line 35, Column 26 +Kind: ParmVar +Clang USR: ERROR +Armor USR: ERROR +------------------------------------------- + +Declaration: +Location: Line 35, Column 35 +Kind: ParmVar +Clang USR: ERROR +Armor USR: ERROR +------------------------------------------- + +Declaration: additionalArgs +Location: Line 36, Column 32 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1033@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@additionalArgs +Armor USR: c:armor_cxx_functions.cpp@1033@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@additionalArgs +------------------------------------------- + +Declaration: priority +Location: Line 37, Column 9 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1080@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@priority +Armor USR: c:armor_cxx_functions.cpp@1080@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@priority +------------------------------------------- + +Declaration: settings +Location: Line 38, Column 35 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1098@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@settings +Armor USR: c:armor_cxx_functions.cpp@1098@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@settings +------------------------------------------- + +Declaration: mode +Location: Line 39, Column 20 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1142@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@mode +Armor USR: c:armor_cxx_functions.cpp@1142@FT@>4#T#T#NI#pTprocessData#&1>@N@std@ST>4#T#T#T#T@map4t0.1>@N@std@ST>2#T#T@vector2t0.0>@N@std@ST>1#T@allocator1S4_>@N@std@ST>1#T@less1S2_>@N@std@ST>1#T@allocator1>@N@std@ST>2#T#T@pair21S2_S3_#>@N@std@ST>1#T@function1Fv(#&S4_#Pt0.3)#&1>@N@std@ST>1#pT@tuple1p1PS12_#I#&1>@ST>2#T#T@ComplexContainer2S2_S4_#$@E@ProcessingMode#>@N@std@ST>2#T#T@pair2S3_S2_#@mode +------------------------------------------- + +Declaration: ComplexContainer +Location: Line 43, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>2#T#T@ComplexContainer +Armor USR: c:@ST>2#T#T@ComplexContainer +------------------------------------------- + +Declaration: ComplexContainer +Location: Line 43, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>2#T#T@ComplexContainer +Armor USR: c:@ST>2#T#T@ComplexContainer +------------------------------------------- + +Declaration: primary +Location: Line 45, Column 7 +Kind: Field +Clang USR: c:@ST>2#T#T@ComplexContainer@FI@primary +Armor USR: c:@ST>2#T#T@ComplexContainer@FI@primary +------------------------------------------- + +Declaration: secondary +Location: Line 46, Column 7 +Kind: Field +Clang USR: c:@ST>2#T#T@ComplexContainer@FI@secondary +Armor USR: c:@ST>2#T#T@ComplexContainer@FI@secondary +------------------------------------------- + +Declaration: elements +Location: Line 47, Column 34 +Kind: Field +Clang USR: c:@ST>2#T#T@ComplexContainer@FI@elements +Armor USR: c:@ST>2#T#T@ComplexContainer@FI@elements +------------------------------------------- + +Declaration: ComplexContainer +Location: Line 49, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>2#T#T@ComplexContainer@F@ComplexContainer#t0.0#t0.1# +Armor USR: c:@ST>2#T#T@ComplexContainer@F@ComplexContainer#t0.0#t0.1# +------------------------------------------- + +Declaration: p +Location: Line 49, Column 24 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1411@ST>2#T#T@ComplexContainer@F@ComplexContainer#t0.0#t0.1#@p +Armor USR: c:armor_cxx_functions.cpp@1411@ST>2#T#T@ComplexContainer@F@ComplexContainer#t0.0#t0.1#@p +------------------------------------------- + +Declaration: s +Location: Line 49, Column 29 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1416@ST>2#T#T@ComplexContainer@F@ComplexContainer#t0.0#t0.1#@s +Armor USR: c:armor_cxx_functions.cpp@1416@ST>2#T#T@ComplexContainer@F@ComplexContainer#t0.0#t0.1#@s +------------------------------------------- + +Declaration: add +Location: Line 51, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>2#T#T@ComplexContainer@F@add#&1t0.0#&1t0.1# +Armor USR: c:@ST>2#T#T@ComplexContainer@F@add#&1t0.0#&1t0.1# +------------------------------------------- + +Declaration: t +Location: Line 51, Column 23 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1469@ST>2#T#T@ComplexContainer@F@add#&1t0.0#&1t0.1#@t +Armor USR: c:armor_cxx_functions.cpp@1469@ST>2#T#T@ComplexContainer@F@add#&1t0.0#&1t0.1#@t +------------------------------------------- + +Declaration: u +Location: Line 51, Column 35 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1481@ST>2#T#T@ComplexContainer@F@add#&1t0.0#&1t0.1#@u +Armor USR: c:armor_cxx_functions.cpp@1481@ST>2#T#T@ComplexContainer@F@add#&1t0.0#&1t0.1#@u +------------------------------------------- + +Declaration: size +Location: Line 53, Column 17 +Kind: CXXMethod +Clang USR: c:@ST>2#T#T@ComplexContainer@F@size#1 +Armor USR: c:@ST>2#T#T@ComplexContainer@F@size#1 +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 57, Column 8 +Kind: ClassTemplate +Clang USR: c:@ST>1#pT@VariadicStruct +Armor USR: c:@ST>1#pT@VariadicStruct +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 57, Column 8 +Kind: CXXRecord +Clang USR: c:@ST>1#pT@VariadicStruct +Armor USR: c:@ST>1#pT@VariadicStruct +------------------------------------------- + +Declaration: data +Location: Line 58, Column 25 +Kind: Field +Clang USR: c:@ST>1#pT@VariadicStruct@FI@data +Armor USR: c:@ST>1#pT@VariadicStruct@FI@data +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 61, Column 5 +Kind: FunctionTemplate +Clang USR: c:@ST>1#pT@VariadicStruct@FT@>1#pTVariadicStruct#P&&t1.0#v# +Armor USR: c:@ST>1#pT@VariadicStruct@FT@>1#pTVariadicStruct#P&&t1.0#v# +------------------------------------------- + +Declaration: VariadicStruct +Location: Line 61, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#pT@VariadicStruct@FT@>1#pTVariadicStruct#P&&t1.0#v# +Armor USR: c:@ST>1#pT@VariadicStruct@FT@>1#pTVariadicStruct#P&&t1.0#v# +------------------------------------------- + +Declaration: args +Location: Line 61, Column 28 +Kind: ParmVar +Clang USR: c:armor_cxx_functions.cpp@1667@ST>1#pT@VariadicStruct@FT@>1#pTVariadicStruct#P&&t1.0#v#@args +Armor USR: c:armor_cxx_functions.cpp@1667@ST>1#pT@VariadicStruct@FT@>1#pTVariadicStruct#P&&t1.0#v#@args +------------------------------------------- + diff --git a/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/test_usr_cxx_functions.py b/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/test_usr_cxx_functions.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_cxx_functions/test_usr_cxx_functions.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/armor/armor_cxx_records/armor_cxx_records.cpp b/src/tests/common/unit/usr_generator/armor/armor_cxx_records/armor_cxx_records.cpp new file mode 100644 index 0000000..d39895f --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_cxx_records/armor_cxx_records.cpp @@ -0,0 +1,64 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +// test_template_specializations.cpp +#include +#include + +// Primary template +template +class Container { +public: + T data; + + Container(T val); + + void print(); + + T getValue() const; +}; + +template<> +class Container { +public: + int data; + + Container(int val); + + void print(); + + int getValue() const; + + bool isEven() const; +}; + +// Explicit specialization for std::string +template<> +class Container { +public: + std::string data; + + Container(std::string val); + + void print(); + + std::string getValue() const; + + int length() const; +}; + +// Partial specialization for pointer types +template +class Container { +public: + T* data; + + Container(T* val); + + void print(); + + T* getValue() const; + + T& dereference() const; +}; + + diff --git a/src/tests/common/unit/usr_generator/armor/armor_cxx_records/expected.txt b/src/tests/common/unit/usr_generator/armor/armor_cxx_records/expected.txt new file mode 100644 index 0000000..2067edd --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_cxx_records/expected.txt @@ -0,0 +1,196 @@ +Declaration: Container +Location: Line 7, Column 7 +Kind: ClassTemplate +Clang USR: c:@ST>1#T@Container +Armor USR: c:@ST>1#T@Container +------------------------------------------- + +Declaration: Container +Location: Line 7, Column 7 +Kind: CXXRecord +Clang USR: c:@ST>1#T@Container +Armor USR: c:@ST>1#T@Container +------------------------------------------- + +Declaration: data +Location: Line 9, Column 7 +Kind: Field +Clang USR: c:@ST>1#T@Container@FI@data +Armor USR: c:@ST>1#T@Container@FI@data +------------------------------------------- + +Declaration: Container +Location: Line 11, Column 5 +Kind: CXXConstructor +Clang USR: c:@ST>1#T@Container@F@Container#t0.0# +Armor USR: c:@ST>1#T@Container@F@Container#t0.0# +------------------------------------------- + +Declaration: val +Location: Line 11, Column 17 +Kind: ParmVar +Clang USR: c:armor_cxx_records.cpp@174@ST>1#T@Container@F@Container#t0.0#@val +Armor USR: c:armor_cxx_records.cpp@174@ST>1#T@Container@F@Container#t0.0#@val +------------------------------------------- + +Declaration: print +Location: Line 13, Column 10 +Kind: CXXMethod +Clang USR: c:@ST>1#T@Container@F@print# +Armor USR: c:@ST>1#T@Container@F@print# +------------------------------------------- + +Declaration: getValue +Location: Line 15, Column 7 +Kind: CXXMethod +Clang USR: c:@ST>1#T@Container@F@getValue#1 +Armor USR: c:@ST>1#T@Container@F@getValue#1 +------------------------------------------- + +Declaration: Container +Location: Line 19, Column 7 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@Container>#I +Armor USR: c:@S@Container>#I +------------------------------------------- + +Declaration: data +Location: Line 21, Column 9 +Kind: Field +Clang USR: c:@S@Container>#I@FI@data +Armor USR: c:@S@Container>#I@FI@data +------------------------------------------- + +Declaration: Container +Location: Line 23, Column 5 +Kind: CXXConstructor +Clang USR: c:@S@Container>#I@F@Container#I# +Armor USR: c:@S@Container>#I@F@Container#I# +------------------------------------------- + +Declaration: val +Location: Line 23, Column 19 +Kind: ParmVar +Clang USR: c:armor_cxx_records.cpp@313@S@Container>#I@F@Container#I#@val +Armor USR: c:armor_cxx_records.cpp@313@S@Container>#I@F@Container#I#@val +------------------------------------------- + +Declaration: print +Location: Line 25, Column 10 +Kind: CXXMethod +Clang USR: c:@S@Container>#I@F@print# +Armor USR: c:@S@Container>#I@F@print# +------------------------------------------- + +Declaration: getValue +Location: Line 27, Column 9 +Kind: CXXMethod +Clang USR: c:@S@Container>#I@F@getValue#1 +Armor USR: c:@S@Container>#I@F@getValue#1 +------------------------------------------- + +Declaration: isEven +Location: Line 29, Column 10 +Kind: CXXMethod +Clang USR: c:@S@Container>#I@F@isEven#1 +Armor USR: c:@S@Container>#I@F@isEven#1 +------------------------------------------- + +Declaration: Container +Location: Line 34, Column 7 +Kind: ClassTemplateSpecialization +Clang USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C +Armor USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C +------------------------------------------- + +Declaration: data +Location: Line 36, Column 17 +Kind: Field +Clang USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@FI@data +Armor USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@FI@data +------------------------------------------- + +Declaration: Container +Location: Line 38, Column 5 +Kind: CXXConstructor +Clang USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@Container#S0_# +Armor USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@Container#S0_# +------------------------------------------- + +Declaration: val +Location: Line 38, Column 27 +Kind: ParmVar +Clang USR: c:armor_cxx_records.cpp@545@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@Container#S0_#@val +Armor USR: c:armor_cxx_records.cpp@545@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@Container#S0_#@val +------------------------------------------- + +Declaration: print +Location: Line 40, Column 10 +Kind: CXXMethod +Clang USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@print# +Armor USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@print# +------------------------------------------- + +Declaration: getValue +Location: Line 42, Column 17 +Kind: CXXMethod +Clang USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@getValue#1 +Armor USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@getValue#1 +------------------------------------------- + +Declaration: length +Location: Line 44, Column 9 +Kind: CXXMethod +Clang USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@length#1 +Armor USR: c:@S@Container>#$@N@std@N@__cxx11@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C@F@length#1 +------------------------------------------- + +Declaration: Container +Location: Line 49, Column 7 +Kind: ClassTemplatePartialSpecialization +Clang USR: c:@SP>1#T@Container>#*t0.0 +Armor USR: c:@SP>1#T@Container>#*t0.0 +------------------------------------------- + +Declaration: data +Location: Line 51, Column 8 +Kind: Field +Clang USR: c:@SP>1#T@Container>#*t0.0@FI@data +Armor USR: c:@SP>1#T@Container>#*t0.0@FI@data +------------------------------------------- + +Declaration: Container +Location: Line 53, Column 5 +Kind: CXXConstructor +Clang USR: c:@SP>1#T@Container>#*t0.0@F@Container#S0_# +Armor USR: c:@SP>1#T@Container>#*t0.0@F@Container#S0_# +------------------------------------------- + +Declaration: val +Location: Line 53, Column 18 +Kind: ParmVar +Clang USR: c:armor_cxx_records.cpp@785@SP>1#T@Container>#*t0.0@F@Container#S0_#@val +Armor USR: c:armor_cxx_records.cpp@785@SP>1#T@Container>#*t0.0@F@Container#S0_#@val +------------------------------------------- + +Declaration: print +Location: Line 55, Column 10 +Kind: CXXMethod +Clang USR: c:@SP>1#T@Container>#*t0.0@F@print# +Armor USR: c:@SP>1#T@Container>#*t0.0@F@print# +------------------------------------------- + +Declaration: getValue +Location: Line 57, Column 8 +Kind: CXXMethod +Clang USR: c:@SP>1#T@Container>#*t0.0@F@getValue#1 +Armor USR: c:@SP>1#T@Container>#*t0.0@F@getValue#1 +------------------------------------------- + +Declaration: dereference +Location: Line 59, Column 8 +Kind: CXXMethod +Clang USR: c:@SP>1#T@Container>#*t0.0@F@dereference#1 +Armor USR: c:@SP>1#T@Container>#*t0.0@F@dereference#1 +------------------------------------------- + diff --git a/src/tests/common/unit/usr_generator/armor/armor_cxx_records/test_usr_cxx_records.py b/src/tests/common/unit/usr_generator/armor/armor_cxx_records/test_usr_cxx_records.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_cxx_records/test_usr_cxx_records.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/armor_field_var_merge.cpp b/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/armor_field_var_merge.cpp new file mode 100644 index 0000000..9ea131f --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/armor_field_var_merge.cpp @@ -0,0 +1,36 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include + +template +struct CustomTraits { + static constexpr bool is_custom = false; + static constexpr size_t size = sizeof(T); + using promoted_type = T; +}; + +template<> +struct CustomTraits { + static constexpr bool is_custom = true; + static constexpr size_t size = 1; + using promoted_type = int; // Char promotes to int +}; + +template<> +struct CustomTraits { + static constexpr bool is_custom = true; + static constexpr size_t size = sizeof(float); + using promoted_type = double; // Float promotes to double +}; + + +template +struct StaticSpecialization { + static T defaultValue; + + static T getDefault() { + return defaultValue; + } +}; + +static constexpr bool is_custom = true; diff --git a/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/expected.txt b/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/expected.txt new file mode 100644 index 0000000..18ec769 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/expected.txt @@ -0,0 +1,126 @@ +Declaration: CustomTraits +Location: Line 4, Column 8 +Kind: ClassTemplate +Armor USR: c:@ST>1#T@CustomTraits +Clang USR: c:@ST>1#T@CustomTraits +------------------------------------------- + +Declaration: CustomTraits +Location: Line 4, Column 8 +Kind: CXXRecord +Armor USR: c:@ST>1#T@CustomTraits +Clang USR: c:@ST>1#T@CustomTraits +------------------------------------------- + +Declaration: is_custom +Location: Line 5, Column 27 +Kind: Var +Armor USR: c:@ST>1#T@CustomTraits@FI@is_custom +Clang USR: c:@ST>1#T@CustomTraits@is_custom +------------------------------------------- + +Declaration: size +Location: Line 6, Column 29 +Kind: Var +Armor USR: c:@ST>1#T@CustomTraits@FI@size +Clang USR: c:@ST>1#T@CustomTraits@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 7, Column 11 +Kind: TypeAlias +Armor USR: c:@ST>1#T@CustomTraits@T@promoted_type +Clang USR: c:@ST>1#T@CustomTraits@promoted_type +------------------------------------------- + +Declaration: CustomTraits +Location: Line 11, Column 8 +Kind: ClassTemplateSpecialization +Armor USR: c:@S@CustomTraits>#C +Clang USR: c:@S@CustomTraits>#C +------------------------------------------- + +Declaration: is_custom +Location: Line 12, Column 27 +Kind: Var +Armor USR: c:@S@CustomTraits>#C@FI@is_custom +Clang USR: c:@S@CustomTraits>#C@is_custom +------------------------------------------- + +Declaration: size +Location: Line 13, Column 29 +Kind: Var +Armor USR: c:@S@CustomTraits>#C@FI@size +Clang USR: c:@S@CustomTraits>#C@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 14, Column 11 +Kind: TypeAlias +Armor USR: c:@S@CustomTraits>#C@T@promoted_type +Clang USR: c:@S@CustomTraits>#C@promoted_type +------------------------------------------- + +Declaration: CustomTraits +Location: Line 18, Column 8 +Kind: ClassTemplateSpecialization +Armor USR: c:@S@CustomTraits>#f +Clang USR: c:@S@CustomTraits>#f +------------------------------------------- + +Declaration: is_custom +Location: Line 19, Column 27 +Kind: Var +Armor USR: c:@S@CustomTraits>#f@FI@is_custom +Clang USR: c:@S@CustomTraits>#f@is_custom +------------------------------------------- + +Declaration: size +Location: Line 20, Column 29 +Kind: Var +Armor USR: c:@S@CustomTraits>#f@FI@size +Clang USR: c:@S@CustomTraits>#f@size +------------------------------------------- + +Declaration: promoted_type +Location: Line 21, Column 11 +Kind: TypeAlias +Armor USR: c:@S@CustomTraits>#f@T@promoted_type +Clang USR: c:@S@CustomTraits>#f@promoted_type +------------------------------------------- + +Declaration: StaticSpecialization +Location: Line 26, Column 8 +Kind: ClassTemplate +Armor USR: c:@ST>1#T@StaticSpecialization +Clang USR: c:@ST>1#T@StaticSpecialization +------------------------------------------- + +Declaration: StaticSpecialization +Location: Line 26, Column 8 +Kind: CXXRecord +Armor USR: c:@ST>1#T@StaticSpecialization +Clang USR: c:@ST>1#T@StaticSpecialization +------------------------------------------- + +Declaration: defaultValue +Location: Line 27, Column 14 +Kind: Var +Armor USR: c:@ST>1#T@StaticSpecialization@FI@defaultValue +Clang USR: c:@ST>1#T@StaticSpecialization@defaultValue +------------------------------------------- + +Declaration: getDefault +Location: Line 29, Column 14 +Kind: CXXMethod +Armor USR: c:@ST>1#T@StaticSpecialization@F@getDefault#S +Clang USR: c:@ST>1#T@StaticSpecialization@F@getDefault#S +------------------------------------------- + +Declaration: is_custom +Location: Line 34, Column 23 +Kind: Var +Armor USR: c:@is_custom +Clang USR: c:armor_field_var_merge.cpp@is_custom +------------------------------------------- + diff --git a/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/test_field_var_merge.py b/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/test_field_var_merge.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_field_var_merge/test_field_var_merge.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/armor/armor_tag_anon/armor_tag_anon.cpp b/src/tests/common/unit/usr_generator/armor/armor_tag_anon/armor_tag_anon.cpp new file mode 100644 index 0000000..7287423 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_tag_anon/armor_tag_anon.cpp @@ -0,0 +1,76 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause + +struct { +} alpha; + +struct alpha2{ + int x; +} alpha2; + +struct alpah3{ + int x; +} alpha4; + +enum { + x, +} alpha_enum; + +enum alpha_eum2{ + y, +} alpha_enum2; + +enum alpha_eum3{ + z, +} alpha_enum4; + + +struct armor{ + + struct{ + int x; + struct { + int y; + }; + }; + + enum{ + x1, + }; + + enum{ + y1, + }; + +}; + + +struct { int x; } *const*volatile*&& field = nullptr; + +struct {int y;} *** gamma[30]; + +struct SomeClass; +struct { int x; } SomeClass::* class_member_ptr; + +enum { I } *****const**volatile** beta = nullptr; + +struct { + int a; +} zeta; + +struct zeta{ + int a; + int b; +} alpha1; + +typedef struct { + int a; + int b; +} *****const**********alpha6[100]; + +alpha6 ok; + +typedef enum { + a, + b +} *****const**********alpha7[100]; diff --git a/src/tests/common/unit/usr_generator/armor/armor_tag_anon/expected.txt b/src/tests/common/unit/usr_generator/armor/armor_tag_anon/expected.txt new file mode 100644 index 0000000..68c98de --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_tag_anon/expected.txt @@ -0,0 +1,385 @@ +Declaration: +Location: Line 2, Column 1 +Kind: CXXRecord +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@1 +Armor USR: c:@S@#vf#alpha +------------------------------------------- + +Declaration: alpha +Location: Line 3, Column 3 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@alpha +Armor USR: c:@alpha +------------------------------------------- + +Declaration: alpha2 +Location: Line 5, Column 8 +Kind: CXXRecord +Clang USR: c:@S@alpha2 +Armor USR: c:@S@alpha2 +------------------------------------------- + +Declaration: x +Location: Line 6, Column 9 +Kind: Field +Clang USR: c:@S@alpha2@FI@x +Armor USR: c:@S@alpha2@FI@x +------------------------------------------- + +Declaration: alpha2 +Location: Line 7, Column 3 +Kind: Var +Clang USR: c:@alpha2 +Armor USR: c:@alpha2 +------------------------------------------- + +Declaration: alpah3 +Location: Line 9, Column 8 +Kind: CXXRecord +Clang USR: c:@S@alpah3 +Armor USR: c:@S@alpah3 +------------------------------------------- + +Declaration: x +Location: Line 10, Column 9 +Kind: Field +Clang USR: c:@S@alpah3@FI@x +Armor USR: c:@S@alpah3@FI@x +------------------------------------------- + +Declaration: alpha4 +Location: Line 11, Column 3 +Kind: Var +Clang USR: c:@alpha4 +Armor USR: c:@alpha4 +------------------------------------------- + +Declaration: +Location: Line 13, Column 1 +Kind: Enum +Clang USR: c:@E@armor_tag_anon.cpp@94 +Armor USR: c:@E@#vf#alpha_enum +------------------------------------------- + +Declaration: x +Location: Line 14, Column 5 +Kind: EnumConstant +Clang USR: c:@E@armor_tag_anon.cpp@94@x +Armor USR: c:@E@#vf#alpha_enum@x +------------------------------------------- + +Declaration: alpha_enum +Location: Line 15, Column 3 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@alpha_enum +Armor USR: c:@alpha_enum +------------------------------------------- + +Declaration: alpha_eum2 +Location: Line 17, Column 6 +Kind: Enum +Clang USR: c:@E@alpha_eum2 +Armor USR: c:@E@alpha_eum2 +------------------------------------------- + +Declaration: y +Location: Line 18, Column 5 +Kind: EnumConstant +Clang USR: c:@E@alpha_eum2@y +Armor USR: c:@E@alpha_eum2@y +------------------------------------------- + +Declaration: alpha_enum2 +Location: Line 19, Column 3 +Kind: Var +Clang USR: c:@alpha_enum2 +Armor USR: c:@alpha_enum2 +------------------------------------------- + +Declaration: alpha_eum3 +Location: Line 21, Column 6 +Kind: Enum +Clang USR: c:@E@alpha_eum3 +Armor USR: c:@E@alpha_eum3 +------------------------------------------- + +Declaration: z +Location: Line 22, Column 5 +Kind: EnumConstant +Clang USR: c:@E@alpha_eum3@z +Armor USR: c:@E@alpha_eum3@z +------------------------------------------- + +Declaration: alpha_enum4 +Location: Line 23, Column 3 +Kind: Var +Clang USR: c:@alpha_enum4 +Armor USR: c:@alpha_enum4 +------------------------------------------- + +Declaration: armor +Location: Line 26, Column 8 +Kind: CXXRecord +Clang USR: c:@S@armor +Armor USR: c:@S@armor +------------------------------------------- + +Declaration: +Location: Line 28, Column 5 +Kind: CXXRecord +Clang USR: c:@S@armor@Sa +Armor USR: c:@S@armor@Sa +------------------------------------------- + +Declaration: x +Location: Line 29, Column 13 +Kind: Field +Clang USR: c:@S@armor@Sa@FI@x +Armor USR: c:@S@armor@Sa@FI@x +------------------------------------------- + +Declaration: +Location: Line 30, Column 9 +Kind: CXXRecord +Clang USR: c:@S@armor@Sa@Sa +Armor USR: c:@S@armor@Sa@Sa +------------------------------------------- + +Declaration: y +Location: Line 31, Column 17 +Kind: Field +Clang USR: c:@S@armor@Sa@Sa@FI@y +Armor USR: c:@S@armor@Sa@Sa@FI@y +------------------------------------------- + +Declaration: +Location: Line 35, Column 5 +Kind: Enum +Clang USR: c:@S@armor@Ea@x1 +Armor USR: c:@S@armor@Ea +------------------------------------------- + +Declaration: x1 +Location: Line 36, Column 9 +Kind: EnumConstant +Clang USR: c:@S@armor@Ea@x1@x1 +Armor USR: c:@S@armor@Ea@x1 +------------------------------------------- + +Declaration: +Location: Line 39, Column 5 +Kind: Enum +Clang USR: c:@S@armor@Ea@y1 +Armor USR: c:@S@armor@Ea +------------------------------------------- + +Declaration: y1 +Location: Line 40, Column 9 +Kind: EnumConstant +Clang USR: c:@S@armor@Ea@y1@y1 +Armor USR: c:@S@armor@Ea@y1 +------------------------------------------- + +Declaration: +Location: Line 46, Column 1 +Kind: CXXRecord +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@366 +Armor USR: c:@S@#vf#field +------------------------------------------- + +Declaration: x +Location: Line 46, Column 14 +Kind: Field +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@366@FI@x +Armor USR: c:@S@#vf#field@FI@x +------------------------------------------- + +Declaration: field +Location: Line 46, Column 38 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@field +Armor USR: c:@field +------------------------------------------- + +Declaration: +Location: Line 48, Column 1 +Kind: CXXRecord +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@421 +Armor USR: c:@S@#vf#gamma +------------------------------------------- + +Declaration: y +Location: Line 48, Column 13 +Kind: Field +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@421@FI@y +Armor USR: c:@S@#vf#gamma@FI@y +------------------------------------------- + +Declaration: gamma +Location: Line 48, Column 21 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@gamma +Armor USR: c:@gamma +------------------------------------------- + +Declaration: SomeClass +Location: Line 50, Column 8 +Kind: CXXRecord +Clang USR: c:@S@SomeClass +Armor USR: c:@S@SomeClass +------------------------------------------- + +Declaration: +Location: Line 51, Column 1 +Kind: CXXRecord +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@471 +Armor USR: c:@S@#vf#class_member_ptr +------------------------------------------- + +Declaration: x +Location: Line 51, Column 14 +Kind: Field +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@471@FI@x +Armor USR: c:@S@#vf#class_member_ptr@FI@x +------------------------------------------- + +Declaration: class_member_ptr +Location: Line 51, Column 32 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@class_member_ptr +Armor USR: c:@class_member_ptr +------------------------------------------- + +Declaration: +Location: Line 53, Column 1 +Kind: Enum +Clang USR: c:@E@armor_tag_anon.cpp@521 +Armor USR: c:@E@#vf#beta +------------------------------------------- + +Declaration: I +Location: Line 53, Column 8 +Kind: EnumConstant +Clang USR: c:@E@armor_tag_anon.cpp@521@I +Armor USR: c:@E@#vf#beta@I +------------------------------------------- + +Declaration: beta +Location: Line 53, Column 35 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@beta +Armor USR: c:@beta +------------------------------------------- + +Declaration: +Location: Line 55, Column 1 +Kind: CXXRecord +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@572 +Armor USR: c:@S@#vf#zeta +------------------------------------------- + +Declaration: a +Location: Line 56, Column 7 +Kind: Field +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@572@FI@a +Armor USR: c:@S@#vf#zeta@FI@a +------------------------------------------- + +Declaration: zeta +Location: Line 57, Column 3 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@zeta +Armor USR: c:@zeta +------------------------------------------- + +Declaration: zeta +Location: Line 59, Column 8 +Kind: CXXRecord +Clang USR: c:@S@zeta +Armor USR: c:@S@zeta +------------------------------------------- + +Declaration: a +Location: Line 60, Column 7 +Kind: Field +Clang USR: c:@S@zeta@FI@a +Armor USR: c:@S@zeta@FI@a +------------------------------------------- + +Declaration: b +Location: Line 61, Column 7 +Kind: Field +Clang USR: c:@S@zeta@FI@b +Armor USR: c:@S@zeta@FI@b +------------------------------------------- + +Declaration: alpha1 +Location: Line 62, Column 3 +Kind: Var +Clang USR: c:@alpha1 +Armor USR: c:@alpha1 +------------------------------------------- + +Declaration: +Location: Line 64, Column 9 +Kind: CXXRecord +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@649 +Armor USR: c:@SA@alpha6 +------------------------------------------- + +Declaration: a +Location: Line 65, Column 7 +Kind: Field +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@649@FI@a +Armor USR: c:@SA@alpha6@FI@a +------------------------------------------- + +Declaration: b +Location: Line 66, Column 7 +Kind: Field +Clang USR: c:armor_tag_anon.cpp@S@armor_tag_anon.cpp@649@FI@b +Armor USR: c:@SA@alpha6@FI@b +------------------------------------------- + +Declaration: alpha6 +Location: Line 67, Column 23 +Kind: Typedef +Clang USR: c:armor_tag_anon.cpp@T@alpha6 +Armor USR: c:@T@alpha6 +------------------------------------------- + +Declaration: ok +Location: Line 69, Column 8 +Kind: Var +Clang USR: c:armor_tag_anon.cpp@ok +Armor USR: c:@ok +------------------------------------------- + +Declaration: +Location: Line 71, Column 9 +Kind: Enum +Clang USR: c:@E@armor_tag_anon.cpp@732 +Armor USR: c:@EA@alpha7 +------------------------------------------- + +Declaration: a +Location: Line 72, Column 3 +Kind: EnumConstant +Clang USR: c:@E@armor_tag_anon.cpp@732@a +Armor USR: c:@EA@alpha7@a +------------------------------------------- + +Declaration: b +Location: Line 73, Column 3 +Kind: EnumConstant +Clang USR: c:@E@armor_tag_anon.cpp@732@b +Armor USR: c:@EA@alpha7@b +------------------------------------------- + +Declaration: alpha7 +Location: Line 74, Column 23 +Kind: Typedef +Clang USR: c:armor_tag_anon.cpp@T@alpha7 +Armor USR: c:@T@alpha7 +------------------------------------------- + diff --git a/src/tests/common/unit/usr_generator/armor/armor_tag_anon/test_usr_tag_anon.py b/src/tests/common/unit/usr_generator/armor/armor_tag_anon/test_usr_tag_anon.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_tag_anon/test_usr_tag_anon.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/armor/armor_templets/armor_templets.cpp b/src/tests/common/unit/usr_generator/armor/armor_templets/armor_templets.cpp new file mode 100644 index 0000000..65298ec --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_templets/armor_templets.cpp @@ -0,0 +1,29 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include +#include +#include +#include +#include + +template +struct VariadicHolder { + std::tuple values; +}; + +VariadicHolder variadic_instance; + +template class OuterContainer, + template class InnerContainer> +struct ComplexWrapper { + OuterContainer, std::allocator>> nested; + OuterContainer simple; + typename OuterContainer::value_type value; + + template + using ContainerAlias = OuterContainer, std::allocator>>; + + ContainerAlias aliased; +}; + +ComplexWrapper complex_wrapper; diff --git a/src/tests/common/unit/usr_generator/armor/armor_templets/expected.txt b/src/tests/common/unit/usr_generator/armor/armor_templets/expected.txt new file mode 100644 index 0000000..74f131f --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_templets/expected.txt @@ -0,0 +1,91 @@ +Declaration: VariadicHolder +Location: Line 8, Column 8 +Kind: ClassTemplate +Armor USR: c:@ST>1#pT@VariadicHolder +Clang USR: c:@ST>1#pT@VariadicHolder +------------------------------------------- + +Declaration: VariadicHolder +Location: Line 8, Column 8 +Kind: CXXRecord +Armor USR: c:@ST>1#pT@VariadicHolder +Clang USR: c:@ST>1#pT@VariadicHolder +------------------------------------------- + +Declaration: values +Location: Line 9, Column 25 +Kind: Field +Armor USR: c:@ST>1#pT@VariadicHolder@FI@values +Clang USR: c:@ST>1#pT@VariadicHolder@FI@values +------------------------------------------- + +Declaration: variadic_instance +Location: Line 12, Column 42 +Kind: Var +Armor USR: c:@variadic_instance +Clang USR: c:@variadic_instance +------------------------------------------- + +Declaration: ComplexWrapper +Location: Line 16, Column 8 +Kind: ClassTemplate +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper +------------------------------------------- + +Declaration: ComplexWrapper +Location: Line 16, Column 8 +Kind: CXXRecord +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper +------------------------------------------- + +Declaration: nested +Location: Line 17, Column 94 +Kind: Field +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@nested +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@nested +------------------------------------------- + +Declaration: simple +Location: Line 18, Column 25 +Kind: Field +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@simple +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@simple +------------------------------------------- + +Declaration: value +Location: Line 19, Column 46 +Kind: Field +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@value +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@value +------------------------------------------- + +Declaration: ContainerAlias +Location: Line 22, Column 5 +Kind: TypeAliasTemplate +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@ContainerAlias +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@ContainerAlias +------------------------------------------- + +Declaration: ContainerAlias +Location: Line 22, Column 11 +Kind: TypeAlias +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@T@ContainerAlias +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@ContainerAlias +------------------------------------------- + +Declaration: aliased +Location: Line 24, Column 27 +Kind: Field +Armor USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@aliased +Clang USR: c:@ST>2#t>2#T#pT#t>2#T#pT@ComplexWrapper@FI@aliased +------------------------------------------- + +Declaration: complex_wrapper +Location: Line 27, Column 40 +Kind: Var +Armor USR: c:@complex_wrapper +Clang USR: c:@complex_wrapper +------------------------------------------- + diff --git a/src/tests/common/unit/usr_generator/armor/armor_templets/test_usr_templets.py b/src/tests/common/unit/usr_generator/armor/armor_templets/test_usr_templets.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_templets/test_usr_templets.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/armor/armor_type_alias/armor_type_alias.cpp b/src/tests/common/unit/usr_generator/armor/armor_type_alias/armor_type_alias.cpp new file mode 100644 index 0000000..7bc7888 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_type_alias/armor_type_alias.cpp @@ -0,0 +1,272 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +// ============================================================================= +// 1. PRIMITIVE TYPE ALIASES +// ============================================================================= + +using Byte = unsigned char; +using Int8 = signed char; +using Int16 = short; +using Int32 = int; +using Int64 = long long; +using UInt8 = unsigned char; +using UInt16 = unsigned short; +using UInt32 = unsigned int; +using UInt64 = unsigned long long; +using Float32 = float; +using Float64 = double; +using Char = char; +using Bool = bool; + +// ============================================================================= +// 2. CHAINED PRIMITIVE ALIASES (alias of alias of alias) +// ============================================================================= + +using Size = UInt64; // chain depth 1 +using Index = Size; // chain depth 2 +using Offset = Index; // chain depth 3 +using Handle = UInt32; // chain depth 1 +using SubHandle = Handle; // chain depth 2 +using Token = SubHandle; // chain depth 3 + +// ============================================================================= +// 3. POINTER & REFERENCE ALIASES +// ============================================================================= + +using BytePtr = Byte *; +using ConstBytePtr = const Byte *; +using Int32Ptr = Int32 *; +using Int32Ref = Int32 &; // reference alias +using VoidPtr = void *; +using ConstVoidPtr = const void *; + +// Chained pointer aliases +using RawBuffer = BytePtr; // alias of pointer alias +using ConstBuffer = ConstBytePtr; // alias of const-pointer alias +using BufferHandle = RawBuffer; // alias of alias of pointer alias + +// ============================================================================= +// 4. STD CONTAINER ALIASES (single-level) +// ============================================================================= + +using IntVec = std::vector; +using FloatVec = std::vector; +using DoubleVec = std::vector; +using StringVec = std::vector; +using ByteVec = std::vector; +using IntIntMap = std::map; +using StringIntMap = std::map; +using IntStringMap = std::map; +using StringStrMap = std::map; +using IntIntUMap = std::unordered_map; +using StrIntUMap = std::unordered_map; +using IntPair = std::pair; +using StrIntPair = std::pair; +using IntTriple = std::tuple; +using MixedTuple = std::tuple; +using IntArr4 = std::array; +using FloatArr3 = std::array; + +// ============================================================================= +// 5. CHAINED CONTAINER ALIASES (alias of alias) +// ============================================================================= + +using Row = IntVec; // chain depth 1 +using Matrix = std::vector; // container of aliased type +using Cube = std::vector; // container of container alias + +using Record = StringIntMap; // chain depth 1 +using RecordSet = std::vector; // container of aliased map +using RecordIndex = std::map; // map of aliased vector + +using Pair = IntPair; // chain depth 1 +using PairVec = std::vector; // container of aliased pair +using PairMap = std::map; // map with aliased value + +// ============================================================================= +// 6. NESTED CONTAINER ALIASES (containers of containers) +// ============================================================================= + +using VecOfVecInt = std::vector>; +using VecOfVecFloat = std::vector>; +using MapOfVecInt = std::map>; +using MapOfMapInt = std::map>; +using VecOfMapStrInt = std::vector>; +using UMapOfVecStr = std::unordered_map>; +using VecOfPair = std::vector>; +using MapOfTuple = std::map>; + +// Chained nested container aliases +using Grid = VecOfVecInt; // alias of nested container +using GridRow = IntVec; // alias of inner container +using SparseGrid = MapOfVecInt; // alias of map-of-vec +using SparseGridIndex = std::map;// map of aliased map-of-vec + +// ============================================================================= +// 7. SMART POINTER ALIASES +// ============================================================================= + +using IntShared = std::shared_ptr; +using IntUnique = std::unique_ptr; +using IntWeak = std::weak_ptr; +using VoidShared = std::shared_ptr; + +// Chained smart pointer aliases +using SharedInt = IntShared; // chain depth 1 +using SharedIntVec = std::vector; // container of aliased smart ptr +using SharedIntMap = std::map; // map of aliased smart ptr + +// ============================================================================= +// 8. FUNCTION / CALLABLE ALIASES +// ============================================================================= + +using VoidFn = std::function; +using IntFn = std::function; +using IntIntFn = std::function; +using IntIntIntFn = std::function; +using BoolIntFn = std::function; +using VoidIntFn = std::function; +using VoidStrFn = std::function; +using StrStrFn = std::function; + +// Function aliases using aliased types +using SizeFn = std::function; // uses primitive alias +using IndexMapFn = std::function; // uses chained alias +using RowTransformFn = std::function; // uses container alias +using MatrixFn = std::function; // uses chained container alias + +// Chained function aliases +using Callback = VoidFn; // chain depth 1 +using EventHandler = Callback; // chain depth 2 +using SignalHandler = EventHandler; // chain depth 3 + +using Predicate = BoolIntFn; // chain depth 1 +using Filter = Predicate; // chain depth 2 + +using Transformer = IntIntFn; // chain depth 1 +using Mapper = Transformer; // chain depth 2 +using Reducer = Mapper; // chain depth 3 + +// ============================================================================= +// 9. TEMPLATE TYPE ALIAS (alias templates) +// ============================================================================= + +template +using Vec = std::vector; + +template +using Ptr = std::shared_ptr; + +template +using UniquePtr = std::unique_ptr; + +template +using Dict = std::map; + +template +using HashMap = std::unordered_map; + +template +using Opt = std::pair; // lightweight optional-like + +template +using Grid2D = std::vector>; + +template +using Grid3D = std::vector>; // chained template alias + +template +using MultiDict = std::map>; + +template +using Fn = std::function; // generic callable alias + +template +using PtrVec = Vec>; // chained template aliases + +template +using PtrDict = Dict>; // chained template aliases + +// ============================================================================= +// 10. COMBINATIONS: MIXING PRIMITIVE, CONTAINER, SMART-PTR, FUNCTION ALIASES +// ============================================================================= + +// Primitive alias inside containers +using IndexVec = Vec; // template alias + chained primitive +using HandleMap = Dict; // template alias + chained primitives +using TokenSet = std::vector; // container of depth-3 chained alias + +// Smart pointer of aliased container +using SharedRow = Ptr; // smart ptr of container alias +using SharedMatrix = Ptr; // smart ptr of chained container alias +using UniqueGrid = UniquePtr; // unique ptr of aliased nested container + +// Container of smart pointers of aliased types +using SharedRowVec = Vec; // vec of (shared ptr of alias) +using SharedMatrixVec = Vec; // vec of (shared ptr of chained alias) + +// Function aliases using template aliases +using IndexTransform = Fn; // template fn alias + chained primitive +using RowFn = Fn; // template fn alias + container alias +using MatrixBuilder = Fn; // template fn alias + chained container +using GridReducer = Fn; // template fn alias + nested alias + +// Map of function aliases +using CallbackMap = Dict; // map of chained fn alias +using HandlerRegistry = HashMap; // hashmap of depth-2 fn alias + +// Tuple combining aliased types +using RecordTuple = std::tuple; // tuple of mixed aliases +using FullRecord = std::tuple; // tuple of depth-3 aliases + +// ============================================================================= +// 11. DEEP CHAINING (5+ levels) +// ============================================================================= + +// Primitive chain +using L1 = int; +using L2 = L1; +using L3 = L2; +using L4 = L3; +using L5 = L4; +using L6 = L5; + +// Container chain +using C1 = std::vector; +using C2 = C1; +using C3 = C2; +using C4 = C3; +using C5 = C4; + +// Function chain +using F1 = std::function; +using F2 = F1; +using F3 = F2; +using F4 = F3; +using F5 = F4; + +// Smart pointer chain +using S1 = std::shared_ptr; +using S2 = S1; +using S3 = S2; +using S4 = S3; +using S5 = S4; + +// Cross-kind chaining: primitive -> container -> smart ptr -> function +using XBase = UInt32; // primitive alias +using XVec = std::vector; // container of primitive alias +using XShared = std::shared_ptr; // smart ptr of container alias +using XFn = std::function; // function using smart ptr + primitive alias +using XCallback = XFn; // alias of cross-kind chain +using XHandler = XCallback; // alias of alias of cross-kind chain diff --git a/src/tests/common/unit/usr_generator/armor/armor_type_alias/expected.txt b/src/tests/common/unit/usr_generator/armor/armor_type_alias/expected.txt new file mode 100644 index 0000000..aeabf33 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_type_alias/expected.txt @@ -0,0 +1,1232 @@ +Declaration: Byte +Location: Line 16, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Byte +Clang USR: c:@Byte +------------------------------------------- + +Declaration: Int8 +Location: Line 17, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Int8 +Clang USR: c:@Int8 +------------------------------------------- + +Declaration: Int16 +Location: Line 18, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Int16 +Clang USR: c:@Int16 +------------------------------------------- + +Declaration: Int32 +Location: Line 19, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Int32 +Clang USR: c:@Int32 +------------------------------------------- + +Declaration: Int64 +Location: Line 20, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Int64 +Clang USR: c:@Int64 +------------------------------------------- + +Declaration: UInt8 +Location: Line 21, Column 7 +Kind: TypeAlias +Armor USR: c:@T@UInt8 +Clang USR: c:@UInt8 +------------------------------------------- + +Declaration: UInt16 +Location: Line 22, Column 7 +Kind: TypeAlias +Armor USR: c:@T@UInt16 +Clang USR: c:@UInt16 +------------------------------------------- + +Declaration: UInt32 +Location: Line 23, Column 7 +Kind: TypeAlias +Armor USR: c:@T@UInt32 +Clang USR: c:@UInt32 +------------------------------------------- + +Declaration: UInt64 +Location: Line 24, Column 7 +Kind: TypeAlias +Armor USR: c:@T@UInt64 +Clang USR: c:@UInt64 +------------------------------------------- + +Declaration: Float32 +Location: Line 25, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Float32 +Clang USR: c:@Float32 +------------------------------------------- + +Declaration: Float64 +Location: Line 26, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Float64 +Clang USR: c:@Float64 +------------------------------------------- + +Declaration: Char +Location: Line 27, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Char +Clang USR: c:@Char +------------------------------------------- + +Declaration: Bool +Location: Line 28, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Bool +Clang USR: c:@Bool +------------------------------------------- + +Declaration: Size +Location: Line 34, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Size +Clang USR: c:@Size +------------------------------------------- + +Declaration: Index +Location: Line 35, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Index +Clang USR: c:@Index +------------------------------------------- + +Declaration: Offset +Location: Line 36, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Offset +Clang USR: c:@Offset +------------------------------------------- + +Declaration: Handle +Location: Line 37, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Handle +Clang USR: c:@Handle +------------------------------------------- + +Declaration: SubHandle +Location: Line 38, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SubHandle +Clang USR: c:@SubHandle +------------------------------------------- + +Declaration: Token +Location: Line 39, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Token +Clang USR: c:@Token +------------------------------------------- + +Declaration: BytePtr +Location: Line 45, Column 7 +Kind: TypeAlias +Armor USR: c:@T@BytePtr +Clang USR: c:@BytePtr +------------------------------------------- + +Declaration: ConstBytePtr +Location: Line 46, Column 7 +Kind: TypeAlias +Armor USR: c:@T@ConstBytePtr +Clang USR: c:@ConstBytePtr +------------------------------------------- + +Declaration: Int32Ptr +Location: Line 47, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Int32Ptr +Clang USR: c:@Int32Ptr +------------------------------------------- + +Declaration: Int32Ref +Location: Line 48, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Int32Ref +Clang USR: c:@Int32Ref +------------------------------------------- + +Declaration: VoidPtr +Location: Line 49, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VoidPtr +Clang USR: c:@VoidPtr +------------------------------------------- + +Declaration: ConstVoidPtr +Location: Line 50, Column 7 +Kind: TypeAlias +Armor USR: c:@T@ConstVoidPtr +Clang USR: c:@ConstVoidPtr +------------------------------------------- + +Declaration: RawBuffer +Location: Line 53, Column 7 +Kind: TypeAlias +Armor USR: c:@T@RawBuffer +Clang USR: c:@RawBuffer +------------------------------------------- + +Declaration: ConstBuffer +Location: Line 54, Column 7 +Kind: TypeAlias +Armor USR: c:@T@ConstBuffer +Clang USR: c:@ConstBuffer +------------------------------------------- + +Declaration: BufferHandle +Location: Line 55, Column 7 +Kind: TypeAlias +Armor USR: c:@T@BufferHandle +Clang USR: c:@BufferHandle +------------------------------------------- + +Declaration: IntVec +Location: Line 61, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntVec +Clang USR: c:@IntVec +------------------------------------------- + +Declaration: FloatVec +Location: Line 62, Column 7 +Kind: TypeAlias +Armor USR: c:@T@FloatVec +Clang USR: c:@FloatVec +------------------------------------------- + +Declaration: DoubleVec +Location: Line 63, Column 7 +Kind: TypeAlias +Armor USR: c:@T@DoubleVec +Clang USR: c:@DoubleVec +------------------------------------------- + +Declaration: StringVec +Location: Line 64, Column 7 +Kind: TypeAlias +Armor USR: c:@T@StringVec +Clang USR: c:@StringVec +------------------------------------------- + +Declaration: ByteVec +Location: Line 65, Column 7 +Kind: TypeAlias +Armor USR: c:@T@ByteVec +Clang USR: c:@ByteVec +------------------------------------------- + +Declaration: IntIntMap +Location: Line 66, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntIntMap +Clang USR: c:@IntIntMap +------------------------------------------- + +Declaration: StringIntMap +Location: Line 67, Column 7 +Kind: TypeAlias +Armor USR: c:@T@StringIntMap +Clang USR: c:@StringIntMap +------------------------------------------- + +Declaration: IntStringMap +Location: Line 68, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntStringMap +Clang USR: c:@IntStringMap +------------------------------------------- + +Declaration: StringStrMap +Location: Line 69, Column 7 +Kind: TypeAlias +Armor USR: c:@T@StringStrMap +Clang USR: c:@StringStrMap +------------------------------------------- + +Declaration: IntIntUMap +Location: Line 70, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntIntUMap +Clang USR: c:@IntIntUMap +------------------------------------------- + +Declaration: StrIntUMap +Location: Line 71, Column 7 +Kind: TypeAlias +Armor USR: c:@T@StrIntUMap +Clang USR: c:@StrIntUMap +------------------------------------------- + +Declaration: IntPair +Location: Line 72, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntPair +Clang USR: c:@IntPair +------------------------------------------- + +Declaration: StrIntPair +Location: Line 73, Column 7 +Kind: TypeAlias +Armor USR: c:@T@StrIntPair +Clang USR: c:@StrIntPair +------------------------------------------- + +Declaration: IntTriple +Location: Line 74, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntTriple +Clang USR: c:@IntTriple +------------------------------------------- + +Declaration: MixedTuple +Location: Line 75, Column 7 +Kind: TypeAlias +Armor USR: c:@T@MixedTuple +Clang USR: c:@MixedTuple +------------------------------------------- + +Declaration: IntArr4 +Location: Line 76, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntArr4 +Clang USR: c:@IntArr4 +------------------------------------------- + +Declaration: FloatArr3 +Location: Line 77, Column 7 +Kind: TypeAlias +Armor USR: c:@T@FloatArr3 +Clang USR: c:@FloatArr3 +------------------------------------------- + +Declaration: Row +Location: Line 83, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Row +Clang USR: c:@Row +------------------------------------------- + +Declaration: Matrix +Location: Line 84, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Matrix +Clang USR: c:@Matrix +------------------------------------------- + +Declaration: Cube +Location: Line 85, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Cube +Clang USR: c:@Cube +------------------------------------------- + +Declaration: Record +Location: Line 87, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Record +Clang USR: c:@Record +------------------------------------------- + +Declaration: RecordSet +Location: Line 88, Column 7 +Kind: TypeAlias +Armor USR: c:@T@RecordSet +Clang USR: c:@RecordSet +------------------------------------------- + +Declaration: RecordIndex +Location: Line 89, Column 7 +Kind: TypeAlias +Armor USR: c:@T@RecordIndex +Clang USR: c:@RecordIndex +------------------------------------------- + +Declaration: Pair +Location: Line 91, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Pair +Clang USR: c:@Pair +------------------------------------------- + +Declaration: PairVec +Location: Line 92, Column 7 +Kind: TypeAlias +Armor USR: c:@T@PairVec +Clang USR: c:@PairVec +------------------------------------------- + +Declaration: PairMap +Location: Line 93, Column 7 +Kind: TypeAlias +Armor USR: c:@T@PairMap +Clang USR: c:@PairMap +------------------------------------------- + +Declaration: VecOfVecInt +Location: Line 99, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VecOfVecInt +Clang USR: c:@VecOfVecInt +------------------------------------------- + +Declaration: VecOfVecFloat +Location: Line 100, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VecOfVecFloat +Clang USR: c:@VecOfVecFloat +------------------------------------------- + +Declaration: MapOfVecInt +Location: Line 101, Column 7 +Kind: TypeAlias +Armor USR: c:@T@MapOfVecInt +Clang USR: c:@MapOfVecInt +------------------------------------------- + +Declaration: MapOfMapInt +Location: Line 102, Column 7 +Kind: TypeAlias +Armor USR: c:@T@MapOfMapInt +Clang USR: c:@MapOfMapInt +------------------------------------------- + +Declaration: VecOfMapStrInt +Location: Line 103, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VecOfMapStrInt +Clang USR: c:@VecOfMapStrInt +------------------------------------------- + +Declaration: UMapOfVecStr +Location: Line 104, Column 7 +Kind: TypeAlias +Armor USR: c:@T@UMapOfVecStr +Clang USR: c:@UMapOfVecStr +------------------------------------------- + +Declaration: VecOfPair +Location: Line 105, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VecOfPair +Clang USR: c:@VecOfPair +------------------------------------------- + +Declaration: MapOfTuple +Location: Line 106, Column 7 +Kind: TypeAlias +Armor USR: c:@T@MapOfTuple +Clang USR: c:@MapOfTuple +------------------------------------------- + +Declaration: Grid +Location: Line 109, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Grid +Clang USR: c:@Grid +------------------------------------------- + +Declaration: GridRow +Location: Line 110, Column 7 +Kind: TypeAlias +Armor USR: c:@T@GridRow +Clang USR: c:@GridRow +------------------------------------------- + +Declaration: SparseGrid +Location: Line 111, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SparseGrid +Clang USR: c:@SparseGrid +------------------------------------------- + +Declaration: SparseGridIndex +Location: Line 112, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SparseGridIndex +Clang USR: c:@SparseGridIndex +------------------------------------------- + +Declaration: IntShared +Location: Line 118, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntShared +Clang USR: c:@IntShared +------------------------------------------- + +Declaration: IntUnique +Location: Line 119, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntUnique +Clang USR: c:@IntUnique +------------------------------------------- + +Declaration: IntWeak +Location: Line 120, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntWeak +Clang USR: c:@IntWeak +------------------------------------------- + +Declaration: VoidShared +Location: Line 121, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VoidShared +Clang USR: c:@VoidShared +------------------------------------------- + +Declaration: SharedInt +Location: Line 124, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SharedInt +Clang USR: c:@SharedInt +------------------------------------------- + +Declaration: SharedIntVec +Location: Line 125, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SharedIntVec +Clang USR: c:@SharedIntVec +------------------------------------------- + +Declaration: SharedIntMap +Location: Line 126, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SharedIntMap +Clang USR: c:@SharedIntMap +------------------------------------------- + +Declaration: VoidFn +Location: Line 132, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VoidFn +Clang USR: c:@VoidFn +------------------------------------------- + +Declaration: IntFn +Location: Line 133, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntFn +Clang USR: c:@IntFn +------------------------------------------- + +Declaration: IntIntFn +Location: Line 134, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntIntFn +Clang USR: c:@IntIntFn +------------------------------------------- + +Declaration: +Location: Line 134, Column 48 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: IntIntIntFn +Location: Line 135, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IntIntIntFn +Clang USR: c:@IntIntIntFn +------------------------------------------- + +Declaration: +Location: Line 135, Column 48 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: +Location: Line 135, Column 53 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: BoolIntFn +Location: Line 136, Column 7 +Kind: TypeAlias +Armor USR: c:@T@BoolIntFn +Clang USR: c:@BoolIntFn +------------------------------------------- + +Declaration: +Location: Line 136, Column 49 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: VoidIntFn +Location: Line 137, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VoidIntFn +Clang USR: c:@VoidIntFn +------------------------------------------- + +Declaration: +Location: Line 137, Column 49 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: VoidStrFn +Location: Line 138, Column 7 +Kind: TypeAlias +Armor USR: c:@T@VoidStrFn +Clang USR: c:@VoidStrFn +------------------------------------------- + +Declaration: +Location: Line 138, Column 57 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: StrStrFn +Location: Line 139, Column 7 +Kind: TypeAlias +Armor USR: c:@T@StrStrFn +Clang USR: c:@StrStrFn +------------------------------------------- + +Declaration: +Location: Line 139, Column 64 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: SizeFn +Location: Line 142, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SizeFn +Clang USR: c:@SizeFn +------------------------------------------- + +Declaration: IndexMapFn +Location: Line 143, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IndexMapFn +Clang USR: c:@IndexMapFn +------------------------------------------- + +Declaration: +Location: Line 143, Column 52 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: RowTransformFn +Location: Line 144, Column 7 +Kind: TypeAlias +Armor USR: c:@T@RowTransformFn +Clang USR: c:@RowTransformFn +------------------------------------------- + +Declaration: +Location: Line 144, Column 48 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: MatrixFn +Location: Line 145, Column 7 +Kind: TypeAlias +Armor USR: c:@T@MatrixFn +Clang USR: c:@MatrixFn +------------------------------------------- + +Declaration: +Location: Line 145, Column 54 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: Callback +Location: Line 148, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Callback +Clang USR: c:@Callback +------------------------------------------- + +Declaration: EventHandler +Location: Line 149, Column 7 +Kind: TypeAlias +Armor USR: c:@T@EventHandler +Clang USR: c:@EventHandler +------------------------------------------- + +Declaration: SignalHandler +Location: Line 150, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SignalHandler +Clang USR: c:@SignalHandler +------------------------------------------- + +Declaration: Predicate +Location: Line 152, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Predicate +Clang USR: c:@Predicate +------------------------------------------- + +Declaration: Filter +Location: Line 153, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Filter +Clang USR: c:@Filter +------------------------------------------- + +Declaration: Transformer +Location: Line 155, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Transformer +Clang USR: c:@Transformer +------------------------------------------- + +Declaration: Mapper +Location: Line 156, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Mapper +Clang USR: c:@Mapper +------------------------------------------- + +Declaration: Reducer +Location: Line 157, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Reducer +Clang USR: c:@Reducer +------------------------------------------- + +Declaration: Vec +Location: Line 164, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@Vec +Clang USR: c:@Vec +------------------------------------------- + +Declaration: Vec +Location: Line 164, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Vec +Clang USR: c:@Vec +------------------------------------------- + +Declaration: Ptr +Location: Line 167, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@Ptr +Clang USR: c:@Ptr +------------------------------------------- + +Declaration: Ptr +Location: Line 167, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Ptr +Clang USR: c:@Ptr +------------------------------------------- + +Declaration: UniquePtr +Location: Line 170, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@UniquePtr +Clang USR: c:@UniquePtr +------------------------------------------- + +Declaration: UniquePtr +Location: Line 170, Column 7 +Kind: TypeAlias +Armor USR: c:@T@UniquePtr +Clang USR: c:@UniquePtr +------------------------------------------- + +Declaration: Dict +Location: Line 173, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@Dict +Clang USR: c:@Dict +------------------------------------------- + +Declaration: Dict +Location: Line 173, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Dict +Clang USR: c:@Dict +------------------------------------------- + +Declaration: HashMap +Location: Line 176, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@HashMap +Clang USR: c:@HashMap +------------------------------------------- + +Declaration: HashMap +Location: Line 176, Column 7 +Kind: TypeAlias +Armor USR: c:@T@HashMap +Clang USR: c:@HashMap +------------------------------------------- + +Declaration: Opt +Location: Line 179, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@Opt +Clang USR: c:@Opt +------------------------------------------- + +Declaration: Opt +Location: Line 179, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Opt +Clang USR: c:@Opt +------------------------------------------- + +Declaration: Grid2D +Location: Line 182, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@Grid2D +Clang USR: c:@Grid2D +------------------------------------------- + +Declaration: Grid2D +Location: Line 182, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Grid2D +Clang USR: c:@Grid2D +------------------------------------------- + +Declaration: Grid3D +Location: Line 185, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@Grid3D +Clang USR: c:@Grid3D +------------------------------------------- + +Declaration: Grid3D +Location: Line 185, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Grid3D +Clang USR: c:@Grid3D +------------------------------------------- + +Declaration: MultiDict +Location: Line 188, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@MultiDict +Clang USR: c:@MultiDict +------------------------------------------- + +Declaration: MultiDict +Location: Line 188, Column 7 +Kind: TypeAlias +Armor USR: c:@T@MultiDict +Clang USR: c:@MultiDict +------------------------------------------- + +Declaration: Fn +Location: Line 191, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@Fn +Clang USR: c:@Fn +------------------------------------------- + +Declaration: Fn +Location: Line 191, Column 7 +Kind: TypeAlias +Armor USR: c:@T@Fn +Clang USR: c:@Fn +------------------------------------------- + +Declaration: PtrVec +Location: Line 194, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@PtrVec +Clang USR: c:@PtrVec +------------------------------------------- + +Declaration: PtrVec +Location: Line 194, Column 7 +Kind: TypeAlias +Armor USR: c:@T@PtrVec +Clang USR: c:@PtrVec +------------------------------------------- + +Declaration: PtrDict +Location: Line 197, Column 1 +Kind: TypeAliasTemplate +Armor USR: c:@PtrDict +Clang USR: c:@PtrDict +------------------------------------------- + +Declaration: PtrDict +Location: Line 197, Column 7 +Kind: TypeAlias +Armor USR: c:@T@PtrDict +Clang USR: c:@PtrDict +------------------------------------------- + +Declaration: IndexVec +Location: Line 204, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IndexVec +Clang USR: c:@IndexVec +------------------------------------------- + +Declaration: HandleMap +Location: Line 205, Column 7 +Kind: TypeAlias +Armor USR: c:@T@HandleMap +Clang USR: c:@HandleMap +------------------------------------------- + +Declaration: TokenSet +Location: Line 206, Column 7 +Kind: TypeAlias +Armor USR: c:@T@TokenSet +Clang USR: c:@TokenSet +------------------------------------------- + +Declaration: SharedRow +Location: Line 209, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SharedRow +Clang USR: c:@SharedRow +------------------------------------------- + +Declaration: SharedMatrix +Location: Line 210, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SharedMatrix +Clang USR: c:@SharedMatrix +------------------------------------------- + +Declaration: UniqueGrid +Location: Line 211, Column 7 +Kind: TypeAlias +Armor USR: c:@T@UniqueGrid +Clang USR: c:@UniqueGrid +------------------------------------------- + +Declaration: SharedRowVec +Location: Line 214, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SharedRowVec +Clang USR: c:@SharedRowVec +------------------------------------------- + +Declaration: SharedMatrixVec +Location: Line 215, Column 7 +Kind: TypeAlias +Armor USR: c:@T@SharedMatrixVec +Clang USR: c:@SharedMatrixVec +------------------------------------------- + +Declaration: IndexTransform +Location: Line 218, Column 7 +Kind: TypeAlias +Armor USR: c:@T@IndexTransform +Clang USR: c:@IndexTransform +------------------------------------------- + +Declaration: +Location: Line 218, Column 41 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: RowFn +Location: Line 219, Column 7 +Kind: TypeAlias +Armor USR: c:@T@RowFn +Clang USR: c:@RowFn +------------------------------------------- + +Declaration: +Location: Line 219, Column 37 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: MatrixBuilder +Location: Line 220, Column 7 +Kind: TypeAlias +Armor USR: c:@T@MatrixBuilder +Clang USR: c:@MatrixBuilder +------------------------------------------- + +Declaration: GridReducer +Location: Line 221, Column 7 +Kind: TypeAlias +Armor USR: c:@T@GridReducer +Clang USR: c:@GridReducer +------------------------------------------- + +Declaration: +Location: Line 221, Column 39 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: +Location: Line 221, Column 45 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: CallbackMap +Location: Line 224, Column 7 +Kind: TypeAlias +Armor USR: c:@T@CallbackMap +Clang USR: c:@CallbackMap +------------------------------------------- + +Declaration: HandlerRegistry +Location: Line 225, Column 7 +Kind: TypeAlias +Armor USR: c:@T@HandlerRegistry +Clang USR: c:@HandlerRegistry +------------------------------------------- + +Declaration: RecordTuple +Location: Line 228, Column 7 +Kind: TypeAlias +Armor USR: c:@T@RecordTuple +Clang USR: c:@RecordTuple +------------------------------------------- + +Declaration: FullRecord +Location: Line 229, Column 7 +Kind: TypeAlias +Armor USR: c:@T@FullRecord +Clang USR: c:@FullRecord +------------------------------------------- + +Declaration: L1 +Location: Line 236, Column 7 +Kind: TypeAlias +Armor USR: c:@T@L1 +Clang USR: c:@L1 +------------------------------------------- + +Declaration: L2 +Location: Line 237, Column 7 +Kind: TypeAlias +Armor USR: c:@T@L2 +Clang USR: c:@L2 +------------------------------------------- + +Declaration: L3 +Location: Line 238, Column 7 +Kind: TypeAlias +Armor USR: c:@T@L3 +Clang USR: c:@L3 +------------------------------------------- + +Declaration: L4 +Location: Line 239, Column 7 +Kind: TypeAlias +Armor USR: c:@T@L4 +Clang USR: c:@L4 +------------------------------------------- + +Declaration: L5 +Location: Line 240, Column 7 +Kind: TypeAlias +Armor USR: c:@T@L5 +Clang USR: c:@L5 +------------------------------------------- + +Declaration: L6 +Location: Line 241, Column 7 +Kind: TypeAlias +Armor USR: c:@T@L6 +Clang USR: c:@L6 +------------------------------------------- + +Declaration: C1 +Location: Line 244, Column 7 +Kind: TypeAlias +Armor USR: c:@T@C1 +Clang USR: c:@C1 +------------------------------------------- + +Declaration: C2 +Location: Line 245, Column 7 +Kind: TypeAlias +Armor USR: c:@T@C2 +Clang USR: c:@C2 +------------------------------------------- + +Declaration: C3 +Location: Line 246, Column 7 +Kind: TypeAlias +Armor USR: c:@T@C3 +Clang USR: c:@C3 +------------------------------------------- + +Declaration: C4 +Location: Line 247, Column 7 +Kind: TypeAlias +Armor USR: c:@T@C4 +Clang USR: c:@C4 +------------------------------------------- + +Declaration: C5 +Location: Line 248, Column 7 +Kind: TypeAlias +Armor USR: c:@T@C5 +Clang USR: c:@C5 +------------------------------------------- + +Declaration: F1 +Location: Line 251, Column 7 +Kind: TypeAlias +Armor USR: c:@T@F1 +Clang USR: c:@F1 +------------------------------------------- + +Declaration: +Location: Line 251, Column 34 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: F2 +Location: Line 252, Column 7 +Kind: TypeAlias +Armor USR: c:@T@F2 +Clang USR: c:@F2 +------------------------------------------- + +Declaration: F3 +Location: Line 253, Column 7 +Kind: TypeAlias +Armor USR: c:@T@F3 +Clang USR: c:@F3 +------------------------------------------- + +Declaration: F4 +Location: Line 254, Column 7 +Kind: TypeAlias +Armor USR: c:@T@F4 +Clang USR: c:@F4 +------------------------------------------- + +Declaration: F5 +Location: Line 255, Column 7 +Kind: TypeAlias +Armor USR: c:@T@F5 +Clang USR: c:@F5 +------------------------------------------- + +Declaration: S1 +Location: Line 258, Column 7 +Kind: TypeAlias +Armor USR: c:@T@S1 +Clang USR: c:@S1 +------------------------------------------- + +Declaration: S2 +Location: Line 259, Column 7 +Kind: TypeAlias +Armor USR: c:@T@S2 +Clang USR: c:@S2 +------------------------------------------- + +Declaration: S3 +Location: Line 260, Column 7 +Kind: TypeAlias +Armor USR: c:@T@S3 +Clang USR: c:@S3 +------------------------------------------- + +Declaration: S4 +Location: Line 261, Column 7 +Kind: TypeAlias +Armor USR: c:@T@S4 +Clang USR: c:@S4 +------------------------------------------- + +Declaration: S5 +Location: Line 262, Column 7 +Kind: TypeAlias +Armor USR: c:@T@S5 +Clang USR: c:@S5 +------------------------------------------- + +Declaration: XBase +Location: Line 265, Column 7 +Kind: TypeAlias +Armor USR: c:@T@XBase +Clang USR: c:@XBase +------------------------------------------- + +Declaration: XVec +Location: Line 266, Column 7 +Kind: TypeAlias +Armor USR: c:@T@XVec +Clang USR: c:@XVec +------------------------------------------- + +Declaration: XShared +Location: Line 267, Column 7 +Kind: TypeAlias +Armor USR: c:@T@XShared +Clang USR: c:@XShared +------------------------------------------- + +Declaration: XFn +Location: Line 268, Column 7 +Kind: TypeAlias +Armor USR: c:@T@XFn +Clang USR: c:@XFn +------------------------------------------- + +Declaration: +Location: Line 268, Column 46 +Kind: ParmVar +Armor USR: ERROR +Clang USR: ERROR +------------------------------------------- + +Declaration: XCallback +Location: Line 269, Column 7 +Kind: TypeAlias +Armor USR: c:@T@XCallback +Clang USR: c:@XCallback +------------------------------------------- + +Declaration: XHandler +Location: Line 270, Column 7 +Kind: TypeAlias +Armor USR: c:@T@XHandler +Clang USR: c:@XHandler +------------------------------------------- + diff --git a/src/tests/common/unit/usr_generator/armor/armor_type_alias/test_usr_type_alias.py b/src/tests/common/unit/usr_generator/armor/armor_type_alias/test_usr_type_alias.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/armor_type_alias/test_usr_type_alias.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/armor/conftest.py b/src/tests/common/unit/usr_generator/armor/conftest.py new file mode 100644 index 0000000..bf203a8 --- /dev/null +++ b/src/tests/common/unit/usr_generator/armor/conftest.py @@ -0,0 +1,34 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import glob +import pytest + +def find_path_from_project_root(marker): + while True: + current = os.getcwd() + if os.path.exists(os.path.join(current, marker)): + return os.path.join(current, marker) + parent = os.path.dirname(current) + if parent == current: + break # Reached the filesystem root + os.chdir(parent) + raise RuntimeError(f"Project root with marker '{marker}' not found.") + +def get_build_dir(): + return find_path_from_project_root("build") + +@pytest.fixture +def binary_path(): + """Returns the absolute path to the binary.""" + return os.path.join(get_build_dir(), "src/tests/common/unit/usr_generator/usr_generator_debug") + +@pytest.fixture +def get_cpp_files(request): + curr_dir = os.path.dirname(request.fspath) + return glob.glob(os.path.join(curr_dir, "*.cpp")) + +@pytest.fixture +def binary_args(request): + """Returns the arguments for the binary with debug and JSON output enabled.""" + return ["output.txt"] diff --git a/src/tests/common/unit/usr_generator/llvm/conftest.py b/src/tests/common/unit/usr_generator/llvm/conftest.py new file mode 100644 index 0000000..f14c650 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/conftest.py @@ -0,0 +1,34 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import glob +import pytest + +def find_path_from_project_root(marker): + while True: + current = os.getcwd() + if os.path.exists(os.path.join(current, marker)): + return os.path.join(current, marker) + parent = os.path.dirname(current) + if parent == current: + break # Reached the filesystem root + os.chdir(parent) + raise RuntimeError(f"Project root with marker '{marker}' not found.") + +def get_build_dir(): + return find_path_from_project_root("build") + +@pytest.fixture +def binary_path(): + """Returns the absolute path to the binary.""" + return os.path.join(get_build_dir(), "src/tests/common/unit/usr_generator/usr_generator_debug") + +@pytest.fixture +def get_cpp_files(request): + curr_dir = os.path.dirname(request.fspath) + return glob.glob(os.path.join(curr_dir, "*.cpp")) + +@pytest.fixture +def binary_args(request): + """Returns the arguments for the binary with debug and JSON output enabled.""" + return ["output.txt","true"] diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_array_type/array-type.cpp b/src/tests/common/unit/usr_generator/llvm/llvm_array_type/array-type.cpp new file mode 100644 index 0000000..b2f58fc --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_array_type/array-type.cpp @@ -0,0 +1,13 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s + +// Function template specializations differing in array type parameter should have unique USRs. + +template void foo(buffer); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# +template<> void foo(char[16]); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# +template<> void foo(char[32]); +// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# +template<> void foo(char[64]); \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_array_type/expected.txt b/src/tests/common/unit/usr_generator/llvm/llvm_array_type/expected.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_array_type/test_usr_array_type.py b/src/tests/common/unit/usr_generator/llvm/llvm_array_type/test_usr_array_type.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_array_type/test_usr_array_type.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_func_type/expected.txt b/src/tests/common/unit/usr_generator/llvm/llvm_func_type/expected.txt new file mode 100644 index 0000000..f733fcd --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_func_type/expected.txt @@ -0,0 +1,27 @@ +Declaration: _VoidToVoidPtr_ +Location: Line 5, Column 16 +Kind: Typedef +Clang USR: c:func-type.cpp@T@_VoidToVoidPtr_ +Armor USR: c:@T@_VoidToVoidPtr_ +------------------------------------------- + +Declaration: _IntToVoidPtr_ +Location: Line 6, Column 16 +Kind: Typedef +Clang USR: c:func-type.cpp@T@_IntToVoidPtr_ +Armor USR: c:@T@_IntToVoidPtr_ +------------------------------------------- + +Declaration: IntTo_VoidToVoidPtr_Ptr +Location: Line 7, Column 27 +Kind: Typedef +Clang USR: c:func-type.cpp@T@IntTo_VoidToVoidPtr_Ptr +Armor USR: c:@T@IntTo_VoidToVoidPtr_Ptr +------------------------------------------- + +Declaration: VoidTo_IntToVoidPtr_Ptr +Location: Line 8, Column 26 +Kind: Typedef +Clang USR: c:func-type.cpp@T@VoidTo_IntToVoidPtr_Ptr +Armor USR: c:@T@VoidTo_IntToVoidPtr_Ptr +------------------------------------------- diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_func_type/func-type.cpp b/src/tests/common/unit/usr_generator/llvm/llvm_func_type/func-type.cpp new file mode 100644 index 0000000..5d3a91f --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_func_type/func-type.cpp @@ -0,0 +1,20 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s + +// Functions taking function pointer parameters with different signatures should result in unique USRs. + +typedef void (*_VoidToVoidPtr_)(); +typedef void (*_IntToVoidPtr_)( int ); +typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int ); +typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)(); + +void Func( IntTo_VoidToVoidPtr_Ptr ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# | +void Func( VoidTo_IntToVoidPtr_Ptr ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# | + +void Func( void (* (*)(int, int))(int, int) ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# | +void Func( void (* (*)(int, int, int))(int) ); +// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# | \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_func_type/test_usr_func_type.py b/src/tests/common/unit/usr_generator/llvm/llvm_func_type/test_usr_func_type.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_func_type/test_usr_func_type.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_linkage/expected.txt b/src/tests/common/unit/usr_generator/llvm/llvm_linkage/expected.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_linkage/linkage.cpp b/src/tests/common/unit/usr_generator/llvm/llvm_linkage/linkage.cpp new file mode 100644 index 0000000..c2969d9 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_linkage/linkage.cpp @@ -0,0 +1,9 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s + +// Linkage decls are skipped in USRs for enclosed items. +// Linkage decls themselves don't have USRs (no lines between ns and X). +// CHECK: {{[0-9]+}}:11 | namespace/C++ | ns | c:@N@ns | +// CHECK-NEXT: {{[0-9]+}}:33 | variable/C | X | c:@N@ns@X | +namespace ns { extern "C" { int X; } } \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_linkage/test_usr_linkage_type.py b/src/tests/common/unit/usr_generator/llvm/llvm_linkage/test_usr_linkage_type.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_linkage/test_usr_linkage_type.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/expected.txt b/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/expected.txt new file mode 100644 index 0000000..59a8519 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/expected.txt @@ -0,0 +1,105 @@ +Declaration: QType +Location: Line 6, Column 15 +Kind: Typedef +Clang USR: c:usrs.cpp@N@bar@T@QType +Armor USR: c:@N@bar@T@QType +------------------------------------------- + +Declaration: ClsC +Location: Line 29, Column 9 +Kind: CXXRecord +Clang USR: c:usrs.cpp@aN@S@ClsC +Armor USR: c:@aN@S@ClsC +------------------------------------------- + +Declaration: w +Location: Line 30, Column 7 +Kind: Var +Clang USR: c:usrs.cpp@aN@w +Armor USR: c:@aN@w +------------------------------------------- + +Declaration: add +Location: Line 37, Column 21 +Kind: Function +Clang USR: c:usrs.cpp@N@foo@N@taz@F@add#I#I# +Armor USR: c:@N@foo@N@taz@F@add#I#I# +------------------------------------------- + +Declaration: RDar9371763_Foo +Location: Line 69, Column 7 +Kind: CXXRecord +Clang USR: c:usrs.cpp@aN@S@RDar9371763_Foo +Armor USR: c:@aN@S@RDar9371763_Foo +------------------------------------------- + +Declaration: bar +Location: Line 71, Column 8 +Kind: CXXMethod +Clang USR: c:usrs.cpp@aN@S@RDar9371763_Foo@F@bar# +Armor USR: c:@aN@S@RDar9371763_Foo@F@bar# +------------------------------------------- + +Declaration: bar +Location: Line 75, Column 23 +Kind: CXXMethod +Clang USR: c:usrs.cpp@aN@S@RDar9371763_Foo@F@bar# +Armor USR: c:@aN@S@RDar9371763_Foo@F@bar# +------------------------------------------- + +Declaration: +Location: Line 91, Column 1 +Kind: CXXRecord +Clang USR: c:usrs.cpp@S@usrs.cpp@1475 +Armor USR: c:@S@#vf#embedS1 +------------------------------------------- + +Declaration: x +Location: Line 91, Column 14 +Kind: Field +Clang USR: c:usrs.cpp@S@usrs.cpp@1475@FI@x +Armor USR: c:@S@#vf#embedS1@FI@x +------------------------------------------- + +Declaration: embedS1 +Location: Line 91, Column 19 +Kind: Var +Clang USR: c:usrs.cpp@embedS1 +Armor USR: c:@embedS1 +------------------------------------------- + +Declaration: +Location: Line 92, Column 1 +Kind: CXXRecord +Clang USR: c:usrs.cpp@S@usrs.cpp@1502 +Armor USR: c:@S@#vf#embedS2 +------------------------------------------- + +Declaration: x +Location: Line 92, Column 14 +Kind: Field +Clang USR: c:usrs.cpp@S@usrs.cpp@1502@FI@x +Armor USR: c:@S@#vf#embedS2@FI@x +------------------------------------------- + +Declaration: embedS2 +Location: Line 92, Column 19 +Kind: Var +Clang USR: c:usrs.cpp@embedS2 +Armor USR: c:@embedS2 +------------------------------------------- + +Declaration: float3 +Location: Line 99, Column 55 +Kind: Typedef +Clang USR: c:usrs.cpp@T@float3 +Armor USR: c:@T@float3 +------------------------------------------- + +Declaration: __m128 +Location: Line 101, Column 15 +Kind: Typedef +Clang USR: c:usrs.cpp@T@__m128 +Armor USR: c:@T@__m128 +------------------------------------------- + diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/test_usr_gen.py b/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/test_usr_gen.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/test_usr_gen.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/usrs.cpp b/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/usrs.cpp new file mode 100644 index 0000000..1af5c7b --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_usr_cpp/usrs.cpp @@ -0,0 +1,188 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +namespace foo { + int x; + void bar(int z); +} +namespace bar { + typedef int QType; + void bar(QType z); +} + +class ClsA { +public: + int a, b; + ClsA(int A, int B) : a(A), b(B) {} +}; + +namespace foo { + class ClsB : public ClsA { + public: + ClsB() : ClsA(1, 2) {} + int result() const; + }; +} + +int foo::ClsB::result() const { + return a + b; +} + +namespace { + class ClsC : public foo::ClsB {}; + int w; +} + +int z; + +namespace foo { namespace taz { + int x; + static inline int add(int a, int b) { return a + b; } + void sub(int a, int b); +} +} + +namespace foo { namespace taz { + class ClsD : public foo::ClsB { + public: + ClsD& operator=(int x) { a = x; return *this; } + ClsD& operator=(double x) { a = (int) x; return *this; } + ClsD& operator=(const ClsD &x) { a = x.a; return *this; } + static int qux(); + static int uz(int z, ...); + bool operator==(const ClsD &x) const { return a == x.a; } + }; +}} + +extern "C" { + void rez(int a, int b); +} + +namespace foo_alias = foo; + +using namespace foo; + +namespace foo_alias2 = foo; + +using foo::ClsB; + +namespace foo_alias3 = foo; + +namespace { +class RDar9371763_Foo { +public: + void bar(); +}; +} + +void RDar9371763_Foo::bar() {} + +void rdar9371763() { + RDar9371763_Foo foo; + foo.bar(); +} + +template typename T::A someTemplFn() {} +template typename T::B someTemplFn() {} +template int someTemplFn() {} + +void fun(int c) {} + +void funWithChar(unsigned char c) {} +void funWithChar(signed char c) {} + +struct { int x; } embedS1; +struct { int x; } embedS2; + +template +class TC1 { + void meth(TC1); +}; + +typedef __attribute__((__ext_vector_type__(3))) float float3; + +typedef float __m128 __attribute__((__vector_size__(16))); + +float3 vectorOverload(float3 f); + +__m128 vectorOverload(__m128 f); + +// RUN: c-index-test -test-load-source-usrs all -fno-delayed-template-parsing %s | FileCheck %s +// CHECK: usrs.cpp c:@N@foo Extent=[1:1 - 4:2] +// CHECK: usrs.cpp c:@N@foo@x Extent=[2:3 - 2:8] +// CHECK: usrs.cpp c:@N@foo@F@bar#I# Extent=[3:3 - 3:18] +// CHECK: usrs.cpp c:usrs.cpp@36@N@foo@F@bar#I#@z Extent=[3:12 - 3:17] +// CHECK: usrs.cpp c:@N@bar Extent=[5:1 - 8:2] +// CHECK: usrs.cpp c:usrs.cpp@N@bar@T@QType Extent=[6:3 - 6:20] +// CHECK: usrs.cpp c:@N@bar@F@bar#I# Extent=[7:3 - 7:20] +// CHECK: usrs.cpp c:usrs.cpp@94@N@bar@F@bar#I#@z Extent=[7:12 - 7:19] +// CHECK: usrs.cpp c:@S@ClsA Extent=[10:1 - 14:2] +// CHECK: usrs.cpp c: Extent=[11:1 - 11:8] +// CHECK: usrs.cpp c:@S@ClsA@FI@a Extent=[12:3 - 12:8] +// CHECK: usrs.cpp c:@S@ClsA@FI@b Extent=[12:3 - 12:11] +// CHECK: usrs.cpp c:@S@ClsA@F@ClsA#I#I# Extent=[13:3 - 13:37] +// CHECK: usrs.cpp c:usrs.cpp@147@S@ClsA@F@ClsA#I#I#@A Extent=[13:8 - 13:13] +// CHECK: usrs.cpp c:usrs.cpp@154@S@ClsA@F@ClsA#I#I#@B Extent=[13:15 - 13:20] +// CHECK: usrs.cpp c:@N@foo Extent=[16:1 - 22:2] +// CHECK: usrs.cpp c:@N@foo@S@ClsB Extent=[17:3 - 21:4] +// CHECK: usrs.cpp c: Extent=[18:3 - 18:10] +// CHECK: usrs.cpp c:@N@foo@S@ClsB@F@ClsB# Extent=[19:5 - 19:27] +// CHECK: usrs.cpp c:@N@foo@S@ClsB@F@result#1 Extent=[20:5 - 20:23] +// CHECK: usrs.cpp c:@N@foo@S@ClsB@F@result#1 Extent=[24:1 - 26:2] +// CHECK: usrs.cpp c:usrs.cpp@aN@S@ClsC Extent=[29:3 - 29:35] +// CHECK: usrs.cpp c:usrs.cpp@aN@w Extent=[30:3 - 30:8] +// CHECK: usrs.cpp c:@z Extent=[33:1 - 33:6] +// CHECK: usrs.cpp c:@N@foo Extent=[35:1 - 40:2] +// CHECK: usrs.cpp c:@N@foo@N@taz Extent=[35:17 - 39:2] +// CHECK: usrs.cpp c:@N@foo@N@taz@x Extent=[36:3 - 36:8] +// CHECK: usrs.cpp c:usrs.cpp@N@foo@N@taz@F@add#I#I# Extent=[37:3 - 37:56] +// CHECK: usrs.cpp c:usrs.cpp@479@N@foo@N@taz@F@add#I#I#@a Extent=[37:25 - 37:30] +// CHECK: usrs.cpp c:usrs.cpp@486@N@foo@N@taz@F@add#I#I#@b Extent=[37:32 - 37:37] +// CHECK: usrs.cpp c:@N@foo@N@taz@F@sub#I#I# Extent=[38:3 - 38:25] +// CHECK: usrs.cpp c:usrs.cpp@522@N@foo@N@taz@F@sub#I#I#@a Extent=[38:12 - 38:17] +// CHECK: usrs.cpp c:usrs.cpp@529@N@foo@N@taz@F@sub#I#I#@b Extent=[38:19 - 38:24] +// CHECK: usrs.cpp c:@N@foo Extent=[42:1 - 52:3] +// CHECK: usrs.cpp c:@N@foo@N@taz Extent=[42:17 - 52:2] +// CHECK: usrs.cpp c:@N@foo@N@taz@S@ClsD Extent=[43:3 - 51:4] +// CHECK: usrs.cpp c: Extent=[44:3 - 44:10] +// CHECK: usrs.cpp c:@N@foo@N@taz@S@ClsD@F@operator=#I# Extent=[45:5 - 45:52] +// CHECK: usrs.cpp c:usrs.cpp@638@N@foo@N@taz@S@ClsD@F@operator=#I#@x Extent=[45:21 - 45:26] +// CHECK: usrs.cpp c:@N@foo@N@taz@S@ClsD@F@operator=#d# Extent=[46:5 - 46:61] +// CHECK: usrs.cpp c:usrs.cpp@690@N@foo@N@taz@S@ClsD@F@operator=#d#@x Extent=[46:21 - 46:29] +// CHECK: usrs.cpp c:@N@foo@N@taz@S@ClsD@F@operator=#&1$@N@foo@N@taz@S@ClsD# Extent=[47:5 - 47:62] +// CHECK: usrs.cpp c:usrs.cpp@751@N@foo@N@taz@S@ClsD@F@operator=#&1$@N@foo@N@taz@S@ClsD#@x Extent=[47:21 - 47:34] +// CHECK: usrs.cpp c:@N@foo@N@taz@S@ClsD@F@qux#S Extent=[48:5 - 48:21] +// CHECK: usrs.cpp c:@N@foo@N@taz@S@ClsD@F@uz#I.#S Extent=[49:5 - 49:30] +// CHECK: usrs.cpp c:usrs.cpp@833@N@foo@N@taz@S@ClsD@F@uz#I.#S@z Extent=[49:19 - 49:24] +// CHECK: usrs.cpp c:@N@foo@N@taz@S@ClsD@F@operator==#&1$@N@foo@N@taz@S@ClsD#1 Extent=[50:5 - 50:62] +// CHECK: usrs.cpp c:usrs.cpp@866@N@foo@N@taz@S@ClsD@F@operator==#&1$@N@foo@N@taz@S@ClsD#1@x Extent=[50:21 - 50:34] +// CHECK: usrs.cpp c:@F@rez Extent=[55:3 - 55:25] +// CHECK: usrs.cpp c:usrs.cpp@941@F@rez@a Extent=[55:12 - 55:17] +// CHECK: usrs.cpp c:usrs.cpp@948@F@rez@b Extent=[55:19 - 55:24] +// CHECK: usrs.cpp c:@NA@foo_alias +// CHECK-NOT: foo +// CHECK: usrs.cpp c:@NA@foo_alias2 +// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16] +// CHECK: usrs.cpp c:@NA@foo_alias3 +// CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2] +// CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2] +// CHECK: usrs.cpp c: Extent=[70:1 - 70:8] +// CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo@F@bar# Extent=[71:3 - 71:13] +// CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo@F@bar# Extent=[75:1 - 75:31] +// CHECK: usrs.cpp c:@F@rdar9371763# Extent=[77:1 - 80:2] +// CHECK: usrs.cpp c:usrs.cpp@1204@F@rdar9371763#@foo Extent=[78:3 - 78:22] + +// CHECK: usrs.cpp c:@FT@>1#TsomeTemplFn#^type-parameter-0-0:::A# Extent=[82:1 - 82:50] +// CHECK: usrs.cpp c:@FT@>1#TsomeTemplFn#^type-parameter-0-0:::B# Extent=[83:1 - 83:50] +// CHECK: usrs.cpp c:@FT@>1#TsomeTemplFn#I# Extent=[84:1 - 84:40] + +// CHECK: usrs.cpp c:@F@funWithChar#C# Extent=[86:1 - 86:28] +// CHECK: usrs.cpp c:@F@funWithChar#c# Extent=[87:1 - 87:37] +// CHECK: usrs.cpp c:@F@funWithChar#r# Extent=[88:1 - 88:35] + +// CHECK: usrs.cpp c:usrs.cpp@S@usrs.cpp@1483@FI@x Extent=[90:10 - 90:15] +// CHECK: usrs.cpp c:usrs.cpp@S@usrs.cpp@1510@FI@x Extent=[91:10 - 91:15] + +// CHECK: usrs.cpp c:@ST>1#T@TC1@F@meth#>@ST>1#T@TC11t0.0# Extent=[95:3 - 95:17] + +// CHECK: usrs.cpp c:@F@vectorOverload#]3f# Extent=[102:1 - 102:32] +// CHECK: usrs.cpp c:@F@vectorOverload#[4f# Extent=[104:1 - 104:32] \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/expected.txt b/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/expected.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/test_usr_cxx0x.py b/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/test_usr_cxx0x.py new file mode 100644 index 0000000..e8487d7 --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/test_usr_cxx0x.py @@ -0,0 +1,33 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause +import os +import subprocess +from deepdiff import DeepDiff + +def test_ast_diff(binary_path, binary_args, get_cpp_files, request): + test_dir = os.path.dirname(request.fspath) + + cpp_files = get_cpp_files + for cpp_file in cpp_files: + # Run the binary + subprocess.run( + [binary_path] + [cpp_file] + binary_args, + check=True, + cwd=os.path.dirname(request.fspath) + ) + + print(test_dir) + + # Read the expected output file as lines + with open(f'{test_dir}/expected.txt', 'r') as f: + expected_lines = [line.strip() for line in f.readlines()] + + # Read the actual output file as lines + with open(f'{test_dir}/output.txt', 'r') as f: + actual_lines = [line.strip() for line in f.readlines()] + + # Compare the lines + diff = DeepDiff(expected_lines, actual_lines, ignore_order=True) + + # Assert that there are no differences + assert diff == {}, f"Files differ: {diff}" \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/usrs-cxx0x.cpp b/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/usrs-cxx0x.cpp new file mode 100644 index 0000000..13ee9ee --- /dev/null +++ b/src/tests/common/unit/usr_generator/llvm/llvm_usrs_cxx0x/usrs-cxx0x.cpp @@ -0,0 +1,20 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +template +struct tuple { }; + +void f(tuple); + +class TestCls { + void meth() &; + void meth() &&; + void meth(int&&); +}; + +// RUN: c-index-test -test-load-source-usrs all -std=c++11 %s | FileCheck %s +// CHECK: usrs-cxx0x.cpp c:@ST>1#pT@tuple Extent=[1:1 - 2:17] +// CHECK: usrs-cxx0x.cpp c:@F@f#$@S@tuple>#p3Ifd# Extent=[4:1 - 4:34] + +// CHECK: usrs-cxx0x.cpp c:@S@TestCls@F@meth#& Extent=[7:3 - 7:16] +// CHECK: usrs-cxx0x.cpp c:@S@TestCls@F@meth#&& Extent=[8:3 - 8:17] +// CHECK: usrs-cxx0x.cpp c:@S@TestCls@F@meth#&&I# Extent=[9:3 - 9:19] \ No newline at end of file diff --git a/src/tests/common/unit/usr_generator/src/main.cpp b/src/tests/common/unit/usr_generator/src/main.cpp new file mode 100644 index 0000000..458fc76 --- /dev/null +++ b/src/tests/common/unit/usr_generator/src/main.cpp @@ -0,0 +1,171 @@ +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +// SPDX-License-Identifier: BSD-3-Clause +#include "custom_usr_generator.hpp" +#include "clang/AST/Decl.h" +#include "clang/AST/DeclBase.h" +#include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclFriend.h" +#include "clang/Index/USRGeneration.h" +#include "clang/Tooling/CompilationDatabase.h" +#include "clang/Tooling/Tooling.h" +#include "clang/Frontend/FrontendActions.h" +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Frontend/CompilerInstance.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/ADT/SmallString.h" +#include +#include +#include +#include + +using namespace clang; +using namespace clang::tooling; +using namespace llvm; + +#ifndef CLANG_FLAGS +#define CLANG_FLAGS "" +#endif + +std::vector getClangFlags() { + std::vector flags; + std::istringstream iss(CLANG_FLAGS); + std::string flag; + while (iss >> flag) { + flags.emplace_back(std::move(flag)); + } + return flags; +} + +namespace { +class USRGenVisitor : public RecursiveASTVisitor { +private: + ASTContext *Context; + llvm::raw_fd_ostream os_output; + std::error_code EC; + bool ShowDiff; + +public: + USRGenVisitor(ASTContext *Context, StringRef OutputFile, bool ShowDiff) + : Context(Context), os_output(OutputFile, EC, llvm::sys::fs::OF_None), ShowDiff(ShowDiff) {} + + void ProcessDecl(const clang::Decl *Decl, StringRef DeclName) { + SourceLocation Loc = Decl->getLocation(); + unsigned Line = -1; + unsigned Column = -1; + + SourceManager &SM = Context->getSourceManager(); + Line = SM.getSpellingLineNumber(Loc); + Column = SM.getSpellingColumnNumber(Loc); + + SmallString<256> ClangUSR; + bool ClangSuccess = index::generateUSRForDecl(Decl, ClangUSR); + + SmallString<256> ArmorUSR; + bool ArmorSuccess = armor::generateUSRForDecl(Decl, ArmorUSR); + + if (ShowDiff && ArmorUSR.equals(ClangUSR)) return; + + os_output << "Declaration: " << DeclName << "\n"; + os_output << "Location: Line " << Line << ", Column " << Column << "\n"; + os_output << "Kind: " << Decl->getDeclKindName() << "\n"; + os_output << "Armor USR: " << (!ArmorSuccess ? ArmorUSR.str() : llvm::StringRef("ERROR")) << "\n"; + os_output << "Clang USR: " << (!ClangSuccess ? ClangUSR.str() : llvm::StringRef("ERROR")) << "\n"; + os_output << "-------------------------------------------\n\n"; + } + + bool VisitNamedDecl(clang::NamedDecl *Decl) { + if (!IsFromMainFile(Decl) || isa(Decl) || isa(Decl) || + isa(Decl)) + return true; + + ProcessDecl(Decl, Decl->getNameAsString()); + return true; + } + + bool VisitFriendDecl(clang::FriendDecl *Decl) { + if (!IsFromMainFile(Decl)) + return true; + + ProcessDecl(Decl, "Friend"); + return true; + } + + inline bool IsFromMainFile(const clang::Decl *Decl) { + clang::ASTContext *clangContext = &Decl->getASTContext(); + return clangContext->getSourceManager().isInMainFile(Decl->getLocation()); + } + + ~USRGenVisitor() { os_output.close(); } +}; + +class USRGenConsumer : public ASTConsumer { +private: + USRGenVisitor Visitor; +public: + explicit USRGenConsumer(ASTContext *Context, const std::string &OutputFile, bool ShowDiff) + : Visitor(Context, OutputFile, ShowDiff) {} + + void HandleTranslationUnit(ASTContext &Context) override { + Visitor.TraverseDecl(Context.getTranslationUnitDecl()); + } +}; + +class USRGenAction : public ASTFrontendAction { +private: + std::string OutputFile; + bool ShowDiff; +public: + USRGenAction(const std::string &OutputFile, bool ShowDiff) : OutputFile(OutputFile), ShowDiff(ShowDiff) {} + + std::unique_ptr CreateASTConsumer(CompilerInstance &CI, StringRef file) override { + return std::make_unique(&CI.getASTContext(), OutputFile, ShowDiff); + } +}; + +class USRGenActionFactory : public FrontendActionFactory { +private: + std::string OutputFile; + bool ShowDiff; +public: + USRGenActionFactory(const std::string &OutputFile, bool ShowDiff) : OutputFile(OutputFile), ShowDiff(ShowDiff) {} + + std::unique_ptr create() override { + return std::make_unique(OutputFile, ShowDiff); + } +}; + +} + +int main(int argc, const char **argv) { + std::vector CompileCommands = getClangFlags(); + + std::string CurrentDir = "."; + std::unique_ptr Compilations = + std::make_unique(CurrentDir, CompileCommands); + + if (argc < 3) { + llvm::errs() << "Usage: " << argv[0] << " [show-diff]\n"; + llvm::errs() << " input-file: C++ source or header file to process\n"; + llvm::errs() << " output-file: File to write USR information to\n"; + llvm::errs() << " show-diff: Optional. If 'true', only show declarations with different USRs\n"; + return 1; + } + + std::string fileToProcess = argv[1]; + std::string outputFile = argv[2]; + + bool showDiff = false; + if (argc >= 4) { + std::string showDiffArg = argv[3]; + showDiff = (showDiffArg == "true" || showDiffArg == "1" || + showDiffArg == "yes" || showDiffArg == "y"); + } + + ClangTool Tool(*Compilations, fileToProcess); + + auto Factory = std::make_unique(outputFile, showDiff); + + return Tool.run(Factory.get()); +}