diff options
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 5 | ||||
-rw-r--r-- | clang/test/CodeGen/debug-info-version.c | 8 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4d51fb02bb4..8240f8d38c1 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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/clang/test/CodeGen/debug-info-version.c b/clang/test/CodeGen/debug-info-version.c new file mode 100644 index 00000000000..3a74876de59 --- /dev/null +++ b/clang/test/CodeGen/debug-info-version.c @@ -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" |