[LLVM-C] Expose functions to create debug locations via DIBuilder.
[lldb.git] / llvm / tools / llvm-c-test / debuginfo.c
1 /*===-- debuginfo.c - tool for testing libLLVM and llvm-c API -------------===*\
2 |*                                                                            *|
3 |*                     The LLVM Compiler Infrastructure                       *|
4 |*                                                                            *|
5 |* This file is distributed under the University of Illinois Open Source      *|
6 |* License. See LICENSE.TXT for details.                                      *|
7 |*                                                                            *|
8 |*===----------------------------------------------------------------------===*|
9 |*                                                                            *|
10 |* Tests for the LLVM C DebugInfo API                                         *|
11 |*                                                                            *|
12 \*===----------------------------------------------------------------------===*/
13
14 #include "llvm-c-test.h"
15 #include "llvm-c/DebugInfo.h"
16 #include <string.h>
17 #include <stdio.h>
18
19 int llvm_test_dibuilder() {
20   LLVMModuleRef M = LLVMModuleCreateWithName("debuginfo.c");
21   LLVMDIBuilderRef DIB = LLVMCreateDIBuilder(M);
22
23   LLVMMetadataRef File = LLVMDIBuilderCreateFile(DIB, "debuginfo.c", 12,
24                                                  ".", 1);
25
26   LLVMDIBuilderCreateCompileUnit(DIB,
27       LLVMDWARFSourceLanguageC, File,"llvm-c-test", 11, 0, NULL, 0, 0,
28       NULL, 0, LLVMDWARFEmissionFull, 0, 0, 0);
29
30   char *MStr = LLVMPrintModuleToString(M);
31   puts(MStr);
32   LLVMDisposeMessage(MStr);
33
34   LLVMDisposeDIBuilder(DIB);
35   LLVMDisposeModule(M);
36
37   return 0;
38 }