Skip to content

Custom Query: The getATypeUse helper predicate in CodeQL doesn't consider the case where type is constructed with an aggregate literal.  #351

Closed
@rak3-sh

Description

@rak3-sh

Affected rules

All rules that are using getATypeUse for analysis.

Description

In case a query wants to check whether a type is left unused, they can do so by using the getATypeUse helper predicate. However, that predicate doesn't consider the case where a type is constructed with an aggregate literal.

Example

#define _KV(key, ...)                                       \
  [](const auto& _log_incoming_value) noexcept {            \
    class _log_kv_pair {                                    \
     public:                                                \
      constexpr static const char * LogKeyName() noexcept { \
        return static_cast<const char*>(key);               \
      }                                                     \
    };                                                      \
    return _log_kv_pair{_log_incoming_value};               \
  }

int main()
{
  _KV("pid");
  return 0;
}

Metadata

Metadata

Assignees

Labels

Difficulty-MediumA false positive or false negative report which is expected to take 1-5 days effort to addressImpact-Mediumfalse positive/false negativeAn issue related to observed false positives or false negatives.user-reportIssue reported by an end user of CodeQL Coding Standards

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions