llvm-project/llvm/lib/MC
Sanne Wouda 2933875cc2 [Assembler] Enable nicer diagnostics for inline assembly.
Fixed test.

Summary:
Enables source location in diagnostic messages from the backend.  This
is after parsing, during finalization.  This requires the SourceMgr, the
inline assembly string buffer, and DiagInfo to still be alive after
EmitInlineAsm returns.

This patch creates a single SourceMgr for inline assembly inside the
AsmPrinter.  MCContext gets a pointer to this SourceMgr.  Using one
SourceMgr per call to EmitInlineAsm would make it difficult for
MCContext to figure out in which SourceMgr the SMLoc is located, while a
single SourceMgr can figure it out if it has multiple buffers.

The Str argument to EmitInlineAsm is copied into a buffer and owned by
the inline asm SourceMgr.  This ensures that DiagHandlers won't print
garbage.  (Clang emits a "note: instantiated into assembly here", which
refers to this string.)

The AsmParser gets destroyed before finalization, which means that the
DiagHandlers the AsmParser installs into the SourceMgr will be stale.
Restore the saved DiagHandlers.

Since now we're using just one SourceMgr for multiple inline asm
strings, we need to tell the AsmParser which buffer it needs to parse
currently.  Hand a buffer id -- returned from SourceMgr::
AddNewSourceBuffer -- to the AsmParser.

Reviewers: rnk, grosbach, compnerd, rengolin, rovka, anemet

Reviewed By: rnk

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29441
    

llvm-svn: 294458
2017-02-08 14:48:05 +00:00
..
MCDisassembler Use StringRef instead of raw pointers in MCAsmInfo/MCInstrInfo APIs (NFC) 2016-10-01 06:46:33 +00:00
MCParser [Assembler] Enable nicer diagnostics for inline assembly. 2017-02-08 14:48:05 +00:00
CMakeLists.txt Revert r283690, "MC: Remove unused entities." 2016-10-10 22:49:37 +00:00
ConstantPools.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
ELFObjectWriter.cpp Change how we handle section symbols on ELF. 2017-02-02 21:26:06 +00:00
LLVMBuild.txt
MCAsmBackend.cpp [mips][ias] Support .dtprel[d]word and .tprel[d]word directives 2016-08-22 16:18:42 +00:00
MCAsmInfo.cpp [MC] Delete use of *structors_used. 2016-08-08 03:30:01 +00:00
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp [MC] Delete use of *structors_used. 2016-08-08 03:30:01 +00:00
MCAsmInfoELF.cpp [WebAssembly] Don't create a needless .note.GNU-stack section 2016-01-15 23:59:13 +00:00
MCAsmStreamer.cpp Only print architecture dependent flags for that architecture. 2017-01-30 15:38:43 +00:00
MCAssembler.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
MCCodeEmitter.cpp
MCCodeView.cpp [CodeView] Fix off-by-one error in def range gap emission 2017-01-24 16:57:55 +00:00
MCContext.cpp [Assembler] Enable nicer diagnostics for inline assembly. 2017-02-08 14:48:05 +00:00
MCDwarf.cpp Speculatively revert r289925, see PR31407 2016-12-16 14:02:28 +00:00
MCELFObjectTargetWriter.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
MCELFStreamer.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
MCExpr.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
MCFragment.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
MCInst.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
MCInstPrinter.cpp
MCInstrAnalysis.cpp
MCInstrDesc.cpp Replace uint16_t with the MCPhysReg typedef in many places. A lot of physical register arrays already use this typedef. 2015-12-05 07:13:35 +00:00
MCLabel.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
MCLinkerOptimizationHint.cpp Apply clang-tidy's modernize-loop-convert to lib/MC. 2016-06-26 14:49:00 +00:00
MCMachOStreamer.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
MCMachObjectTargetWriter.cpp
MCNullStreamer.cpp
MCObjectFileInfo.cpp Change how we handle section symbols on ELF. 2017-02-02 21:26:06 +00:00
MCObjectStreamer.cpp [Assembler] Better error messages for .org directive 2016-12-14 10:43:58 +00:00
MCObjectWriter.cpp
MCRegisterInfo.cpp Extract LaneBitmask into a separate type 2016-12-15 14:36:06 +00:00
MCSchedule.cpp
MCSection.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
MCSectionCOFF.cpp Only print architecture dependent flags for that architecture. 2017-01-30 15:38:43 +00:00
MCSectionELF.cpp Only print architecture dependent flags for that architecture. 2017-01-30 15:38:43 +00:00
MCSectionMachO.cpp Fix the GCC build. 2017-01-30 19:05:09 +00:00
MCStreamer.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
MCSubtargetInfo.cpp (NFC) Change SubtargetFeatures::ToggleFeature and 2016-01-05 10:25:56 +00:00
MCSymbol.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
MCSymbolELF.cpp Change how we handle section symbols on ELF. 2017-02-02 21:26:06 +00:00
MCTargetOptions.cpp Summary: Currently there is no way to disable deprecated warning from asm like this 2016-12-05 23:55:13 +00:00
MCValue.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
MCWin64EH.cpp [MC] Create unique .pdata sections for every .text section 2016-05-02 23:22:18 +00:00
MCWinEH.cpp Revert r283690, "MC: Remove unused entities." 2016-10-10 22:49:37 +00:00
MachObjectWriter.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
StringTableBuilder.cpp [ADT] Move CachedHashString to its own header in ADT, and rename to CachedHashStringRef. 2016-10-17 22:24:36 +00:00
SubtargetFeature.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
WinCOFFObjectWriter.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00
WinCOFFStreamer.cpp [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-07 23:02:00 +00:00