mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-27 00:36:02 +08:00
@@ -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
|
||||
|
Reference in New Issue
Block a user