Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

C++: Generate IR for assertions in release builds #21142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
MathiasVP merged 17 commits into github:main from MathiasVP:ir-support-for-assertions
Jan 21, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6e3fd25
C++: Add tests for assertions in release builds.
MathiasVP Jan 9, 2026
67ab0fe
C++: Add a few helper predicates.
MathiasVP Jan 9, 2026
a18f3b6
C++: Avoid generating IR for a few cases where we will be synthesizin...
MathiasVP Jan 9, 2026
aa058c2
C++: Generate IR for assertions in release builds.
MathiasVP Jan 9, 2026
4f4baee
C++: Fix Code Scanning alerts.
MathiasVP Jan 9, 2026
d6ca1ca
Update cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/Tran...
MathiasVP Jan 15, 2026
1b11790
Update cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/Tran...
MathiasVP Jan 15, 2026
03d6528
Update cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/Tran...
MathiasVP Jan 15, 2026
58a3260
Update cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/Tran...
MathiasVP Jan 19, 2026
b363154
C++: Delete unnecessary conjuncts after review comments.
MathiasVP Jan 19, 2026
d183dcd
C++: Add 'internal: do not use' comment.
MathiasVP Jan 19, 2026
048afc2
C++: Add assertion inside catch block. This does not yet work because...
MathiasVP Jan 20, 2026
c30dffc
C++: Add more tests.
MathiasVP Jan 21, 2026
e4ec792
C++: Fix bugs in variable resolution for assertions following review ...
MathiasVP Jan 21, 2026
11566ee
C++: Accept test changes.
MathiasVP Jan 21, 2026
e1089c8
Merge branch 'main' into ir-support-for-assertions
MathiasVP Jan 21, 2026
64a7d7d
C++: Also output variable name in test.
MathiasVP Jan 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cpp/ql/lib/semmle/code/cpp/Element.qll
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ class Element extends ElementBase {
*/
predicate isAffectedByMacro() { affectedByMacro(this) }

/**
* INTERNAL: Do not use.
*
* Holds if this element is affected by the expansion of `mi`.
*/
predicate isAffectedByMacro(MacroInvocation mi) {
affectedbymacroexpansion(underlyingElement(this), unresolveElement(mi))
}

private Element getEnclosingElementPref() {
enclosingfunction(underlyingElement(this), unresolveElement(result)) or
result.(Function) = stmtEnclosingElement(this) or
Expand Down
3 changes: 3 additions & 0 deletions cpp/ql/lib/semmle/code/cpp/Macro.qll
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ class MacroInvocation extends MacroAccess {
macro_argument_unexpanded(underlyingElement(this), i, result)
}

/** Gets the number of arguments for this macro invocation. */
int getNumberOfArguments() { result = count(int i | exists(this.getUnexpandedArgument(i)) | i) }

/**
* Gets the `i`th _expanded_ argument of this macro invocation, where the
* first argument has `i = 0`. The result has been expanded for macros _and_
Expand Down
2 changes: 1 addition & 1 deletion cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Expr extends StmtParent, @expr {
predicate hasChild(Expr e, int n) { e = this.getChild(n) }

/** Gets the enclosing function of this expression, if any. */
Function getEnclosingFunction() { result = exprEnclosingElement(this) }
override Function getEnclosingFunction() { result = exprEnclosingElement(this) }

/** Gets the nearest enclosing set of curly braces around this expression in the source, if any. */
BlockStmt getEnclosingBlock() { result = this.getEnclosingStmt().getEnclosingBlock() }
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ newtype TInstructionTag =
} or
SizeofVlaDimensionTag(int index) {
exists(VlaDeclStmt v | exists(v.getTransitiveVlaDimensionStmt(index)))
}
} or
AssertionVarAddressTag() or
AssertionVarLoadTag() or
AssertionOpTag() or
AssertionBranchTag()

class InstructionTag extends TInstructionTag {
final string toString() { result = getInstructionTagId(this) }
Expand Down Expand Up @@ -296,4 +300,12 @@ string getInstructionTagId(TInstructionTag tag) {
tag = CoAwaitBranchTag() and result = "CoAwaitBranch"
or
tag = BoolToIntConversionTag() and result = "BoolToIntConversion"
or
tag = AssertionVarAddressTag() and result = "AssertionVarAddress"
or
tag = AssertionVarLoadTag() and result = "AssertionVarLoad"
or
tag = AssertionOpTag() and result = "AssertionOp"
or
tag = AssertionBranchTag() and result = "AssertionBranch"
}
Loading
Loading

AltStyle によって変換されたページ (->オリジナル) /