aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/src/xref_reader.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2017-09-13 14:58:40 +0200
committerHans Bolinder <[email protected]>2017-09-14 12:21:07 +0200
commit8d1b7f9c65f14aea03d63dbdba86b0ef96804fc4 (patch)
tree8cc26492ddfad02028f965436c2c0857f516a5ed /lib/tools/src/xref_reader.erl
parent15e3d354f56ea0b20ce3ab048c7574eed39b69b4 (diff)
downloadotp-8d1b7f9c65f14aea03d63dbdba86b0ef96804fc4.tar.gz
otp-8d1b7f9c65f14aea03d63dbdba86b0ef96804fc4.tar.bz2
otp-8d1b7f9c65f14aea03d63dbdba86b0ef96804fc4.zip
tools: Add handling of the -on_load() attribute to Xref
Diffstat (limited to 'lib/tools/src/xref_reader.erl')
-rw-r--r--lib/tools/src/xref_reader.erl18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/tools/src/xref_reader.erl b/lib/tools/src/xref_reader.erl
index 88f92df35a..d28bdb78db 100644
--- a/lib/tools/src/xref_reader.erl
+++ b/lib/tools/src/xref_reader.erl
@@ -42,7 +42,8 @@
%% experimental; -xref(FunEdge) is recognized.
lattrs=[], % local calls, {{mfa(),mfa()},Line}
xattrs=[], % external calls, -"-
- battrs=[] % badly formed xref attributes, term().
+ battrs=[], % badly formed xref attributes, term().
+ on_load % function name
}).
-include("xref.hrl").
@@ -68,15 +69,26 @@ forms([F | Fs], S) ->
forms([], S) ->
#xrefr{module = M, def_at = DefAt,
l_call_at = LCallAt, x_call_at = XCallAt,
- el = LC, ex = XC, x = X, df = Depr,
+ el = LC, ex = XC, x = X, df = Depr, on_load = OnLoad,
+ lattrs = AL, xattrs = AX, battrs = B, unresolved = U} = S,
+ OL = case OnLoad of
+ undefined -> [];
+ F ->
+ [{M, F, 0}]
+ end,
+ #xrefr{def_at = DefAt,
+ l_call_at = LCallAt, x_call_at = XCallAt,
+ el = LC, ex = XC, x = X, df = Depr, on_load = OnLoad,
lattrs = AL, xattrs = AX, battrs = B, unresolved = U} = S,
Attrs = {lists:reverse(AL), lists:reverse(AX), lists:reverse(B)},
- {ok, M, {DefAt, LCallAt, XCallAt, LC, XC, X, Attrs, Depr}, U}.
+ {ok, M, {DefAt, LCallAt, XCallAt, LC, XC, X, Attrs, Depr, OL}, U}.
form({attribute, Line, xref, Calls}, S) -> % experimental
#xrefr{module = M, function = Fun,
lattrs = L, xattrs = X, battrs = B} = S,
attr(Calls, erl_anno:line(Line), M, Fun, L, X, B, S);
+form({attribute, _, on_load, {F, 0}}, S) ->
+ S#xrefr{on_load = F};
form({attribute, _Line, _Attr, _Val}, S) ->
S;
form({function, _, module_info, 0, _Clauses}, S) ->