mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-08 18:30:04 +00:00
SMDiagnostic: don't emit ranges if there are /any/ multibyte characters.
Right now, only OS X has a way to determine the column width of a string (PR14910). Until we have a good way to deal with this, we just won't print carets, source ranges, or fixits for SMDiagnostic if the source line has multibyte characters in it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172164 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a7aec400a7
commit
9b1e854698
@ -336,6 +336,10 @@ static void printSourceLine(raw_ostream &S, StringRef LineContents) {
|
|||||||
S << '\n';
|
S << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isNonASCII(char c) {
|
||||||
|
return c & 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
void SMDiagnostic::print(const char *ProgName, raw_ostream &S,
|
void SMDiagnostic::print(const char *ProgName, raw_ostream &S,
|
||||||
bool ShowColors) const {
|
bool ShowColors) const {
|
||||||
// Display colors only if OS supports colors.
|
// Display colors only if OS supports colors.
|
||||||
@ -392,18 +396,17 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &S,
|
|||||||
if (LineNo == -1 || ColumnNo == -1)
|
if (LineNo == -1 || ColumnNo == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: If there are multibyte characters in the source, all our ranges will
|
// FIXME: If there are multibyte or multi-column characters in the source, all
|
||||||
// be wrong. To do this properly, we'll need a byte-to-column map like Clang's
|
// our ranges will be wrong. To do this properly, we'll need a byte-to-column
|
||||||
// TextDiagnostic. For now, we'll just handle tabs by expanding them later,
|
// map like Clang's TextDiagnostic. For now, we'll just handle tabs by
|
||||||
// and bail out rather than show incorrect ranges and misaligned fixits for
|
// expanding them later, and bail out rather than show incorrect ranges and
|
||||||
// any other odd characters.
|
// misaligned fixits for any other odd characters.
|
||||||
SmallString<128> PrintableLine(LineContents);
|
if (std::find_if(LineContents.begin(), LineContents.end(), isNonASCII) !=
|
||||||
std::replace(PrintableLine.begin(), PrintableLine.end(), '\t', ' ');
|
LineContents.end()) {
|
||||||
size_t NumColumns = (size_t)llvm::sys::locale::columnWidth(PrintableLine);
|
|
||||||
if (NumColumns != PrintableLine.size()) {
|
|
||||||
printSourceLine(S, LineContents);
|
printSourceLine(S, LineContents);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
size_t NumColumns = LineContents.size();
|
||||||
|
|
||||||
// Build the line with the caret and ranges.
|
// Build the line with the caret and ranges.
|
||||||
std::string CaretLine(NumColumns+1, ' ');
|
std::string CaretLine(NumColumns+1, ' ');
|
||||||
|
Loading…
Reference in New Issue
Block a user