C++ IR: Support __builtin_addressof

This commit is contained in:
Jonas Jensen
2019-07-04 16:34:43 +02:00
parent 50e8034b0b
commit 4b4e7caf9f
4 changed files with 34 additions and 1 deletions

View File

@@ -174,6 +174,17 @@ bad_asts.cpp:
# 27| Type = const Point &
# 27| ValueCategory = prvalue(load)
# 28| 1: return ...
clang.cpp:
# 5| int* globalIntAddress()
# 5| params:
# 5| body: { ... }
# 6| 0: return ...
# 6| 0: __builtin_addressof ...
# 6| Type = int *
# 6| ValueCategory = prvalue
# 6| 0: globalInt
# 6| Type = int
# 6| ValueCategory = lvalue
ir.cpp:
# 1| void Constants()
# 1| params:

View File

@@ -0,0 +1,7 @@
// semmle-extractor-options: --clang
int globalInt;
int *globalIntAddress() {
return __builtin_addressof(globalInt);
}

View File

@@ -48,6 +48,20 @@ bad_asts.cpp:
# 26| v0_13(void) = UnmodeledUse : mu*
# 26| v0_14(void) = ExitFunction :
clang.cpp:
# 5| int* globalIntAddress()
# 5| Block 0
# 5| v0_0(void) = EnterFunction :
# 5| mu0_1(unknown) = AliasedDefinition :
# 5| mu0_2(unknown) = UnmodeledDefinition :
# 6| r0_3(glval<int *>) = VariableAddress[#return] :
# 6| r0_4(glval<int>) = VariableAddress[globalInt] :
# 6| mu0_5(int *) = Store : &:r0_3, r0_4
# 5| r0_6(glval<int *>) = VariableAddress[#return] :
# 5| v0_7(void) = ReturnValue : &:r0_6, ~mu0_2
# 5| v0_8(void) = UnmodeledUse : mu*
# 5| v0_9(void) = ExitFunction :
ir.cpp:
# 1| void Constants()
# 1| Block 0