[PATCH] D151093: [clang][Diagnostic] Simplify emitDiagnosticLoc
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 31 00:50:43 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc113cbb51005: [clang][Diagnostic][NFC] Simplify emitDiagnosticLoc (authored by tbaeder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151093/new/
https://reviews.llvm.org/D151093
Files:
clang/lib/Frontend/TextDiagnostic.cpp
Index: clang/lib/Frontend/TextDiagnostic.cpp
===================================================================
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -850,30 +850,26 @@
if (DiagOpts->ShowSourceRanges && !Ranges.empty()) {
FileID CaretFileID = Loc.getExpansionLoc().getFileID();
bool PrintedRange = false;
+ const SourceManager &SM = Loc.getManager();
for (const auto &R : Ranges) {
// Ignore invalid ranges.
if (!R.isValid())
continue;
- auto &SM = Loc.getManager();
SourceLocation B = SM.getExpansionLoc(R.getBegin());
CharSourceRange ERange = SM.getExpansionRange(R.getEnd());
SourceLocation E = ERange.getEnd();
- bool IsTokenRange = ERange.isTokenRange();
- std::pair<FileID, unsigned> BInfo = SM.getDecomposedLoc(B);
- std::pair<FileID, unsigned> EInfo = SM.getDecomposedLoc(E);
-
- // If the start or end of the range is in another file, just discard
- // it.
- if (BInfo.first != CaretFileID || EInfo.first != CaretFileID)
+ // If the start or end of the range is in another file, just
+ // discard it.
+ if (SM.getFileID(B) != CaretFileID || SM.getFileID(E) != CaretFileID)
continue;
// Add in the length of the token, so that we cover multi-char
// tokens.
unsigned TokSize = 0;
- if (IsTokenRange)
+ if (ERange.isTokenRange())
TokSize = Lexer::MeasureTokenLength(E, SM, LangOpts);
FullSourceLoc BF(B, SM), EF(E, SM);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151093.526943.patch
Type: text/x-patch
Size: 1558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230531/e9321f9d/attachment-0001.bin>
More information about the cfe-commits
mailing list