Skip to content

Commit e7d3eed

Browse files
authored
Merge pull request #21661 from jketema/autoconf
C++: Add heuristic for GNU autoconf config files
2 parents 4cb238f + 04cfd37 commit e7d3eed

File tree

10 files changed

+47
-0
lines changed

10 files changed

+47
-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 `AutoconfConfigureTestFile` of `ConfigurationTestFile` that represents files created by GNU autoconf configure scripts to test the build configuration.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ class MesonPrivateTestFile extends ConfigurationTestFile {
4242
)
4343
}
4444
}
45+
46+
/**
47+
* A file created by a GNU autoconf configure script to test the system configuration.
48+
*/
49+
class AutoconfConfigureTestFile extends ConfigurationTestFile {
50+
AutoconfConfigureTestFile() { this.getBaseName().regexpMatch("conftest[0-9]*\\.c(pp)?") }
51+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| conftest.c.c:4:3:4:8 | call to strlen | This expression has no effect (because $@ has no external side effects). | conftest.h:3:8:3:13 | strlen | strlen |
2+
| conftest_abc.c:4:3:4:8 | call to strlen | This expression has no effect (because $@ has no external side effects). | conftest.h:3:8:3:13 | strlen | strlen |
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "conftest.h"
2+
3+
int main2() {
4+
strlen(""); // GOOD: conftest files are ignored
5+
return 0;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "conftest.h"
2+
3+
int main3() {
4+
strlen(""); // BAD: not a `conftest` file, as `conftest` is not directly followed by the extension or a sequence of numbers.
5+
return 0;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "conftest.h"
2+
3+
int main4() {
4+
strlen(""); // GOOD: conftest files are ignored
5+
return 0;
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
typedef long long size_t;
2+
3+
size_t strlen(const char *s);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "conftest.h"
2+
3+
int main5() {
4+
strlen(""); // GOOD: conftest files are ignored
5+
return 0;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "conftest.h"
2+
3+
int main1() {
4+
strlen(""); // BAD: not a `conftest` file, as `conftest` is not directly followed by the extension or a sequence of numbers.
5+
return 0;
6+
}

0 commit comments

Comments
 (0)