diff options
| author | Oliver Stannard <oliver.stannard@arm.com> | 2016-02-02 13:52:43 +0000 |
|---|---|---|
| committer | Oliver Stannard <oliver.stannard@arm.com> | 2016-02-02 13:52:43 +0000 |
| commit | 7e7d983a878acc83e0aa424907286e8cd4e22960 (patch) | |
| tree | 2927c11cc22432e748958e62e128d60cc85d20a9 /llvm/lib/IR/DiagnosticInfo.cpp | |
| parent | d9e2dcdb424f761f7148db63d7ed9cd6ae40c2fe (diff) | |
| download | bcm5719-llvm-7e7d983a878acc83e0aa424907286e8cd4e22960.tar.gz bcm5719-llvm-7e7d983a878acc83e0aa424907286e8cd4e22960.zip | |
Refactor backend diagnostics for unsupported features
Re-commit of r258951 after fixing layering violation.
The BPF and WebAssembly backends had identical code for emitting errors
for unsupported features, and AMDGPU had very similar code. This merges
them all into one DiagnosticInfo subclass, that can be used by any
backend.
There should be minimal functional changes here, but some AMDGPU tests
have been updated for the new format of errors (it used a slightly
different format to BPF and WebAssembly). The AMDGPU error messages will
now benefit from having precise source locations when debug info is
available.
llvm-svn: 259498
Diffstat (limited to 'llvm/lib/IR/DiagnosticInfo.cpp')
| -rw-r--r-- | llvm/lib/IR/DiagnosticInfo.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index 6426f76bbaa..10d9d55ed71 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -138,11 +138,11 @@ void DiagnosticInfoPGOProfile::print(DiagnosticPrinter &DP) const { DP << getMsg(); } -bool DiagnosticInfoOptimizationBase::isLocationAvailable() const { +bool DiagnosticInfoWithDebugLocBase::isLocationAvailable() const { return getDebugLoc(); } -void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename, +void DiagnosticInfoWithDebugLocBase::getLocation(StringRef *Filename, unsigned *Line, unsigned *Column) const { DILocation *L = getDebugLoc(); @@ -152,7 +152,7 @@ void DiagnosticInfoOptimizationBase::getLocation(StringRef *Filename, *Column = L->getColumn(); } -const std::string DiagnosticInfoOptimizationBase::getLocationStr() const { +const std::string DiagnosticInfoWithDebugLocBase::getLocationStr() const { StringRef Filename("<unknown>"); unsigned Line = 0; unsigned Column = 0; @@ -230,6 +230,16 @@ bool DiagnosticInfoOptimizationFailure::isEnabled() const { return getSeverity() == DS_Warning; } +void DiagnosticInfoUnsupported::print(DiagnosticPrinter &DP) const { + std::string Str; + raw_string_ostream OS(Str); + + OS << getLocationStr() << ": in function " << getFunction().getName() << ' ' + << *getFunction().getFunctionType() << ": " << Msg << '\n'; + OS.flush(); + DP << Str; +} + void llvm::emitLoopVectorizeWarning(LLVMContext &Ctx, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg) { Ctx.diagnose(DiagnosticInfoOptimizationFailure( |

