Debug Info: add a "Debug Info Version" module flag to output the current debug

info version number.

Will error out when modules have different version numbers.

llvm-svn: 195495
This commit is contained in:
Manman Ren 2013-11-22 19:42:45 +00:00
parent fb6439654d
commit 4b7f23d885
2 changed files with 13 additions and 0 deletions

View 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();

View File

@ -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"