diff --git a/.gitignore b/.gitignore index 2e339242..691de0e8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ out .DS_Store .cabal-sandbox cabal.sandbox.config +.stack-work +/dist-newstyle/ +*~ +/stack.yaml diff --git a/llvm-general/Setup.hs b/llvm-general/Setup.hs index 574bf718..716d09b1 100644 --- a/llvm-general/Setup.hs +++ b/llvm-general/Setup.hs @@ -103,10 +103,10 @@ addLLVMToLdLibraryPath configFlags = do -- linking against LLVM build with Clang using GCC ignoredCxxFlags :: [String] ignoredCxxFlags = - ["-Wcovered-switch-default"] ++ map ("-D" ++) uncheckedHsFFIDefines + ["-Wcovered-switch-default", "-fcolor-diagnostics"] ++ map ("-D" ++) uncheckedHsFFIDefines ignoredCFlags :: [String] -ignoredCFlags = ["-Wcovered-switch-default", "-Wdelete-non-virtual-dtor"] +ignoredCFlags = ["-Wcovered-switch-default", "-Wdelete-non-virtual-dtor", "-fcolor-diagnostics"] main = do let origUserHooks = simpleUserHooks diff --git a/llvm-general/src/LLVM/General/Internal/Attribute.hs b/llvm-general/src/LLVM/General/Internal/Attribute.hs index 17a110e2..1beab26e 100644 --- a/llvm-general/src/LLVM/General/Internal/Attribute.hs +++ b/llvm-general/src/LLVM/General/Internal/Attribute.hs @@ -32,6 +32,10 @@ import LLVM.General.Internal.Context import LLVM.General.Internal.EncodeAST import LLVM.General.Internal.DecodeAST +inconsistentCases :: Show a => String -> a -> b +inconsistentCases name attr = + error $ "llvm-general internal error: cases inconstistent in " ++ name ++ " encoding for " ++ show attr + instance Monad m => EncodeM m A.PA.ParameterAttribute (Ptr FFI.ParameterAttrBuilder -> EncodeAST ()) where encodeM a = return $ \b -> liftIO $ case a of A.PA.Alignment v -> FFI.attrBuilderAddAlignment b v @@ -50,6 +54,8 @@ instance Monad m => EncodeM m A.PA.ParameterAttribute (Ptr FFI.ParameterAttrBuil A.PA.InAlloca -> FFI.parameterAttributeKindInAlloca A.PA.NonNull -> FFI.parameterAttributeKindNonNull A.PA.Returned -> FFI.parameterAttributeKindReturned + A.PA.Alignment _ -> inconsistentCases "ParameterAttribute" a + A.PA.Dereferenceable _ -> inconsistentCases "ParameterAttribute" a instance Monad m => EncodeM m A.FA.FunctionAttribute (Ptr FFI.FunctionAttrBuilder -> EncodeAST ()) where encodeM (A.FA.StringAttribute kind value) = return $ \b -> do @@ -86,6 +92,8 @@ instance Monad m => EncodeM m A.FA.FunctionAttribute (Ptr FFI.FunctionAttrBuilde A.FA.SanitizeAddress -> FFI.functionAttributeKindSanitizeAddress A.FA.SanitizeThread -> FFI.functionAttributeKindSanitizeThread A.FA.SanitizeMemory -> FFI.functionAttributeKindSanitizeMemory + A.FA.StackAlignment _ -> inconsistentCases "FunctionAttribute" a + A.FA.StringAttribute _ _ -> inconsistentCases "FunctionAttribute" a instance DecodeM DecodeAST A.PA.ParameterAttribute FFI.ParameterAttribute where decodeM a = do diff --git a/llvm-general/src/LLVM/General/Internal/FFI/Attribute.h b/llvm-general/src/LLVM/General/Internal/FFI/Attribute.h index 1f2c0ece..6638a595 100644 --- a/llvm-general/src/LLVM/General/Internal/FFI/Attribute.h +++ b/llvm-general/src/LLVM/General/Internal/FFI/Attribute.h @@ -1,6 +1,9 @@ #ifndef __LLVM_GENERAL_INTERNAL_FFI__ATTRIBUTES__H__ #define __LLVM_GENERAL_INTERNAL_FFI__ATTRIBUTES__H__ + +// The last three arguments are flags indicating if this is a +// parameter attribute, function result attribute or function attribute. #define LLVM_GENERAL_FOR_EACH_ATTRIBUTE_KIND(macro) \ macro(None,F,F,F) \ macro(Alignment,T,F,F) \