[PATCH] D122659: [clang][preprocessor] Allow calling DumpToken() on annotation tokens
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 29 08:23:17 PDT 2022
tbaeder created this revision.
tbaeder added a reviewer: aaron.ballman.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The `getSpelling()` call otherwise ultimately runs into an assertion because `getLength()` is called on an annotation token.
Just ran into this when debugging using `-dump-tokens`.
Sorry I can't really find a better reviewer, the rest of that function seems to be pretty ancient.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122659
Files:
clang/lib/Lex/Preprocessor.cpp
Index: clang/lib/Lex/Preprocessor.cpp
===================================================================
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -232,8 +232,10 @@
}
void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const {
- llvm::errs() << tok::getTokenName(Tok.getKind()) << " '"
- << getSpelling(Tok) << "'";
+ llvm::errs() << tok::getTokenName(Tok.getKind());
+
+ if (!Tok.isAnnotation())
+ llvm::errs() << " '" << getSpelling(Tok) << "'";
if (!DumpFlags) return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122659.418885.patch
Type: text/x-patch
Size: 546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220329/2ea71fb2/attachment-0001.bin>
More information about the cfe-commits
mailing list