summaryrefslogtreecommitdiff
path: root/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs
blob: 7615a3c69e5717faa3dcb4bdfaa201d4c03a994f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE TemplateHaskell #-}

module T16104_Plugin (plugin) where

import GHC.Plugins
import Data.Bits
import System.IO

plugin :: Plugin
plugin = defaultPlugin {installCoreToDos = install}
  where install _ todos = return (test : todos)

        test = CoreDoPluginPass "Test" check

        check :: ModGuts -> CoreM ModGuts
        check m = do mbN <- thNameToGhcName 'complement
                     case mbN of
                       Just _  -> do
                        liftIO $ putStrLn "Found complement!"
                        -- TODO: Remove #20791
                        liftIO $ hFlush stdout
                       Nothing -> error "Failed to locate complement"

                     return m