File tree Expand file tree Collapse file tree 4 files changed +34
-1
lines changed
src/semmle/code/cpp/ir/implementation/raw/internal Expand file tree Collapse file tree 4 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -727,7 +727,8 @@ class TranslatedTransparentUnaryOperation extends TranslatedTransparentExpr {
727727 expr instanceof PointerDereferenceExpr or
728728 // &x is the same as x. &x isn't loadable, but is included
729729 // here to avoid having two nearly identical classes.
730- expr instanceof AddressOfExpr
730+ expr instanceof AddressOfExpr or
731+ expr instanceof BuiltInOperationBuiltInAddressOf
731732 )
732733 }
733734
Original file line number Diff line number Diff line change @@ -190,6 +190,17 @@ bad_asts.cpp:
190190# 27| Type = const Point &
191191# 27| ValueCategory = prvalue(load)
192192# 28| 1: return ...
193+ clang.cpp:
194+ # 5| int* globalIntAddress()
195+ # 5| params:
196+ # 5| body: { ... }
197+ # 6| 0: return ...
198+ # 6| 0: __builtin_addressof ...
199+ # 6| Type = int *
200+ # 6| ValueCategory = prvalue
201+ # 6| 0: globalInt
202+ # 6| Type = int
203+ # 6| ValueCategory = lvalue
193204ir.cpp:
194205# 1| void Constants()
195206# 1| params:
Original file line number Diff line number Diff line change 1+ // semmle-extractor-options: --clang
2+
3+ int globalInt;
4+
5+ int *globalIntAddress () {
6+ return __builtin_addressof (globalInt);
7+ }
Original file line number Diff line number Diff line change @@ -48,6 +48,20 @@ bad_asts.cpp:
4848# 26| v0_13(void) = UnmodeledUse : mu*
4949# 26| v0_14(void) = ExitFunction :
5050
51+ clang.cpp:
52+ # 5| int* globalIntAddress()
53+ # 5| Block 0
54+ # 5| v0_0(void) = EnterFunction :
55+ # 5| mu0_1(unknown) = AliasedDefinition :
56+ # 5| mu0_2(unknown) = UnmodeledDefinition :
57+ # 6| r0_3(glval<int *>) = VariableAddress[#return] :
58+ # 6| r0_4(glval<int>) = VariableAddress[globalInt] :
59+ # 6| mu0_5(int *) = Store : &:r0_3, r0_4
60+ # 5| r0_6(glval<int *>) = VariableAddress[#return] :
61+ # 5| v0_7(void) = ReturnValue : &:r0_6, ~mu0_2
62+ # 5| v0_8(void) = UnmodeledUse : mu*
63+ # 5| v0_9(void) = ExitFunction :
64+
5165ir.cpp:
5266# 1| void Constants()
5367# 1| Block 0
You can’t perform that action at this time.
0 commit comments