Skip to content

Commit 95794f9

Browse files
committed
C++: Handle values with no valuetext
1 parent 754612d commit 95794f9

File tree

1 file changed

+7
-1
lines changed
  • cpp/ql/src/semmle/code/cpp/exprs

1 file changed

+7
-1
lines changed

cpp/ql/src/semmle/code/cpp/exprs/Expr.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ class Expr extends StmtParent, @expr {
8888
string getValue() { exists(@value v | values(v,result) and valuebind(v,underlyingElement(this))) }
8989

9090
/** Gets the source text for the value of this expression, if it is a constant. */
91-
string getValueText() { exists(@value v | valuetext(v,result) and valuebind(v,underlyingElement(this))) }
91+
string getValueText() {
92+
exists(@value v |
93+
valuebind(v,underlyingElement(this)) and
94+
if valuetext(v, _)
95+
then valuetext(v, result)
96+
else values(v, result))
97+
}
9298

9399
/** Holds if this expression has a value that can be determined at compile time. */
94100
cached

0 commit comments

Comments
 (0)