mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +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
|
||||
|
||||
Reference in New Issue
Block a user