From 8f9849b30b934c2f094df880c297089fbe5d20c8 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Thu, 3 Jan 2019 13:33:37 +0100 Subject: [PATCH] C++: Add BuiltInIntAddr class for __INTADDR__ --- cpp/ql/src/semmle/code/cpp/exprs/BuiltInOperations.qll | 9 ++++++++- cpp/ql/test/library-tests/builtins/edg/expr.expected | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cpp/ql/src/semmle/code/cpp/exprs/BuiltInOperations.qll b/cpp/ql/src/semmle/code/cpp/exprs/BuiltInOperations.qll index cd25fd45f79..68ecce75ab3 100644 --- a/cpp/ql/src/semmle/code/cpp/exprs/BuiltInOperations.qll +++ b/cpp/ql/src/semmle/code/cpp/exprs/BuiltInOperations.qll @@ -42,12 +42,19 @@ class BuiltInNoOp extends BuiltInOperation, @noopexpr { } /** - * A C++ `__offsetof` expression (used by some implementations of offsetof in the presence of user-defined `operator&`). + * A C++ `__offsetof` expression (used by some implementations of offsetof in the presence of user-defined `operator&`). */ class BuiltInOperationOffsetOf extends BuiltInOperation, @offsetofexpr { override string toString() { result = "__offsetof" } } +/** + * A C/C++ `__INTADDR__` expression, used by EDG to implement `offsetof` in the presence of user-defined `operator&`. + */ +class BuiltInIntAddr extends BuiltInOperation, @intaddrexpr { + override string toString() { result = "__INTADDR__" } +} + /** * A C++ `__has_assign` expression (used by some implementations of the type_traits header). */ diff --git a/cpp/ql/test/library-tests/builtins/edg/expr.expected b/cpp/ql/test/library-tests/builtins/edg/expr.expected index ed5cffd449f..8bae66651e7 100644 --- a/cpp/ql/test/library-tests/builtins/edg/expr.expected +++ b/cpp/ql/test/library-tests/builtins/edg/expr.expected @@ -8,6 +8,7 @@ | edg.c:13:14:13:45 | (...) | 0 | 0 | | edg.c:13:14:13:45 | (mystruct *)... | 0 | 0 | | edg.c:13:14:13:45 | (size_t)... | 0 | 0 | +| edg.c:13:14:13:45 | __INTADDR__ | 1 | 1 | | edg.c:13:43:13:44 | f2 | 0 | 0 | | file://:0:0:0:0 | 0 | 0 | 0 | | file://:0:0:0:0 | * ... | 0 | 0 |