Lines Matching +full:output +full:- +full:sarif
1 //===--- TextDiagnostic.cpp - Text Diagnostic Pretty-Printing -------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
74 /// Number of spaces to indent when word-wrapping.
80 if (SourceLine[--i]=='\t') in bytesSincePreviousTabOrLineBegin()
114 "Invalid -ftabstop value"); in printableTextForNextCharacter()
116 unsigned NumSpaces = TabStop - (Col % TabStop); in printableTextForNextCharacter()
148 assert(unsigned(Begin - OriginalBegin) == CharSize); in printableTextForNextCharacter()
150 (*I) += (Begin - OriginalBegin); in printableTextForNextCharacter()
152 // Valid, multi-byte, printable UTF8 character. in printableTextForNextCharacter()
179 I--; in expandTabs()
197 /// "a \t \u3042" -> {0,1,2,-1,-1,-1,-1,-1,3,4,-1,7}
199 /// (\\u3042 is represented in UTF-8 by three bytes and takes two columns to
213 /// entity in the output, then the array will map that byte to the appropriate
214 /// column while the subsequent bytes will be -1.
221 /// "a \t \u3042" -> {0,1,2,8,9,-1,-1,11}
223 /// (\\u3042 is represented in UTF-8 by three bytes and takes two columns to
237 ColumnsOut.resize(SourceLine.size() + 1, -1); in genColumnByteMapping()
243 BytesOut.resize(Columns + 1, -1); in genColumnByteMapping()
251 BytesOut.resize(Columns + 1, -1); in genColumnByteMapping()
272 /// Map a byte to the column which it is at the start of, or return -1
273 /// if it is not at the start of a column (for a UTF-8 trailing byte).
282 while (m_byteToColumn[N] == -1) in byteToContainingColumn()
283 --N; in byteToContainingColumn()
287 /// Map a column to the byte which starts the column, or return -1 if
289 /// multi-column entity.
297 assert(0 <= N && N < static_cast<int>(m_byteToColumn.size() - 1)); in startOfNextColumn()
298 while (byteToColumn(++N) == -1) {} in startOfNextColumn()
305 while (byteToColumn(--N) == -1) {} in startOfPreviousColumn()
345 for (; CaretEnd != CaretStart; --CaretEnd) in selectInterestingSourceRegion()
346 if (!isWhitespace(CaretLine[CaretEnd - 1])) in selectInterestingSourceRegion()
352 // If we have a fix-it line, make sure the slice includes all of the in selectInterestingSourceRegion()
353 // fix-it information. in selectInterestingSourceRegion()
360 for (; FixItEnd != FixItStart; --FixItEnd) in selectInterestingSourceRegion()
361 if (!isWhitespace(FixItInsertionLine[FixItEnd - 1])) in selectInterestingSourceRegion()
379 -1 == map.columnToByte(CaretEnd)) in selectInterestingSourceRegion()
383 -1!=map.columnToByte(CaretStart)) && in selectInterestingSourceRegion()
387 -1!=map.columnToByte(CaretEnd)) && in selectInterestingSourceRegion()
401 unsigned CaretColumnsOutsideSource = CaretEnd-CaretStart in selectInterestingSourceRegion()
402 - (map.byteToColumn(SourceEnd)-map.byteToColumn(SourceStart)); in selectInterestingSourceRegion()
413 TargetColumns -= ellipses_space+CaretColumnsOutsideSource; in selectInterestingSourceRegion()
423 // FIXME: Detect non-ASCII whitespace characters too. in selectInterestingSourceRegion()
435 assert(map.byteToColumn(NewStart) != -1); in selectInterestingSourceRegion()
436 unsigned NewColumns = map.byteToColumn(SourceEnd) - in selectInterestingSourceRegion()
449 // FIXME: Detect non-ASCII whitespace characters too. in selectInterestingSourceRegion()
457 assert(map.byteToColumn(NewEnd) != -1); in selectInterestingSourceRegion()
458 unsigned NewColumns = map.byteToColumn(NewEnd) - in selectInterestingSourceRegion()
474 // output lines to show only this slice. in selectInterestingSourceRegion()
475 assert(CaretStart!=(unsigned)-1 && CaretEnd!=(unsigned)-1 && in selectInterestingSourceRegion()
476 SourceStart!=(unsigned)-1 && SourceEnd!=(unsigned)-1); in selectInterestingSourceRegion()
481 = map.byteToColumn(SourceLine.size())-map.byteToColumn(SourceEnd); in selectInterestingSourceRegion()
483 unsigned ColumnsKept = CaretEnd-CaretStart; in selectInterestingSourceRegion()
509 /// \returns The index of the first non-whitespace character that is
580 unsigned PunctWordLength = End - Start; in findEndOfWord()
590 // the punctuation and use that end-point instead. This will recurse in findEndOfWord()
595 /// Print the given string to a stream, word-wrapping it to
598 /// \param OS the stream to which the word-wrapping string will be
600 /// \param Str the string to word-wrap and output.
601 /// \param Columns the number of columns to word-wrap to.
603 /// Str will be printed. This will be non-zero when part of the first
606 /// \returns true if word-wrapping was required, or false if the
625 unsigned WordLength = WordEnd - WordStart; in printWordWrapped()
673 if (DiagOpts->ShowColors) in emitDiagnosticMessage()
676 if (DiagOpts->ShowLevel) in emitDiagnosticMessage()
677 printDiagnosticLevel(OS, Level, DiagOpts->ShowColors); in emitDiagnosticMessage()
680 Message, OS.tell() - StartOfLocationInfo, in emitDiagnosticMessage()
681 DiagOpts->MessageLength, DiagOpts->ShowColors); in emitDiagnosticMessage()
724 // indicate the transition from continuation notes and other output. in printDiagnosticMessage()
746 if (DiagOpts->AbsolutePath) { in emitFilename()
752 // On Unix-like systems, we cannot just collapse "<link>/..", because in emitFilename()
764 TmpFilename = File->getName(); in emitFilename()
791 emitFilename(FE->getName(), Loc.getManager()); in emitDiagnosticLoc()
799 if (!DiagOpts->ShowLocation) in emitDiagnosticLoc()
802 if (DiagOpts->ShowColors) in emitDiagnosticLoc()
806 switch (DiagOpts->getFormat()) { in emitDiagnosticLoc()
807 case DiagnosticOptions::SARIF: in emitDiagnosticLoc()
809 if (DiagOpts->ShowLine) in emitDiagnosticLoc()
816 if (DiagOpts->ShowColumn) in emitDiagnosticLoc()
819 if (DiagOpts->getFormat() == DiagnosticOptions::MSVC) { in emitDiagnosticLoc()
824 ColNo--; in emitDiagnosticLoc()
829 switch (DiagOpts->getFormat()) { in emitDiagnosticLoc()
830 case DiagnosticOptions::SARIF: in emitDiagnosticLoc()
844 if (DiagOpts->ShowSourceRanges && !Ranges.empty()) { in emitDiagnosticLoc()
863 // Add in the length of the token, so that we cover multi-char in emitDiagnosticLoc()
871 << BF.getLineNumber() << ':' << BF.getColumnNumber() << '-' in emitDiagnosticLoc()
884 if (DiagOpts->ShowLocation && PLoc.isValid()) { in emitIncludeLocation()
894 if (DiagOpts->ShowLocation && PLoc.isValid()) in emitImportLocation()
904 if (DiagOpts->ShowLocation && PLoc.isValid()) in emitBuildingModuleLocation()
933 unsigned Slack = MaxRange - (A.second - A.first + 1); in maybeAddRange()
940 if (Max - Min + 1 <= MaxRange) in maybeAddRange()
945 if ((B.first > A.first && B.first - A.first + 1 > MaxRange) || in maybeAddRange()
946 (B.second < A.second && A.second - B.second + 1 > MaxRange)) in maybeAddRange()
956 Slack = MaxRange - (A.second - A.first + 1); in maybeAddRange()
957 A.first = std::max(Min + Slack, A.first) - Slack; in maybeAddRange()
958 A.second = std::min(A.first + MaxRange - 1, Max); in maybeAddRange()
971 // Pick the first non-whitespace column. in highlightRange()
978 // Pick the last non-whitespace column. in highlightRange()
981 while (EndColNo && (Map.getSourceLine()[EndColNo - 1] == ' ' || in highlightRange()
982 Map.getSourceLine()[EndColNo - 1] == '\t')) in highlightRange()
987 // a multi-line highlighting range that covers a blank line. in highlightRange()
1008 if (Hints.empty() || !DiagOpts->ShowFixits) in buildFixItInsertionLine()
1026 // "column" (printed width, platform-dependent) and what is a in buildFixItInsertionLine()
1029 SM.getColumnNumber(HintLocInfo.first, HintLocInfo.second) - 1; in buildFixItInsertionLine()
1048 (HintCol - PrevHintEndCol) + in buildFixItInsertionLine()
1054 FixItInsertionLine.end() - H.CodeToInsert.size()); in buildFixItInsertionLine()
1060 expandTabs(FixItInsertionLine, DiagOpts->TabStop); in buildFixItInsertionLine()
1106 LineRanges.push_back({StartLineNo, StartColumn - 1, EndColumn - 1}); in prepareAndFilterRanges()
1111 LineRanges.push_back({StartLineNo, StartColumn - 1, ~0u}); in prepareAndFilterRanges()
1118 LineRanges.push_back({EndLineNo, 0, EndColumn - 1}); in prepareAndFilterRanges()
1127 /// (\p EndLineNumber - \p StartLineNumber + 1). Each SmallVector in there
1129 /// the StyleRanges are non-overlapping and sorted from start to end of the
1139 EndLineNumber - StartLineNumber + 1); in highlightLines()
1145 if (PP->getIdentifierTable().getExternalIdentifierLookup()) in highlightLines()
1155 if (const char *CheckPoint = PP->getCheckPoint(FID, FirstLineStart)) { in highlightLines()
1156 assert(CheckPoint >= Buff->getBufferStart() && in highlightLines()
1157 CheckPoint <= Buff->getBufferEnd()); in highlightLines()
1159 size_t Offset = CheckPoint - Buff->getBufferStart(); in highlightLines()
1166 const Token &T, unsigned Start, unsigned Length) -> void { in highlightLines()
1188 const IdentifierInfo *II = PP->getIdentifierInfo(RawIdent); in highlightLines()
1190 if (II->isKeyword(LangOpts)) in highlightLines()
1229 SM.getSpellingColumnNumber(T.getLocation(), &Invalid) - 1; in highlightLines()
1236 SnippetRanges[TokenStartLine - StartLineNumber]; in highlightLines()
1240 assert((TokenEndLine - TokenStartLine) >= 1); in highlightLines()
1244 unsigned EndCol = SM.getSpellingColumnNumber(T.getEndLoc(), &Invalid) - 1; in highlightLines()
1256 SnippetRanges[L - StartLineNumber]; in highlightLines()
1299 if (!DiagOpts->ShowCarets) in emitSnippetAndCaret()
1325 const unsigned MaxLines = DiagOpts->SnippetLineLimit; in emitSnippetAndCaret()
1341 DiagOpts->ShowLineNumbers in emitSnippetAndCaret()
1353 DiagOpts->ShowColors, FID, SM); in emitSnippetAndCaret()
1374 if (size_t(LineEnd - LineStart) > MaxLineLengthToPrint) in emitSnippetAndCaret()
1385 const SourceColumnMap sourceColMap(SourceLine, DiagOpts->TabStop); in emitSnippetAndCaret()
1396 size_t Col = sourceColMap.byteToContainingColumn(CaretColNo - 1); in emitSnippetAndCaret()
1406 unsigned Columns = DiagOpts->MessageLength; in emitSnippetAndCaret()
1411 // If we are in -fdiagnostics-print-source-range-info mode, we are trying in emitSnippetAndCaret()
1412 // to produce easily machine parsable output. Add a space before the in emitSnippetAndCaret()
1415 if (DiagOpts->ShowSourceRanges && !SourceLine.empty()) { in emitSnippetAndCaret()
1422 SourceStyles[LineNo - Lines.first]); in emitSnippetAndCaret()
1426 if (DiagOpts->ShowColors) in emitSnippetAndCaret()
1429 if (DiagOpts->ShowColors) in emitSnippetAndCaret()
1435 if (DiagOpts->ShowColors) in emitSnippetAndCaret()
1438 if (DiagOpts->ShowSourceRanges) in emitSnippetAndCaret()
1441 if (DiagOpts->ShowColors) in emitSnippetAndCaret()
1457 OS.indent(MaxLineNoDisplayWidth - LineNoDisplayWidth + 1) in emitSnippet()
1467 printableTextForNextCharacter(SourceLine, &I, DiagOpts->TabStop); in emitSnippet()
1470 if (DiagOpts->ShowColors) { in emitSnippet()
1488 (CurrentColor && *CurrentColor != CharStyle->Color)) { in emitSnippet()
1489 OS.changeColor(CharStyle->Color, false); in emitSnippet()
1490 CurrentColor = CharStyle->Color; in emitSnippet()
1501 if (DiagOpts->ShowColors) in emitSnippet()
1509 if (!DiagOpts->ShowParseableFixits) in emitParseableFixits()
1513 // fix-its in macros. in emitParseableFixits()
1531 // We specifically do not do word-wrapping or tab-expansion here, in emitParseableFixits()
1537 OS << "fix-it:\""; in emitParseableFixits()
1541 << '-' << SM.getLineNumber(EInfo.first, EInfo.second) in emitParseableFixits()