Skip to content

M14-6-1: Performance issue and missing case #192

Closed
@lcartey

Description

@lcartey

Affected rules

  • M14-6-1

Description

There are three issues with this rule:

  1. The rule is "In a class template with a dependent base,...", however, the rule is not restricted to template classes. Edit: although the query doesn't include an explicit condition, the nature of the problem is that it only can occur where the base type is a dependent template type. This just needs some additional documentation in the query, and some additional test cases.
  2. There is a performance problem in the way that we try to find function calls, function accesses and variable accesses in the sub-type which conflict with a name in the super-type. This is because we are trying to find pairs of functions with the same name, and our join ordering is not ideal.
  3. We are missing the types case.

Example

Templates:

class B {
public:
  void g();
};

class A : B {
public:
  void m1() {
    g();              // COMPLIANT[FALSE_POSITIVE] - not a template class
  }
};

Missing type support:

template <typename T> class B {
public:
  typedef T TYPE;
};

template <typename T> class A : B<T> {
public:
  void m1() {
    TYPE t = 0;       // NON_COMPLIANT[FALSE_NEGATIVE]
  }
};
``

Metadata

Metadata

Assignees

Labels

Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-Highfalse 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