summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp7
-rw-r--r--clang/lib/Driver/Tools.cpp18
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp10
3 files changed, 29 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index e899c9442b2..8e5bc5d327f 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -369,11 +369,16 @@ void CodeGenModule::Release() {
(Context.getLangOpts().Modules || !LinkerOptionsMetadata.empty())) {
EmitModuleLinkOptions();
}
- if (CodeGenOpts.DwarfVersion)
+ if (CodeGenOpts.DwarfVersion) {
// We actually want the latest version when there are conflicts.
// We can change from Warning to Latest if such mode is supported.
getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version",
CodeGenOpts.DwarfVersion);
+ }
+ if (CodeGenOpts.EmitCodeView) {
+ // Indicate that we want CodeView in the metadata.
+ getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
+ }
if (DebugInfo)
// We support a single version in the linked module. The LLVM
// parser will drop debug info with a different version number
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 043d9958b3c..759e91752a5 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -3678,6 +3678,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}
}
+ // Forward -gcodeview.
+ Args.AddLastArg(CmdArgs, options::OPT_gcodeview);
+
// We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
Args.ClaimAllArgs(options::OPT_g_flags_Group);
if (Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
@@ -5270,6 +5273,16 @@ void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
/*default=*/false))
CmdArgs.push_back("-fno-rtti-data");
+ // Emit CodeView if -Z7 is present.
+ bool EmitCodeView = Args.hasArg(options::OPT__SLASH_Z7);
+ bool EmitDwarf = Args.hasArg(options::OPT_gdwarf);
+ // If we are emitting CV but not DWARF, don't build information that LLVM
+ // can't yet process.
+ if (EmitCodeView && !EmitDwarf)
+ CmdArgs.push_back("-gline-tables-only");
+ if (EmitCodeView)
+ CmdArgs.push_back("-gcodeview");
+
const Driver &D = getToolChain().getDriver();
EHFlags EH = parseClangCLEHFlags(D, Args);
// FIXME: Do something with NoExceptC.
@@ -8820,7 +8833,7 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-nologo");
- if (Args.hasArg(options::OPT_g_Group))
+ if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
CmdArgs.push_back("-debug");
bool DLL = Args.hasArg(options::OPT__SLASH_LD, options::OPT__SLASH_LDd,
@@ -8976,7 +8989,8 @@ std::unique_ptr<Command> visualstudio::Compiler::GetCommand(
A->getOption().getID() == options::OPT_fdata_sections ? "/Gw" : "/Gw-");
if (Args.hasArg(options::OPT_fsyntax_only))
CmdArgs.push_back("/Zs");
- if (Args.hasArg(options::OPT_g_Flag, options::OPT_gline_tables_only))
+ if (Args.hasArg(options::OPT_g_Flag, options::OPT_gline_tables_only,
+ options::OPT__SLASH_Z7))
CmdArgs.push_back("/Z7");
std::vector<std::string> Includes =
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 06e8554d9d3..0f09db2bff3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -410,6 +410,13 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.setDebugInfo(CodeGenOptions::LimitedDebugInfo);
}
Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info);
+ if (Args.hasArg(OPT_gcodeview)) {
+ Opts.EmitCodeView = true;
+ Opts.DwarfVersion = 0;
+ } else if (Opts.getDebugInfo() != CodeGenOptions::NoDebugInfo) {
+ // Default Dwarf version is 4 if we are generating debug information.
+ Opts.DwarfVersion = 4;
+ }
Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
if (Args.hasArg(OPT_gdwarf_2))
Opts.DwarfVersion = 2;
@@ -417,9 +424,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
Opts.DwarfVersion = 3;
else if (Args.hasArg(OPT_gdwarf_4))
Opts.DwarfVersion = 4;
- else if (Opts.getDebugInfo() != CodeGenOptions::NoDebugInfo)
- // Default Dwarf version is 4 if we are generating debug information.
- Opts.DwarfVersion = 4;
if (const Arg *A =
Args.getLastArg(OPT_emit_llvm_uselists, OPT_no_emit_llvm_uselists))
OpenPOWER on IntegriCloud