@@ -197,6 +197,8 @@ extension DIBuilder {
197197 /// by third-party tools.
198198 /// - splitDWARFPath: The path to the split DWARF file.
199199 /// - identity: The identity of the tool that is compiling this source file.
200+ /// - sysRoot: The Clang system root (the value of the `-isysroot` that's passed to clang).
201+ /// - sdkRoot: The SDK root -- on Darwin platforms, this is the last component of the sysroot.
200202 /// - Returns: A value representing a compilation-unit level scope.
201203 public func buildCompileUnit(
202204 for language: DWARFSourceLanguage ,
@@ -208,7 +210,9 @@ extension DIBuilder {
208210 flags: [ String ] = [ ] ,
209211 runtimeVersion: Int = 0 ,
210212 splitDWARFPath: String = " " ,
211- identity: String = " "
213+ identity: String = " " ,
214+ sysRoot: String = " " ,
215+ sdkRoot: String = " "
212216 ) -> CompileUnitMetadata {
213217 let allFlags = flags. joined ( separator: " " )
214218 guard let cu = LLVMDIBuilderCreateCompileUnit (
@@ -220,7 +224,11 @@ extension DIBuilder {
220224 kind. llvm,
221225 /*DWOId*/0 ,
222226 splitDebugInlining. llvm,
223- debugInfoForProfiling. llvm
227+ debugInfoForProfiling. llvm,
228+ sysRoot,
229+ sysRoot. count,
230+ sdkRoot,
231+ sdkRoot. count
224232 ) else {
225233 fatalError ( )
226234 }
@@ -860,15 +868,22 @@ extension DIBuilder {
860868 /// - Parameters:
861869 /// - type: Original type.
862870 /// - name: Typedef name.
871+ /// - alignment: Alignment of the type
863872 /// - scope: The surrounding context for the typedef.
864873 /// - file: File where this type is defined.
865874 /// - line: Line number.
866875 public func buildTypedef(
867- of type: DIType , name: String , scope: DIScope , file: FileMetadata , line: Int
876+ of type: DIType ,
877+ name: String ,
878+ alignment: Alignment = . one,
879+ scope: DIScope ,
880+ file: FileMetadata ,
881+ line: Int
868882 ) -> DIType {
869883 guard let ty = LLVMDIBuilderCreateTypedef (
870884 self . llvm, type. asMetadata ( ) , name, name. count,
871- file. asMetadata ( ) , UInt32 ( line) , scope. asMetadata ( ) )
885+ file. asMetadata ( ) , UInt32 ( line) , scope. asMetadata ( ) ,
886+ alignment. rawValue * 8 )
872887 else {
873888 fatalError ( " Failed to allocate metadata " )
874889 }
0 commit comments