mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
Before this change, `Expr.isConstant` only was only true for those constant expressions that could be represented as QL values: numbers, Booleans, and string literals. It was not true for string literals converted from arrays to pointers, and it was not true for addresses of variables with static lifetime. The concept of a "constant expression" varies between C and C++ and between versions of the standard, but they all include addresses of data with static lifetime. These are modelled by the new library `AddressConstantExpression.qll`, which is based on the code in `EscapesTree.qll` and modified for its new purpose. I've tested the change for performance on Wireshark and for correctness with the included tests. I've also checked on Wireshark that all static initializers in C files are considered constant, which was not the case before.