Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a412c9

Browse files
committed
C++: handle __uuidof(0)
1 parent 3e17196 commit 9a412c9

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,12 @@ class DynamicCast extends Cast, @dynamic_cast {
497497
* specified by the `__declspec(uuid)` attribute.
498498
*/
499499
class UuidofOperator extends Expr, @uuidof {
500-
override string toString() { result = "__uuidof(" + getTypeOperand().getName() + ")" }
500+
override string toString() {
501+
if exists(getTypeOperand()) then
502+
result = "__uuidof(" + getTypeOperand().getName() + ")"
503+
else
504+
result = "__uuidof(0)"
505+
}
501506

502507
override int getPrecedence() { result = 15 }
503508

cpp/ql/test/library-tests/literals/uuidof/uuidof.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ void GetUUID() {
1515
uuid = __uuidof(Templ<S>);
1616
S s;
1717
uuid = __uuidof(s);
18+
uuid = __uuidof(0);
1819
}
1920
// semmle-extractor-options: --microsoft

cpp/ql/test/library-tests/literals/uuidof/uuidof.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ uuidofOperators
1111
| uuidof.cpp:14:12:14:30 | __uuidof(S) | const _GUID | 01234567-89ab-cdef-0123-456789abcdef |
1212
| uuidof.cpp:15:12:15:29 | __uuidof(S) | const _GUID | 01234567-89ab-cdef-0123-456789abcdef |
1313
| uuidof.cpp:17:12:17:22 | __uuidof(S) | const _GUID | 01234567-89ab-cdef-0123-456789abcdef |
14+
| uuidof.cpp:18:12:18:22 | __uuidof(0) | const _GUID | 00000000-0000-0000-0000-000000000000 |

0 commit comments

Comments
 (0)