Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/Text/LLVM/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ module Text.LLVM.AST
, DICompositeType'(..), DICompositeType
, DIDerivedType'(..), DIDerivedType
, DIExpression(..)
, DIFile(..)
, DIFile'(..), DIFile
, DIChecksumKind(..)
, DIGlobalVariable'(..), DIGlobalVariable
, DIGlobalVariableExpression'(..), DIGlobalVariableExpression
, DILexicalBlock'(..), DILexicalBlock
Expand Down Expand Up @@ -1748,7 +1749,7 @@ data DebugInfo' lab
| DebugInfoEnumerator String !Integer Bool
-- ^ The 'Bool' field represents @isUnsigned@, introduced in LLVM 7.
| DebugInfoExpression DIExpression
| DebugInfoFile DIFile
| DebugInfoFile (DIFile' lab)
| DebugInfoGlobalVariable (DIGlobalVariable' lab)
| DebugInfoGlobalVariableExpression (DIGlobalVariableExpression' lab)
| DebugInfoLexicalBlock (DILexicalBlock' lab)
Expand Down Expand Up @@ -1951,10 +1952,22 @@ data DIExpression = DIExpression
{ dieElements :: [Word64]
} deriving (Data, Eq, Generic, Ord, Show, Typeable)

data DIFile = DIFile
data DIFile' lab = DIFile
{ difFilename :: FilePath
, difDirectory :: FilePath
} deriving (Data, Eq, Generic, Ord, Show, Typeable)
, difChecksumKind :: DIChecksumKind
, difChecksum :: Maybe String
Comment on lines +1958 to +1959
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these fields introduced in a particular LLVM version? If so, should this be documented here in the Haddocks?

} deriving (Data, Eq, Functor, Generic, Generic1, Ord, Show, Typeable)

type DIFile = DIFile' BlockLabel

data DIChecksumKind
= CSK_None -- ^ == 0. Originally indicated no checksum, now handled by optional
-- encoding
| CSK_MD5 -- ^ == 1
| CSK_SHA1 -- ^ == 2
| CSK_SHA256 -- ^ == 3
deriving (Data, Eq, Generic, Ord, Show, Typeable)

data DIGlobalVariable' lab = DIGlobalVariable
{ digvScope :: Maybe (ValMd' lab)
Expand Down
1 change: 1 addition & 0 deletions src/Text/LLVM/Labels.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
instance HasLabel DIGlobalVariableExpression' where relabel = $(generateRelabel 'relabel ''DIGlobalVariableExpression')
instance HasLabel DILocalVariable' where relabel = $(generateRelabel 'relabel ''DILocalVariable')
instance HasLabel DISubprogram' where relabel = $(generateRelabel 'relabel ''DISubprogram')
instance HasLabel DIFile' where relabel = $(generateRelabel 'relabel ''DIFile')

Check warning on line 146 in src/Text/LLVM/Labels.hs

View workflow job for this annotation

GitHub Actions / ubuntu-24.04 - GHC 9.8.4 - Cabal 3.14.2.0 / CI

Defined but not used: ‘f’

Check warning on line 146 in src/Text/LLVM/Labels.hs

View workflow job for this annotation

GitHub Actions / ubuntu-24.04 - GHC 9.6.7 - Cabal 3.14.2.0 / CI

Defined but not used: ‘f’

Check warning on line 146 in src/Text/LLVM/Labels.hs

View workflow job for this annotation

GitHub Actions / ubuntu-24.04 - GHC 9.10.1 - Cabal 3.14.2.0 / CI

Defined but not used: ‘f’
instance HasLabel DICompositeType' where relabel = $(generateRelabel 'relabel ''DICompositeType')
instance HasLabel DILexicalBlock' where relabel = $(generateRelabel 'relabel ''DILexicalBlock')
instance HasLabel DICompileUnit' where relabel = $(generateRelabel 'relabel ''DICompileUnit')
Expand Down
2 changes: 1 addition & 1 deletion src/Text/LLVM/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ concat <$> mapM (makeLensesWith (lensRules & lensField .~ (\_ _ n -> [TopName $
, ''Linkage
, ''DebugLoc'
, ''DebugInfo'
, ''DIFile
, ''DIFile'
, ''DISubrange'
, ''DIBasicType'
, ''DIExpression
Expand Down
11 changes: 7 additions & 4 deletions src/Text/LLVM/PP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,11 +1329,14 @@ ppDIExpression :: Fmt DIExpression
ppDIExpression e = "!DIExpression"
<> parens (commas (map integral (dieElements e)))

ppDIFile :: Fmt DIFile
ppDIFile :: Fmt (DIFile' i)
ppDIFile f = "!DIFile"
<> parens (commas [ "filename:" <+> doubleQuotes (text (difFilename f))
, "directory:" <+> doubleQuotes (text (difDirectory f))
])
<> parens (mcommas
[ pure ("filename:" <+> doubleQuotes (text (difFilename f)))
, pure ("directory:" <+> doubleQuotes (text (difDirectory f)))
, pure ("checksumkind:" <+> (text $ show $ difChecksumKind f))
, (("checksum:" <+>) . doubleQuotes . text) <$> (difChecksum f)
])

ppDIGlobalVariable' :: Fmt i -> Fmt (DIGlobalVariable' i)
ppDIGlobalVariable' pp gv = "!DIGlobalVariable"
Expand Down