Skip to content

Commit 1847a45

Browse files
authored
Merge pull request #20298 from jketema/pch-expose
C++: Add class representing PCH files
2 parents e8b7ce4 + 3112664 commit 1847a45

File tree

11 files changed

+12551
-2346
lines changed

11 files changed

+12551
-2346
lines changed

cpp/downgrades/c16b29b27f71247023321cc0d0360998b318837c/old.dbscheme

Lines changed: 2436 additions & 0 deletions
Large diffs are not rendered by default.

cpp/downgrades/c16b29b27f71247023321cc0d0360998b318837c/semmlecode.cpp.dbscheme

Lines changed: 2423 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
description: Link PCH creations and uses
2+
compatibility: full
3+
pch_uses.rel: delete
4+
pch_creations.rel: delete
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: feature
3+
---
4+
* Added a new class `PchFile` representing precompiled header (PCH) files used during project compilation.
5+

cpp/ql/lib/cpp.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import Customizations
1717
import semmle.code.cpp.File
18+
import semmle.code.cpp.PchFile
1819
import semmle.code.cpp.Linkage
1920
import semmle.code.cpp.Location
2021
import semmle.code.cpp.Compilation
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Provides the `PchFile` class representing precompiled header (PCH) files created and
3+
* used during the build process.
4+
*/
5+
6+
import semmle.code.cpp.File
7+
8+
/**
9+
* A precompiled header (PCH) file created during the build process.
10+
*/
11+
class PchFile extends @pch {
12+
/**
13+
* Gets a textual representation of this element.
14+
*/
15+
string toString() { result = "PCH for " + this.getHeaderFile() }
16+
17+
/**
18+
* Gets the header file from which the PCH file was created.
19+
*/
20+
File getHeaderFile() { pch_creations(this, _, result) }
21+
22+
/**
23+
* Gets a source file that includes the PCH.
24+
*/
25+
File getAUse() { pch_uses(this, _, result) }
26+
}

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,19 @@ extractor_version(
222222
string frontend_version: string ref
223223
)
224224

225+
pch_uses(
226+
int pch: @pch ref,
227+
int compilation: @compilation ref,
228+
int id: @file ref
229+
)
230+
231+
#keyset[pch, compilation]
232+
pch_creations(
233+
int pch: @pch,
234+
int compilation: @compilation ref,
235+
int from: @file ref
236+
)
237+
225238
/** An element for which line-count information is available. */
226239
@sourceline = @file | @function | @variable | @enumconstant | @xmllocatable;
227240

0 commit comments

Comments
 (0)