From 5122f7cf9286e84bd745bc983f6fb54a8ea4fe45 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Tue, 31 Mar 2026 10:25:57 +0200 Subject: [PATCH] C++: Add heuristics for meson configuration files --- .../semmle/code/cpp/ConfigurationTestFile.qll | 16 ++++++++++++++++ .../tmp_abc/ExprHasNoEffect.expected | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cpp/ql/lib/semmle/code/cpp/ConfigurationTestFile.qll b/cpp/ql/lib/semmle/code/cpp/ConfigurationTestFile.qll index fe89a556f74..b39c1009f07 100644 --- a/cpp/ql/lib/semmle/code/cpp/ConfigurationTestFile.qll +++ b/cpp/ql/lib/semmle/code/cpp/ConfigurationTestFile.qll @@ -26,3 +26,19 @@ class CmakeTryCompileFile extends ConfigurationTestFile { ) } } + +/** + * A file created by Meson to test the system configuration. + */ +class MesonPrivateTestFile extends ConfigurationTestFile { + MesonPrivateTestFile() { + this.getBaseName() = "testfile.c" and + exists(Folder folder, Folder parent | + folder = this.getParentContainer() and + parent = folder.getParentContainer() + | + folder.getBaseName().matches("tmp%") and + parent.getBaseName() = "meson-private" + ) + } +} diff --git a/cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/meson-private/tmp_abc/ExprHasNoEffect.expected b/cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/meson-private/tmp_abc/ExprHasNoEffect.expected index 1f2c9410da1..e69de29bb2d 100644 --- a/cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/meson-private/tmp_abc/ExprHasNoEffect.expected +++ b/cpp/ql/test/query-tests/Likely Bugs/Likely Typos/ExprHasNoEffect/meson-private/tmp_abc/ExprHasNoEffect.expected @@ -1 +0,0 @@ -| testfile.c:6:3:6:8 | call to strlen | This expression has no effect (because $@ has no external side effects). | testfile.c:3:8:3:13 | strlen | strlen |