Skip to content

cpp: FPs in Microsoft.SAL #283

@tosmolka

Description

@tosmolka

We noticed false positives when testing SAL annotations.

These three should demonstrate the issue:
sal.h:

#define _SAL_VERSION 20

test.cpp:

#include "sal.h"
int method1() {
    return _SAL_VERSION;
}
void method2();

test.ql:

import Microsoft.SAL
from SALAnnotation a
select a, a.getDeclaration()

Output from the query:

| test.cpp:3:12:3:23 | _SAL_VERSION | test.cpp:5:6:5:12 | method2 |

It seems the detection is based on "rank" and the fact that MacroInvocation _SAL_VERSION is before DeclarationEntry method2.

Not sure what is the best fix, can you please advise? Thank you.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions