Make debug info work when using -save-temps.
- This is pretty ugly, but the most obvious solution. Chime in if you
have a nicer one.
- The problem is that with -save-temps, clang-cc has no idea what the
name of the original input file is. However, the user expects to be
able to set breakpoints based on the input file name.
- We support this by providing a new option -main-file-name (similar
to -dumpbase used by gcc) which allows the driver to pass in the
original file name.
- <rdar://problem/6753383> building with clang using --save-temps
gets the compile unit name from the .i file...
llvm-svn: 68595
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index c081936..45ceb2b 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -74,6 +74,12 @@
const char *DirName = FE ? FE->getDir()->getName() : "<unknown>";
const LangOptions &LO = M->getLangOptions();
+
+ // If this is the main file, use the user provided main file name if
+ // specified.
+ if (isMain && LO.getMainFileName())
+ FileName = LO.getMainFileName();
+
unsigned LangTag;
if (LO.CPlusPlus) {
if (LO.ObjC1)