[SERVER-81159] IDL generates dead code for variants with array types. Created: 18/Sep/23  Updated: 15/Nov/23  Resolved: 15/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Bug Priority: Minor - P4
Reporter: Matthew Russotto Assignee: Ryan Berryhill
Resolution: Fixed Votes: 0
Labels: perf-tiger, perf-tiger-handoff, perf-tiger-non-q4, techdebt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Service Arch
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Service Arch 2023-11-13, Service Arch 2023-11-27
Participants:

 Description   

When a variant IDL type contains an array, it will generate code like this (from query_settings_gen.cpp, the indexHints field)

                    const BSONType variantType = element.type();
                    switch (variantType) {
                    case Array:
                        if (element.Obj().isEmpty()) {
                            std::uint32_t expectedFieldNumber{0};
                            const IDLParserContext arrayCtxt(kIndexHintsFieldName, &ctxt, ctxt.getTenantId(), getSerializationContext());
                            std::vector<mongo::query_settings::IndexHintSpec> values;
 
                            const BSONObj arrayObject = element.Obj();
                            for (const auto& arrayElement : arrayObject) {
                                [...elided...]
                                ++expectedFieldNumber;
                            }
                            _indexHints = std::move(values);

The arrayObject is empty, so the "for" loop, all the code in it, the expectedFieldNumber, and 'values' are not useful. _indexHints will be set to an empty array every time.



 Comments   
Comment by Githook User [ 14/Nov/23 ]

Author:

{'name': 'Ryan Berryhill', 'email': 'ryan.berryhill@mongodb.com', 'username': 'ryanberryhill'}

Message: SERVER-81159 Don't generate dead code for IDL variants with array types
Branch: master
https://github.com/mongodb/mongo/commit/95cddf089681c28797b8156b48d4ae2d8ee86e72

Generated at Thu Feb 08 06:45:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.