]> granicus.if.org Git - clang/commitdiff
Debug Info: add a "Debug Info Version" module flag to output the current debug
authorManman Ren <manman.ren@gmail.com>
Fri, 22 Nov 2013 19:42:45 +0000 (19:42 +0000)
committerManman Ren <manman.ren@gmail.com>
Fri, 22 Nov 2013 19:42:45 +0000 (19:42 +0000)
info version number.

Will error out when modules have different version numbers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195495 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/debug-info-version.c [new file with mode: 0644]

index 4d51fb02bb4d50d657caea05ebaf0d6fb4c2a73a..8240f8d38c151572543b6093d3b8e51610251ec6 100644 (file)
@@ -258,6 +258,11 @@ void CodeGenModule::Release() {
     // We can change from Warning to Latest if such mode is supported.
     getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version",
                               CodeGenOpts.DwarfVersion);
+  if (DebugInfo)
+    // We support a single version in the linked module: error out when
+    // modules do not have the same version.
+    getModule().addModuleFlag(llvm::Module::Error, "Debug Info Version",
+                              llvm::dwarf::DEBUG_INFO_VERSION);
 
   SimplifyPersonality();
 
diff --git a/test/CodeGen/debug-info-version.c b/test/CodeGen/debug-info-version.c
new file mode 100644 (file)
index 0000000..3a74876
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: %clang -g -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -S -emit-llvm -o - %s | FileCheck %s --check-prefix=NO_DEBUG
+int main (void) {
+  return 0;
+}
+
+// CHECK: metadata !{i32 1, metadata !"Debug Info Version", i32 1}
+// NO_DEBUG-NOT: metadata !"Debug Info Version"