llvm.org GIT mirror llvm / 6c58314
Add support for passing -main-file-name all the way through to the assembler. Part of PR14624 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170390 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 7 years ago
7 changed file(s) with 47 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
9696 /// The compilation directory to use for DW_AT_comp_dir.
9797 std::string CompilationDir;
9898
99 /// The main file name if passed in explicitly.
100 std::string MainFileName;
101
99102 /// The dwarf file and directory tables from the dwarf .file directive.
100103 std::vector MCDwarfFiles;
101104 std::vector MCDwarfDirs;
259262 /// \brief Set the compilation directory for DW_AT_comp_dir
260263 /// Override the default (CWD) compilation directory.
261264 void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
265
266 /// \brief Get the main file name for use in error messages and debug
267 /// info. This can be set to ensure we've got the correct file name
268 /// after preprocessing or for -save-temps.
269 const std::string &getMainFileName() const { return MainFileName; }
270
271 /// \brief Set the main file name and override the default.
272 void setMainFileName(StringRef S) { MainFileName = S.str(); }
262273
263274 /// GetDwarfFile - creates an entry in the dwarf file and directory tables.
264275 unsigned GetDwarfFile(StringRef Directory, StringRef FileName,
9494 return Buffers[i].Buffer;
9595 }
9696
97 unsigned getNumBuffers() const {
98 return Buffers.size();
99 }
100
97101 SMLoc getParentIncludeLoc(unsigned i) const {
98102 assert(i < Buffers.size() && "Invalid Buffer ID!");
99103 return Buffers[i].IncludeLoc;
2020 #include "llvm/MC/MCSymbol.h"
2121 #include "llvm/Support/ELF.h"
2222 #include "llvm/Support/ErrorHandling.h"
23 #include "llvm/Support/MemoryBuffer.h"
2324 #include "llvm/Support/Signals.h"
2425 #include "llvm/Support/SourceMgr.h"
2526 using namespace llvm;
4748 SecureLogFile = getenv("AS_SECURE_LOG_FILE");
4849 SecureLog = 0;
4950 SecureLogUsed = false;
51
52 if (SrcMgr && SrcMgr->getNumBuffers() > 0)
53 MainFileName = SrcMgr->getMemoryBuffer(0)->getBufferIdentifier();
54 else
55 MainFileName = "";
5056 }
5157
5258 MCContext::~MCContext() {
612612 getStreamer().EmitLabel(SectionStartSym);
613613 getContext().setGenDwarfSectionStartSym(SectionStartSym);
614614 getStreamer().EmitDwarfFileDirective(getContext().nextGenDwarfFileNumber(),
615 StringRef(), SrcMgr.getMemoryBuffer(CurBuffer)->getBufferIdentifier());
615 StringRef(),
616 getContext().getMainFileName());
616617 }
617618
618619 // While we have input, parse each statement.
None config.suffixes = ['.ll']
0 config.suffixes = ['.ll', '.s']
11
22 targets = set(config.root.targets_to_build.split())
33 if not 'X86' in targets:
0 // RUN: llvm-mc -triple x86_64-unknown-linux-gnu -filetype obj -main-file-name foo.S -g -o %t %s
1 // RUN: llvm-dwarfdump %t | FileCheck %s
2
3 // CHECK: DW_TAG_compile_unit [1]
4 // CHECK-NOT: DW_TAG_
5 // CHECK: DW_AT_name [DW_FORM_string] ("foo.S")
6
7
8 # 1 "foo.S"
9 # 1 "" 1
10 # 1 "foo.S" 2
11
12 foo:
13 nop
14 nop
15 nop
16
159159 static cl::opt
160160 DebugCompilationDir("fdebug-compilation-dir",
161161 cl::desc("Specifies the debug info's compilation dir"));
162
163 static cl::opt
164 MainFileName("main-file-name",
165 cl::desc("Specifies the name we should consider the input file"));
162166
163167 enum ActionType {
164168 AC_AsLex,
396400 Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags));
397401 if (!DebugCompilationDir.empty())
398402 Ctx.setCompilationDir(DebugCompilationDir);
403 if (!MainFileName.empty())
404 Ctx.setMainFileName(MainFileName);
399405
400406 // Package up features to be passed to target/subtarget
401407 std::string FeaturesStr;