mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge branch 'main' into add-comptr-model-now-with-more-models
This commit is contained in:
2436
cpp/downgrades/c16b29b27f71247023321cc0d0360998b318837c/old.dbscheme
Normal file
2436
cpp/downgrades/c16b29b27f71247023321cc0d0360998b318837c/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
description: Link PCH creations and uses
|
||||
compatibility: full
|
||||
pch_uses.rel: delete
|
||||
pch_creations.rel: delete
|
||||
5
cpp/ql/lib/change-notes/2025-08-27-pch.md
Normal file
5
cpp/ql/lib/change-notes/2025-08-27-pch.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
category: feature
|
||||
---
|
||||
* Added a new class `PchFile` representing precompiled header (PCH) files used during project compilation.
|
||||
|
||||
@@ -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
|
||||
|
||||
26
cpp/ql/lib/semmle/code/cpp/PchFile.qll
Normal file
26
cpp/ql/lib/semmle/code/cpp/PchFile.qll
Normal 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) }
|
||||
}
|
||||
@@ -3884,7 +3884,7 @@ class TranslatedNewExpr extends TranslatedNewOrNewArrayExpr {
|
||||
final override Type getTargetType() { result = expr.getAllocatedType().getUnspecifiedType() }
|
||||
|
||||
final override TranslatedInitialization getInitialization() {
|
||||
result = getTranslatedInitialization(expr.getInitializer())
|
||||
result = getTranslatedInitialization(expr.getInitializer().getFullyConverted())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
description: Link PCH creations and uses
|
||||
compatibility: backwards
|
||||
@@ -24550,6 +24550,37 @@ ir.cpp:
|
||||
# 2771| Type = [LValueReferenceType] ThreeWay &
|
||||
# 2771| ValueCategory = prvalue
|
||||
# 2772| getStmt(2): [ReturnStmt] return ...
|
||||
# 2774| [TopLevelFunction] void test_allocation_with_initializer()
|
||||
# 2774| <params>:
|
||||
# 2774| getEntryPoint(): [BlockStmt] { ... }
|
||||
# 2775| getStmt(0): [DeclStmt] declaration
|
||||
# 2775| getDeclarationEntry(0): [VariableDeclarationEntry] definition of p1
|
||||
# 2775| Type = [IntPointerType] int *
|
||||
# 2775| getVariable().getInitializer(): [Initializer] initializer for p1
|
||||
# 2775| getExpr(): [NewExpr] new
|
||||
# 2775| Type = [IntPointerType] int *
|
||||
# 2775| ValueCategory = prvalue
|
||||
# 2775| getInitializer(): [Literal] 42
|
||||
# 2775| Type = [IntType] int
|
||||
# 2775| Value = [Literal] 42
|
||||
# 2775| ValueCategory = prvalue
|
||||
# 2776| getStmt(1): [DeclStmt] declaration
|
||||
# 2776| getDeclarationEntry(0): [VariableDeclarationEntry] definition of p2
|
||||
# 2776| Type = [PointerType] long *
|
||||
# 2776| getVariable().getInitializer(): [Initializer] initializer for p2
|
||||
# 2776| getExpr(): [NewExpr] new
|
||||
# 2776| Type = [PointerType] long *
|
||||
# 2776| ValueCategory = prvalue
|
||||
# 2776| getInitializer(): [Literal] 42
|
||||
# 2776| Type = [IntType] int
|
||||
# 2776| Value = [Literal] 42
|
||||
# 2776| ValueCategory = prvalue
|
||||
# 2776| getInitializer().getFullyConverted(): [CStyleCast] (long)...
|
||||
# 2776| Conversion = [IntegralConversion] integral conversion
|
||||
# 2776| Type = [LongType] long
|
||||
# 2776| Value = [CStyleCast] 42
|
||||
# 2776| ValueCategory = prvalue
|
||||
# 2777| getStmt(2): [ReturnStmt] return ...
|
||||
ir23.cpp:
|
||||
# 1| [TopLevelFunction] bool consteval_1()
|
||||
# 1| <params>:
|
||||
|
||||
@@ -20395,6 +20395,41 @@ ir.cpp:
|
||||
# 2769| v2769_14(void) = AliasedUse : ~m2771_8
|
||||
# 2769| v2769_15(void) = ExitFunction :
|
||||
|
||||
# 2774| void test_allocation_with_initializer()
|
||||
# 2774| Block 0
|
||||
# 2774| v2774_1(void) = EnterFunction :
|
||||
# 2774| m2774_2(unknown) = AliasedDefinition :
|
||||
# 2774| m2774_3(unknown) = InitializeNonLocal :
|
||||
# 2774| m2774_4(unknown) = Chi : total:m2774_2, partial:m2774_3
|
||||
# 2775| r2775_1(glval<int *>) = VariableAddress[p1] :
|
||||
# 2775| r2775_2(glval<unknown>) = FunctionAddress[operator new] :
|
||||
# 2775| r2775_3(unsigned long) = Constant[4] :
|
||||
# 2775| r2775_4(void *) = Call[operator new] : func:r2775_2, 0:r2775_3
|
||||
# 2775| m2775_5(unknown) = ^CallSideEffect : ~m2774_4
|
||||
# 2775| m2775_6(unknown) = Chi : total:m2774_4, partial:m2775_5
|
||||
# 2775| m2775_7(unknown) = ^InitializeDynamicAllocation : &:r2775_4
|
||||
# 2775| r2775_8(int *) = Convert : r2775_4
|
||||
# 2775| r2775_9(int) = Constant[42] :
|
||||
# 2775| m2775_10(int) = Store[?] : &:r2775_8, r2775_9
|
||||
# 2775| m2775_11(unknown) = Chi : total:m2775_7, partial:m2775_10
|
||||
# 2775| m2775_12(int *) = Store[p1] : &:r2775_1, r2775_8
|
||||
# 2776| r2776_1(glval<long *>) = VariableAddress[p2] :
|
||||
# 2776| r2776_2(glval<unknown>) = FunctionAddress[operator new] :
|
||||
# 2776| r2776_3(unsigned long) = Constant[8] :
|
||||
# 2776| r2776_4(void *) = Call[operator new] : func:r2776_2, 0:r2776_3
|
||||
# 2776| m2776_5(unknown) = ^CallSideEffect : ~m2775_6
|
||||
# 2776| m2776_6(unknown) = Chi : total:m2775_6, partial:m2776_5
|
||||
# 2776| m2776_7(unknown) = ^InitializeDynamicAllocation : &:r2776_4
|
||||
# 2776| r2776_8(long *) = Convert : r2776_4
|
||||
# 2776| r2776_9(long) = Constant[42] :
|
||||
# 2776| m2776_10(long) = Store[?] : &:r2776_8, r2776_9
|
||||
# 2776| m2776_11(unknown) = Chi : total:m2776_7, partial:m2776_10
|
||||
# 2776| m2776_12(long *) = Store[p2] : &:r2776_1, r2776_8
|
||||
# 2777| v2777_1(void) = NoOp :
|
||||
# 2774| v2774_5(void) = ReturnVoid :
|
||||
# 2774| v2774_6(void) = AliasedUse : ~m2776_6
|
||||
# 2774| v2774_7(void) = ExitFunction :
|
||||
|
||||
ir23.cpp:
|
||||
# 1| bool consteval_1()
|
||||
# 1| Block 0
|
||||
|
||||
@@ -2771,4 +2771,9 @@ void test_three_way(int a, int b, ThreeWay c, ThreeWay d) {
|
||||
auto y = c <=> d;
|
||||
}
|
||||
|
||||
void test_allocation_with_initializer() {
|
||||
int* p1 = new int(42);
|
||||
long* p2 = new long(42);
|
||||
}
|
||||
|
||||
// semmle-extractor-options: -std=c++20 --clang
|
||||
|
||||
@@ -18547,6 +18547,36 @@ ir.cpp:
|
||||
# 2769| v2769_13(void) = AliasedUse : ~m?
|
||||
# 2769| v2769_14(void) = ExitFunction :
|
||||
|
||||
# 2774| void test_allocation_with_initializer()
|
||||
# 2774| Block 0
|
||||
# 2774| v2774_1(void) = EnterFunction :
|
||||
# 2774| mu2774_2(unknown) = AliasedDefinition :
|
||||
# 2774| mu2774_3(unknown) = InitializeNonLocal :
|
||||
# 2775| r2775_1(glval<int *>) = VariableAddress[p1] :
|
||||
# 2775| r2775_2(glval<unknown>) = FunctionAddress[operator new] :
|
||||
# 2775| r2775_3(unsigned long) = Constant[4] :
|
||||
# 2775| r2775_4(void *) = Call[operator new] : func:r2775_2, 0:r2775_3
|
||||
# 2775| mu2775_5(unknown) = ^CallSideEffect : ~m?
|
||||
# 2775| mu2775_6(unknown) = ^InitializeDynamicAllocation : &:r2775_4
|
||||
# 2775| r2775_7(int *) = Convert : r2775_4
|
||||
# 2775| r2775_8(int) = Constant[42] :
|
||||
# 2775| mu2775_9(int) = Store[?] : &:r2775_7, r2775_8
|
||||
# 2775| mu2775_10(int *) = Store[p1] : &:r2775_1, r2775_7
|
||||
# 2776| r2776_1(glval<long *>) = VariableAddress[p2] :
|
||||
# 2776| r2776_2(glval<unknown>) = FunctionAddress[operator new] :
|
||||
# 2776| r2776_3(unsigned long) = Constant[8] :
|
||||
# 2776| r2776_4(void *) = Call[operator new] : func:r2776_2, 0:r2776_3
|
||||
# 2776| mu2776_5(unknown) = ^CallSideEffect : ~m?
|
||||
# 2776| mu2776_6(unknown) = ^InitializeDynamicAllocation : &:r2776_4
|
||||
# 2776| r2776_7(long *) = Convert : r2776_4
|
||||
# 2776| r2776_8(long) = Constant[42] :
|
||||
# 2776| mu2776_9(long) = Store[?] : &:r2776_7, r2776_8
|
||||
# 2776| mu2776_10(long *) = Store[p2] : &:r2776_1, r2776_7
|
||||
# 2777| v2777_1(void) = NoOp :
|
||||
# 2774| v2774_4(void) = ReturnVoid :
|
||||
# 2774| v2774_5(void) = AliasedUse : ~m?
|
||||
# 2774| v2774_6(void) = ExitFunction :
|
||||
|
||||
ir23.cpp:
|
||||
# 1| bool consteval_1()
|
||||
# 1| Block 0
|
||||
|
||||
Reference in New Issue
Block a user