Skip to content

M7-3-6: Refine detection of using within function/class scope #400

Closed
@lcartey

Description

@lcartey

Affected rules

  • M7-3-6

Description

The rule states:

using-directives and using-declarations (excluding class scope or function scope using-declarations) shall not be used in header files.

However, we currently permit both using declarations and using directives in function/class scope - we should refine this.

In addition, some using directives/declarations appear to be "orphaned" in our model - i.e. be located within a function or class, but with a fake parent which is not otherwise connected to the AST. We should exclude these to avoid false positives.

Example

template<typename T>
void foo(T& t){
  using some_namespace::func; // COMPLIANT[FALSE_POSITIVE] - not directly reproducible today
  func(t);
}

template<typename T>
class base{
protected:
  void foo(T);
};

template<typename T>
class derived: base<T> {
public:
  using base::foo; // COMPLIANT[FALSE_POSITIVE]
  void foo(T,T);
};

Metadata

Metadata

Assignees

Labels

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