aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/src/xref_reader.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2017-09-15 07:54:32 +0200
committerHans Bolinder <[email protected]>2017-09-15 07:54:32 +0200
commit40ab89f78863b17f8657b8c4575b4a904eb395ae (patch)
treee65d449e42ddc67fa8dd90014e17620ee34c0f81 /lib/tools/src/xref_reader.erl
parent94333e038485030f385012c99c0e7995ae03f499 (diff)
parent8d1b7f9c65f14aea03d63dbdba86b0ef96804fc4 (diff)
downloadotp-40ab89f78863b17f8657b8c4575b4a904eb395ae.tar.gz
otp-40ab89f78863b17f8657b8c4575b4a904eb395ae.tar.bz2
otp-40ab89f78863b17f8657b8c4575b4a904eb395ae.zip
Merge branch 'hasse/tools/xref_on_load/OTP-14344' into maint
* hasse/tools/xref_on_load/OTP-14344: tools: Add handling of the -on_load() attribute to Xref tools: Correction of xref(3)
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) ->