Skip to content

Commit 359aa02

Browse files
authored
Merge pull request #19410 from jketema/header-variant
C++: Turn header variant tests that use PCH files into integration tests
2 parents 302680c + 3423a10 commit 359aa02

File tree

36 files changed

+64
-53
lines changed

36 files changed

+64
-53
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "a.h"
2+
#define FOUR 4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int main() {
2+
return ONE + FOUR;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#import "d.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int main() {
2+
return SEVENTEEN;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#if 1
2+
#pragma hdrstop
3+
extern int x;
4+
#define SEEN_F
5+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#ifdef SEEN_F
2+
static int g() {
3+
return 20;
4+
}
5+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "h1.h"
2+
#pragma hdrstop
3+
#include "h2.h"
4+
#define SEEN_H

cpp/ql/test/header-variant-tests/clang-pch/i.c renamed to cpp/ql/integration-tests/header-variant-tests/clang-pch/i.c

-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ static int h2() {
1313
return 32;
1414
}
1515
#endif
16-
// semmle-extractor-options: --clang -include-pch ${testdir}/clang-pch.testproj/h.pch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
4+
def test(codeql, cpp):
5+
os.mkdir("pch")
6+
extractor = cpp.get_tool("extractor")
7+
codeql.database.create(command=[
8+
f'"{extractor}" --mimic-clang -emit-pch -o pch/a.pch a.c',
9+
f'"{extractor}" --mimic-clang -include-pch pch/a.pch -Iextra_dummy_path b.c',
10+
f'"{extractor}" --mimic-clang -include pch/a -Iextra_dummy_path c.c',
11+
f'"{extractor}" --mimic-clang -emit-pch -o pch/d.pch d.c',
12+
f'"{extractor}" --mimic-clang -include-pch pch/d.pch e.c',
13+
f'"{extractor}" --mimic-clang -emit-pch -o pch/f.pch f.c',
14+
f'"{extractor}" --mimic-clang -include-pch pch/f.pch g.c',
15+
f'"{extractor}" --mimic-clang -emit-pch -o pch/h.pch h.c',
16+
f'"{extractor}" --mimic-clang -include-pch pch/h.pch i.c',
17+
])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "a.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma hdrstop
2+
#include "b.h"
3+
4+
int b() {
5+
return A;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "d.h"
2+
#include "c.h"
3+
4+
int c() {
5+
return A;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
3+
4+
def test(codeql, cpp):
5+
os.mkdir("pch")
6+
extractor = cpp.get_tool("extractor")
7+
codeql.database.create(command=[
8+
f'"{extractor}" --mimic-cl /Yca.h /Fppch/a.pch a.c',
9+
f'"{extractor}" --mimic-cl /Yub.h /Fppch/a.pch b.c',
10+
f'"{extractor}" --mimic-cl /Yuc.h /Fppch/a.pch c.c',
11+
])

cpp/ql/test/header-variant-tests/clang-pch/_.c

-3
This file was deleted.

cpp/ql/test/header-variant-tests/clang-pch/a.c

-3
This file was deleted.

cpp/ql/test/header-variant-tests/clang-pch/c.c

-4
This file was deleted.

cpp/ql/test/header-variant-tests/clang-pch/d.c

-2
This file was deleted.

cpp/ql/test/header-variant-tests/clang-pch/e.c

-4
This file was deleted.

cpp/ql/test/header-variant-tests/clang-pch/f.c

-6
This file was deleted.

cpp/ql/test/header-variant-tests/clang-pch/g.c

-6
This file was deleted.

cpp/ql/test/header-variant-tests/clang-pch/h.c

-5
This file was deleted.

cpp/ql/test/header-variant-tests/microsoft-pch/_.c

-3
This file was deleted.

cpp/ql/test/header-variant-tests/microsoft-pch/a.c

-2
This file was deleted.

cpp/ql/test/header-variant-tests/microsoft-pch/b.c

-7
This file was deleted.

cpp/ql/test/header-variant-tests/microsoft-pch/c.c

-7
This file was deleted.

0 commit comments

Comments
 (0)