Merge pull request #20298 from jketema/pch-expose

C++: Add class representing PCH files
This commit is contained in:
Jeroen Ketema
2025-08-28 15:33:20 +02:00
committed by GitHub
11 changed files with 12557 additions and 2352 deletions

View File

@@ -0,0 +1,5 @@
---
category: feature
---
* Added a new class `PchFile` representing precompiled header (PCH) files used during project compilation.

View File

@@ -15,6 +15,7 @@
import Customizations
import semmle.code.cpp.File
import semmle.code.cpp.PchFile
import semmle.code.cpp.Linkage
import semmle.code.cpp.Location
import semmle.code.cpp.Compilation

View File

@@ -0,0 +1,26 @@
/**
* Provides the `PchFile` class representing precompiled header (PCH) files created and
* used during the build process.
*/
import semmle.code.cpp.File
/**
* A precompiled header (PCH) file created during the build process.
*/
class PchFile extends @pch {
/**
* Gets a textual representation of this element.
*/
string toString() { result = "PCH for " + this.getHeaderFile() }
/**
* Gets the header file from which the PCH file was created.
*/
File getHeaderFile() { pch_creations(this, _, result) }
/**
* Gets a source file that includes the PCH.
*/
File getAUse() { pch_uses(this, _, result) }
}

View File

@@ -222,6 +222,19 @@ extractor_version(
string frontend_version: string ref
)
pch_uses(
int pch: @pch ref,
int compilation: @compilation ref,
int id: @file ref
)
#keyset[pch, compilation]
pch_creations(
int pch: @pch,
int compilation: @compilation ref,
int from: @file ref
)
/** An element for which line-count information is available. */
@sourceline = @file | @function | @variable | @enumconstant | @xmllocatable;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: Link PCH creations and uses
compatibility: backwards