From 1ec96e17be9407c1fa5377eb660df18a7cecdeba Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Fri, 19 Aug 2016 09:39:56 +0200 Subject: [PATCH 1/5] Add documentation for ATTRIBUTE_KIND macro --- llvm-general/src/LLVM/General/Internal/FFI/Attribute.h | 3 +++ 1 file changed, 3 insertions(+) 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) \ From 7f1540b4e5ccc226038fcfb701bcc8d482b3b4b1 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 17 Aug 2016 10:30:50 +0200 Subject: [PATCH 2/5] Ignore tempfiles, stack.yaml and dist-newstyle # Conflicts: # .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) 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 From a9103b75449471e39fcefa64ac31bb0defb6c459 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Thu, 18 Aug 2016 19:59:56 +0200 Subject: [PATCH 3/5] Improve error messages on pattern match failure # Conflicts: # llvm-general/src/LLVM/General/Internal/Attribute.hs --- llvm-general/src/LLVM/General/Internal/Attribute.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm-general/src/LLVM/General/Internal/Attribute.hs b/llvm-general/src/LLVM/General/Internal/Attribute.hs index 17a110e2..dd9dd459 100644 --- a/llvm-general/src/LLVM/General/Internal/Attribute.hs +++ b/llvm-general/src/LLVM/General/Internal/Attribute.hs @@ -50,6 +50,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 _ -> error $ "llvm-general internal error: cases inconsistent in ParameterAttribute encoding for " ++ show a + A.PA.Dereferenceable _ -> error $ "llvm-general internal error: cases inconsistent in ParameterAttribute encoding for " ++ show 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 +88,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 _ -> error $ "llvm-general internal error: cases inconsistent in FunctionAttribute encoding for " ++ show a + A.FA.StringAttribute _ _ -> error $ "llvm-general internal error: cases inconsistent in FunctionAttribute encoding for " ++ show a instance DecodeM DecodeAST A.PA.ParameterAttribute FFI.ParameterAttribute where decodeM a = do From 71ee446060f904e55c4b3c879de6aefcfefc8cb1 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Tue, 23 Aug 2016 17:17:32 +0200 Subject: [PATCH 4/5] Extract error messages in a separate function # Conflicts: # llvm-general/src/LLVM/General/Internal/Attribute.hs --- llvm-general/src/LLVM/General/Internal/Attribute.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/llvm-general/src/LLVM/General/Internal/Attribute.hs b/llvm-general/src/LLVM/General/Internal/Attribute.hs index dd9dd459..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,8 +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 _ -> error $ "llvm-general internal error: cases inconsistent in ParameterAttribute encoding for " ++ show a - A.PA.Dereferenceable _ -> error $ "llvm-general internal error: cases inconsistent in ParameterAttribute encoding for " ++ show a + 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 @@ -88,8 +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 _ -> error $ "llvm-general internal error: cases inconsistent in FunctionAttribute encoding for " ++ show a - A.FA.StringAttribute _ _ -> error $ "llvm-general internal error: cases inconsistent in FunctionAttribute encoding for " ++ show a + A.FA.StackAlignment _ -> inconsistentCases "FunctionAttribute" a + A.FA.StringAttribute _ _ -> inconsistentCases "FunctionAttribute" a instance DecodeM DecodeAST A.PA.ParameterAttribute FFI.ParameterAttribute where decodeM a = do From 730ceeee3776a1f62bc874ec166d277124a2294b Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 21 Sep 2016 07:07:21 +0200 Subject: [PATCH 5/5] Ignore -fcolor-diagnostics (not a valid gcc arg) --- llvm-general/Setup.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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