File tree Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1+ - ` M7-3-6 ` - ` UsingDeclarationsUsedInHeaderFiles.ql ` :
2+ - Address FN reported in #400 . Only using-declarations are exempted from class- and function-scope.
Original file line number Diff line number Diff line change @@ -28,5 +28,13 @@ predicate isInClassScope(UsingEntry u) { exists(Class c | u.getEnclosingElement(
2828from UsingEntry u
2929where
3030 not isExcluded ( u , BannedSyntaxPackage:: usingDeclarationsUsedInHeaderFilesQuery ( ) ) and
31- ( isInHeaderFile ( u ) and not isInFunctionScope ( u ) and not isInClassScope ( u ) )
31+ isInHeaderFile ( u ) and
32+ (
33+ u instanceof UsingDeclarationEntry
34+ implies
35+ (
36+ not isInFunctionScope ( u ) and
37+ not isInClassScope ( u )
38+ )
39+ )
3240select u , "Using directive or declaration used in a header file " + u .getFile ( ) + "."
Original file line number Diff line number Diff line change 11| test.h:4:1:4:21 | using namespace std | Using directive or declaration used in a header file test.h. |
2+ | test.h:18:3:18:21 | using namespace std | Using directive or declaration used in a header file test.h. |
Original file line number Diff line number Diff line change @@ -7,11 +7,15 @@ namespace my_namespace {
77int MY_CONST = 0 ;
88};
99
10- int f () {
10+ void f () {
1111
1212 using my_namespace::MY_CONST; // COMPLIANT - function scope
1313
1414 int x = MY_CONST;
1515}
1616
17+ void test_fn_reported_in_400 () {
18+ using namespace std ; // NON_COMPLIANT - only using declarations are exempted
19+ // in function scope.
20+ }
1721#endif
You can’t perform that action at this time.
0 commit comments