Index: include/llvm-c/DebugInfo.h =================================================================== --- include/llvm-c/DebugInfo.h +++ include/llvm-c/DebugInfo.h @@ -122,6 +122,14 @@ } LLVMDWARFEmissionKind; /** + * Which algorithm a checksum was generated with. + */ +typedef enum { + LLVMDIFileChecksumMD5 = 1, + LLVMDIFileChecksumSHA1 = 2, +} LLVMDIFileChecksumKind; + +/** * The current debug metadata version number. */ unsigned LLVMDebugMetadataVersion(void); @@ -210,7 +218,9 @@ LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, const char *Directory, - size_t DirectoryLen); + size_t DirectoryLen, LLVMBool ChecksumPresent, + LLVMDIFileChecksumKind ChecksumKind, + const char *Checksum, size_t ChecksumLen); /** * Creates a new DebugLocation that describes a source location. Index: lib/IR/DebugInfo.cpp =================================================================== --- lib/IR/DebugInfo.cpp +++ lib/IR/DebugInfo.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -741,9 +742,16 @@ LLVMMetadataRef LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, const char *Directory, - size_t DirectoryLen) { + size_t DirectoryLen, LLVMBool ChecksumPresent, + LLVMDIFileChecksumKind ChecksumKind, + const char *Checksum, size_t ChecksumLen) { + Optional> OptChecksum; + if (ChecksumPresent) + OptChecksum.emplace(static_cast(ChecksumKind), + StringRef(Checksum, ChecksumLen)); return wrap(unwrap(Builder)->createFile(StringRef(Filename, FilenameLen), - StringRef(Directory, DirectoryLen))); + StringRef(Directory, DirectoryLen), + OptChecksum)); } LLVMMetadataRef Index: test/Bindings/llvm-c/debug_info.ll =================================================================== --- test/Bindings/llvm-c/debug_info.ll +++ test/Bindings/llvm-c/debug_info.ll @@ -3,6 +3,8 @@ ; CHECK: ; ModuleID = 'debuginfo.c' ; CHECK-NEXT: source_filename = "debuginfo.c" -; CHECK: !llvm.dbg.cu = !{!0} +; CHECK: !llvm.dbg.cu = !{!0, !2} ; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) -; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c\00", directory: ".") +; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".") +; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false) +; CHECK-NEXT: !3 = !DIFile(filename: "a.h", directory: ".", checksumkind: CSK_MD5, checksum: "595f44fec1e92a71d3e9e77456ba80d1") Index: tools/llvm-c-test/debuginfo.c =================================================================== --- tools/llvm-c-test/debuginfo.c +++ tools/llvm-c-test/debuginfo.c @@ -18,13 +18,21 @@ LLVMModuleRef M = LLVMModuleCreateWithName("debuginfo.c"); LLVMDIBuilderRef DIB = LLVMCreateDIBuilder(M); - LLVMMetadataRef File = LLVMDIBuilderCreateFile(DIB, "debuginfo.c", 12, - ".", 1); + LLVMMetadataRef File = + LLVMDIBuilderCreateFile(DIB, "debuginfo.c", 11, ".", 1, 0, 0, NULL, 0); LLVMDIBuilderCreateCompileUnit(DIB, LLVMDWARFSourceLanguageC, File,"llvm-c-test", 11, 0, NULL, 0, 0, NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0); + LLVMMetadataRef FileWithChecksum = LLVMDIBuilderCreateFile( + DIB, "a.h", 3, ".", 1, 1, LLVMDIFileChecksumMD5, + "595f44fec1e92a71d3e9e77456ba80d1", 32); + + LLVMDIBuilderCreateCompileUnit(DIB, + LLVMDWARFSourceLanguageC, FileWithChecksum, "llvm-c-test", 11, 0, NULL, 0, 0, + NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0); + char *MStr = LLVMPrintModuleToString(M); puts(MStr); LLVMDisposeMessage(MStr);