diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-12-03 17:55:29 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-12-03 17:55:29 +0000 |
commit | 0f873eb80ad4c4d850ef18a4b591391541fcf97d (patch) | |
tree | da9e93f4c75e05fd18dd329530cf29e30f797e6c /llvm/lib/IR | |
parent | 40c04e494253a6cbc106bb1d6530069c021ad97b (diff) | |
download | bcm5719-llvm-0f873eb80ad4c4d850ef18a4b591391541fcf97d.tar.gz bcm5719-llvm-0f873eb80ad4c4d850ef18a4b591391541fcf97d.zip |
Update Diagnostic handling for changes in CFE.
The clang frontend no longer emits the current working directory for
DIFiles containing an absolute path in the filename: and will move the
common prefix between current working directory and the file into the
directory: component.
https://reviews.llvm.org/D55085
llvm-svn: 348155
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/DiagnosticInfo.cpp | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp index 5ddb1196b07..fc6f5f1c758 100644 --- a/llvm/lib/IR/DiagnosticInfo.cpp +++ b/llvm/lib/IR/DiagnosticInfo.cpp @@ -33,9 +33,10 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Regex.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/Support/ScopedPrinter.h" +#include "llvm/Support/raw_ostream.h" #include <atomic> #include <cassert> #include <memory> @@ -106,7 +107,7 @@ void DiagnosticInfoPGOProfile::print(DiagnosticPrinter &DP) const { DiagnosticLocation::DiagnosticLocation(const DebugLoc &DL) { if (!DL) return; - Filename = DL->getFilename(); + File = DL->getFile(); Line = DL->getLine(); Column = DL->getColumn(); } @@ -114,17 +115,32 @@ DiagnosticLocation::DiagnosticLocation(const DebugLoc &DL) { DiagnosticLocation::DiagnosticLocation(const DISubprogram *SP) { if (!SP) return; - Filename = SP->getFilename(); + + File = SP->getFile(); Line = SP->getScopeLine(); Column = 0; } -void DiagnosticInfoWithLocationBase::getLocation(StringRef *Filename, - unsigned *Line, - unsigned *Column) const { - *Filename = Loc.getFilename(); - *Line = Loc.getLine(); - *Column = Loc.getColumn(); +std::string DiagnosticLocation::getAbsolutePath() const { + StringRef Name = File->getFilename(); + if (sys::path::is_absolute(Name)) + return Name; + + SmallString<128> Path; + sys::path::append(Path, File->getDirectory(), Name); + return sys::path::remove_leading_dotslash(Path).str(); +} + +std::string DiagnosticInfoWithLocationBase::getAbsolutePath() const { + return Loc.getAbsolutePath(); +} + +void DiagnosticInfoWithLocationBase::getLocation(StringRef &RelativePath, + unsigned &Line, + unsigned &Column) const { + RelativePath = Loc.getRelativePath(); + Line = Loc.getLine(); + Column = Loc.getColumn(); } const std::string DiagnosticInfoWithLocationBase::getLocationStr() const { @@ -132,7 +148,7 @@ const std::string DiagnosticInfoWithLocationBase::getLocationStr() const { unsigned Line = 0; unsigned Column = 0; if (isLocationAvailable()) - getLocation(&Filename, &Line, &Column); + getLocation(Filename, Line, Column); return (Filename + ":" + Twine(Line) + ":" + Twine(Column)).str(); } @@ -399,7 +415,7 @@ template <> struct MappingTraits<DiagnosticLocation> { static void mapping(IO &io, DiagnosticLocation &DL) { assert(io.outputting() && "input not yet implemented"); - StringRef File = DL.getFilename(); + StringRef File = DL.getRelativePath(); unsigned Line = DL.getLine(); unsigned Col = DL.getColumn(); |