diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 5ebeee27735d95..9a1806f27e6339 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1046,12 +1046,13 @@ void CodeGenModule::Release() { // We support a single version in the linked module. The LLVM // parser will drop debug info with a different version number // (and warn about it, too). - uint32_t DebugMetadataVersion = - CodeGenOpts.HeterogeneousDwarf ? - llvm::DEBUG_METADATA_VERSION_HETEROGENEOUS_DWARF : - llvm::DEBUG_METADATA_VERSION; - getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version", - DebugMetadataVersion); + if (CodeGenOpts.HeterogeneousDwarf) { + getModule().addModuleFlag(llvm::Module::Override, "Debug Info Version", + llvm::DEBUG_METADATA_VERSION_HETEROGENEOUS_DWARF); + } else { + getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version", + llvm::DEBUG_METADATA_VERSION); + } } // We need to record the widths of enums and wchar_t, so that we can generate diff --git a/clang/test/CodeGen/debug-info-version-heterogeneous-dwarf.c b/clang/test/CodeGen/debug-info-version-heterogeneous-dwarf.c index 72f55a52d9b4ba..285226686ba811 100644 --- a/clang/test/CodeGen/debug-info-version-heterogeneous-dwarf.c +++ b/clang/test/CodeGen/debug-info-version-heterogeneous-dwarf.c @@ -4,5 +4,5 @@ int main (void) { return 0; } -// CHECK: i32 2, !"Debug Info Version", i32 4} +// CHECK: i32 4, !"Debug Info Version", i32 4} // NO_DEBUG-NOT: !"Debug Info Version"