mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-16 10:03:08 -07:00
parent
f1148b8b41
commit
e9784fa9a7
2 changed files with 21 additions and 2 deletions
|
@ -56,6 +56,7 @@ module ShellCheck.CFGAnalysis (
|
|||
,SpaceStatus (..)
|
||||
,getIncomingState
|
||||
,getOutgoingState
|
||||
,doesPostDominate
|
||||
,ShellCheck.CFGAnalysis.runTests -- STRIP
|
||||
) where
|
||||
|
||||
|
@ -140,6 +141,15 @@ getOutgoingState analysis id = do
|
|||
(start,end) <- M.lookup id $ tokenToRange analysis
|
||||
snd <$> M.lookup end (nodeToData analysis)
|
||||
|
||||
-- Conveniently determine whether one node postdominates another,
|
||||
-- i.e. whether 'target' always unconditionally runs after 'base'.
|
||||
doesPostDominate :: CFGAnalysis -> Id -> Id -> Bool
|
||||
doesPostDominate analysis target base = fromMaybe False $ do
|
||||
(_, baseEnd) <- M.lookup base $ tokenToRange analysis
|
||||
(targetStart, _) <- M.lookup target $ tokenToRange analysis
|
||||
postDoms <- M.lookup baseEnd $ postDominators analysis
|
||||
return $ S.member targetStart postDoms
|
||||
|
||||
getDataForNode analysis node = M.lookup node $ nodeToData analysis
|
||||
|
||||
-- The current state of data flow at a point in the program, potentially as a diff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue