Skip to content

Commit 17ab87d

Browse files
authored
Merge pull request #21618 from jketema/meson-silence
C++: Add heuristics for meson configuration files
2 parents 2bde364 + ceec44b commit 17ab87d

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added a subclass `MesonPrivateTestFile` of `ConfigurationTestFile` that represents files created by Meson to test the build configuration.

cpp/ql/lib/semmle/code/cpp/ConfigurationTestFile.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ class CmakeTryCompileFile extends ConfigurationTestFile {
2626
)
2727
}
2828
}
29+
30+
/**
31+
* A file created by Meson to test the system configuration.
32+
*/
33+
class MesonPrivateTestFile extends ConfigurationTestFile {
34+
MesonPrivateTestFile() {
35+
this.getBaseName() = "testfile.c" and
36+
exists(Folder folder, Folder parent |
37+
folder = this.getParentContainer() and
38+
parent = folder.getParentContainer()
39+
|
40+
folder.getBaseName().matches("tmp%") and
41+
parent.getBaseName() = "meson-private"
42+
)
43+
}
44+
}

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/meson-private/tmp_abc/ExprHasNoEffect.expected

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Likely Bugs/Likely Typos/ExprHasNoEffect.ql
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
typedef long long size_t;
2+
3+
size_t strlen(const char *s);
4+
5+
int main() {
6+
strlen(""); // GOOD: the source file occurs in a `meson-private/tmp.../testfile.c` directory
7+
return 0;
8+
}

0 commit comments

Comments
 (0)