mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
CPP: Restrict to #elif, #else, #endif.
This commit is contained in:
@@ -49,10 +49,21 @@ private predicate looksLikeCode(string line) {
|
||||
|
||||
/**
|
||||
* Holds if there is a preprocessor directive on the line indicated by
|
||||
* `f` and `line`.
|
||||
* `f` and `line` that we permit code comments besides. For example this
|
||||
* is considered acceptable:
|
||||
* ```
|
||||
* #ifdef MYMACRO
|
||||
* ...
|
||||
* #endif // #ifdef MYMACRO
|
||||
* ```
|
||||
*/
|
||||
private predicate preprocLine(File f, int line) {
|
||||
exists(PreprocessorDirective pd, Location l |
|
||||
(
|
||||
pd instanceof PreprocessorElse or
|
||||
pd instanceof PreprocessorElif or
|
||||
pd instanceof PreprocessorEndif
|
||||
) and
|
||||
pd.getLocation() = l and
|
||||
l.getFile() = f and
|
||||
l.getStartLine() = line
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
| test2.cpp:65:1:65:17 | // # pragma once | This comment appears to contain commented-out code |
|
||||
| test2.cpp:67:1:67:19 | /*#error"myerror"*/ | This comment appears to contain commented-out code |
|
||||
| test2.cpp:91:1:95:2 | /*\n#ifdef MYMACRO\n\t// ...\n#endif // #ifdef MYMACRO\n*/ | This comment appears to contain commented-out code |
|
||||
| test2.cpp:107:21:107:43 | // #include "config2.h" | This comment appears to contain commented-out code |
|
||||
| test2.cpp:115:16:115:35 | /* #ifdef MYMACRO */ | This comment appears to contain commented-out code |
|
||||
| test.c:2:1:2:22 | // commented out code; | This comment appears to contain commented-out code |
|
||||
| test.c:4:1:7:8 | // some; | This comment appears to contain commented-out code |
|
||||
| test.c:9:1:13:8 | // also; | This comment appears to contain commented-out code |
|
||||
|
||||
Reference in New Issue
Block a user