Created
June 2, 2014 20:37
-
-
Save apriori/0527c9d03b03fc5f5e10 to your computer and use it in GitHub Desktop.
Segfaults for any given .h/.cpp file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main (main) where | |
import Control.Monad | |
import Control.Monad.Trans.Control | |
import Control.Monad.Trans | |
import Control.Monad.IO.Class | |
import System.Environment | |
import Text.Printf | |
import qualified Data.Vector as DV(empty) | |
import Clang | |
import Clang.TranslationUnit(getCursor, withCreateIndex, withParse) | |
import Clang.Cursor | |
import Clang.String | |
import Clang.Module as M | |
import Clang.File as F | |
import qualified Data.Vector.Storable as DVS(mapM_) | |
test :: TranslationUnit s' -> Clang s () | |
test tu = getCursor tu >>= getChildren >>= DVS.mapM_ printInfo | |
where | |
printInfo :: Cursor s -> Clang s () | |
printInfo c = do | |
name <- getDisplayName c >>= unpack | |
tstr <- getCursorKindSpelling (getKind c) >>= unpack | |
moduleVar <- getCursor tu >>= getModule | |
moduleName <- return moduleVar >>= getFullName >>= unpack | |
tlh <- join . fmap (sequence . map (unpack <=< F.getName)) $ getTopLevelHeaders tu moduleVar | |
liftIO $ putStrLn $ "top level headers" ++ show tlh | |
liftIO $ printf "Module:%s, Name:%s, Kind:%s\n" moduleName name tstr | |
main :: IO () | |
main = do | |
(arg : args) <- getArgs | |
withCreateIndex False False $ \index -> | |
withParse index (Just arg) args DV.empty [TranslationUnit_None] test | |
return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment