[cfe-commits] r170391 - in /cfe/trunk: include/clang/Driver/CC1AsOptions.td lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/debug-main-file.S tools/driver/cc1as_main.cpp
Eric Christopher
echristo at gmail.com
Mon Dec 17 16:31:11 PST 2012
Author: echristo
Date: Mon Dec 17 18:31:10 2012
New Revision: 170391
URL: http://llvm.org/viewvc/llvm-project?rev=170391&view=rev
Log:
Add support for passing the main file name down to the assembler
for location information.
Part of PR14624
Added:
cfe/trunk/test/Driver/debug-main-file.S
Modified:
cfe/trunk/include/clang/Driver/CC1AsOptions.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/tools/driver/cc1as_main.cpp
Modified: cfe/trunk/include/clang/Driver/CC1AsOptions.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1AsOptions.td?rev=170391&r1=170390&r2=170391&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1AsOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CC1AsOptions.td Mon Dec 17 18:31:10 2012
@@ -37,6 +37,8 @@
HelpText<"Save temporary labels in the symbol table. "
"Note this may change .s semantics, it should almost never be used "
"on compiler generated code!">;
+def main_file_name : Separate<["-"], "main-file-name">,
+ HelpText<"Main file name to use for debug info">;
//===----------------------------------------------------------------------===//
// Frontend Options
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=170391&r1=170390&r2=170391&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 17 18:31:10 2012
@@ -1388,12 +1388,12 @@
// The native darwin assembler doesn't support cfi directives, so
// we disable them if we think the .s file will be passed to it.
Default = Args.hasFlag(options::OPT_integrated_as,
- options::OPT_no_integrated_as,
- TC.IsIntegratedAssemblerDefault());
+ options::OPT_no_integrated_as,
+ TC.IsIntegratedAssemblerDefault());
}
return !Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
- options::OPT_fno_dwarf2_cfi_asm,
- Default);
+ options::OPT_fno_dwarf2_cfi_asm,
+ Default);
}
static bool ShouldDisableDwarfDirectory(const ArgList &Args,
@@ -3278,6 +3278,11 @@
CmdArgs.push_back("-filetype");
CmdArgs.push_back("obj");
+ // Set the main file name, so that debug info works even with
+ // -save-temps or preprocessed assembly.
+ CmdArgs.push_back("-main-file-name");
+ CmdArgs.push_back(Clang::getBaseInputName(Args, Inputs));
+
if (UseRelaxAll(C, Args))
CmdArgs.push_back("-relax-all");
@@ -4367,10 +4372,10 @@
}
void darwin::VerifyDebug::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &Args,
- const char *LinkingOutput) const {
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
ArgStringList CmdArgs;
CmdArgs.push_back("--verify");
CmdArgs.push_back("--debug-info");
@@ -5751,7 +5756,7 @@
CmdArgs.push_back("-lCompilerRT-Generic");
CmdArgs.push_back("-L/usr/pkg/compiler-rt/lib");
CmdArgs.push_back(
- Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
+ Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
}
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("ld"));
Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=170391&r1=170390&r2=170391&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Mon Dec 17 18:31:10 2012
@@ -30,6 +30,7 @@
/// \brief Clang compiler tool.
class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
+ public:
static const char *getBaseInputName(const ArgList &Args,
const InputInfoList &Inputs);
static const char *getBaseInputStem(const ArgList &Args,
@@ -37,6 +38,7 @@
static const char *getDependencyFileName(const ArgList &Args,
const InputInfoList &Inputs);
+ private:
void AddPreprocessingOptions(Compilation &C,
const Driver &D,
const ArgList &Args,
@@ -286,15 +288,15 @@
class LLVM_LIBRARY_VISIBILITY VerifyDebug : public DarwinTool {
public:
VerifyDebug(const ToolChain &TC) : DarwinTool("darwin::VerifyDebug",
- "dwarfdump", TC) {}
+ "dwarfdump", TC) {}
virtual bool hasIntegratedCPP() const { return false; }
virtual void ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &TCArgs,
- const char *LinkingOutput) const;
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &TCArgs,
+ const char *LinkingOutput) const;
};
}
Added: cfe/trunk/test/Driver/debug-main-file.S
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-main-file.S?rev=170391&view=auto
==============================================================================
--- cfe/trunk/test/Driver/debug-main-file.S (added)
+++ cfe/trunk/test/Driver/debug-main-file.S Mon Dec 17 18:31:10 2012
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK: main-file-name
+
+#ifdef(1)
+foo:
+ nop
+ nop
+ nop
+#endif
Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=170391&r1=170390&r2=170391&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Mon Dec 17 18:31:10 2012
@@ -84,6 +84,7 @@
unsigned GenDwarfForAssembly : 1;
std::string DwarfDebugFlags;
std::string DebugCompilationDir;
+ std::string MainFileName;
/// @}
/// @name Frontend Options
@@ -183,6 +184,7 @@
Opts.GenDwarfForAssembly = Args->hasArg(OPT_g);
Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
+ Opts.MainFileName = Args->getLastArgValue(OPT_main_file_name);
// Frontend Options
if (Args->hasArg(OPT_INPUT)) {
@@ -309,6 +311,8 @@
Ctx.setDwarfDebugFlags(StringRef(Opts.DwarfDebugFlags));
if (!Opts.DebugCompilationDir.empty())
Ctx.setCompilationDir(Opts.DebugCompilationDir);
+ if (!Opts.MainFileName.empty())
+ Ctx.setMainFileName(StringRef(Opts.MainFileName));
// Build up the feature string from the target feature list.
std::string FS;
More information about the cfe-commits
mailing list