Made the usage checking on PARs for plain variables ignore the variables declared inside the branches of that PAR
This commit is contained in:
parent
d9cfa9135d
commit
8174e86366
|
@ -165,17 +165,27 @@ checkPlainVarUsage (m, p) = {- liftIO (putStrLn ("Checking: " ++ show (m,p))) >>
|
||||||
getVars (SeqItems ss) = foldUnionVars $ map nodeVars ss
|
getVars (SeqItems ss) = foldUnionVars $ map nodeVars ss
|
||||||
getVars (ParItems ps) = foldUnionVars $ map getVars ps
|
getVars (ParItems ps) = foldUnionVars $ map getVars ps
|
||||||
getVars (RepParItem _ p) = getVars p
|
getVars (RepParItem _ p) = getVars p
|
||||||
|
|
||||||
|
getDecl :: ParItems UsageLabel -> [Var]
|
||||||
|
getDecl (ParItems ps) = concatMap getDecl ps
|
||||||
|
getDecl (RepParItem _ p) = getDecl p
|
||||||
|
getDecl (SeqItems ss) = mapMaybe
|
||||||
|
(fmap (Var . A.Variable emptyMeta . A.Name emptyMeta) . join . fmap getScopeIn . nodeDecl) ss
|
||||||
|
where
|
||||||
|
getScopeIn (ScopeIn _ n) = Just n
|
||||||
|
getScopeIn _ = Nothing
|
||||||
|
|
||||||
check :: ParItems UsageLabel -> m ()
|
check :: ParItems UsageLabel -> m ()
|
||||||
check (SeqItems {}) = return ()
|
check (SeqItems {}) = return ()
|
||||||
check (ParItems ps) = sequence_ $ permuteHelper checkCREW (map getVars ps)
|
check (ParItems ps) = sequence_ $ permuteHelper (checkCREW $ concatMap getDecl ps) (map getVars ps)
|
||||||
check (RepParItem _ p) = check (ParItems [p,p]) -- Easy way to check two replicated branches
|
check (RepParItem _ p) = check (ParItems [p,p]) -- Easy way to check two replicated branches
|
||||||
|
|
||||||
checkCREW :: Vars -> [Vars] -> m ()
|
checkCREW :: [Var] -> Vars -> [Vars] -> m ()
|
||||||
checkCREW item rest
|
checkCREW decl item rest
|
||||||
= do writtenTwice <- filterPlain $ Map.keysSet (writtenVars item) `Set.intersection` Map.keysSet
|
= do writtenTwice <- filterPlain $ (Map.keysSet (writtenVars item) `Set.intersection` Map.keysSet
|
||||||
(writtenVars otherVars)
|
(writtenVars otherVars)) `Set.difference` Set.fromList decl
|
||||||
writtenAndRead <- filterPlain $ Map.keysSet (writtenVars item) `Set.intersection` readVars otherVars
|
writtenAndRead <- filterPlain $ (Map.keysSet (writtenVars item) `Set.intersection` readVars otherVars)
|
||||||
|
`Set.difference` Set.fromList decl
|
||||||
when (not $ Set.null writtenTwice) $
|
when (not $ Set.null writtenTwice) $
|
||||||
diePC m $ formatCode
|
diePC m $ formatCode
|
||||||
"The following variables are written-to in at least two places inside a PAR: %" writtenTwice
|
"The following variables are written-to in at least two places inside a PAR: %" writtenTwice
|
||||||
|
|
Loading…
Reference in New Issue
Block a user