[PATCH] D116318: [clang-format][NFC] Fix a bug in getPreviousToken() in the parser
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 27 12:01:31 PST 2021
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, curdeius.
owenpan added a project: clang-format.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116318
Files:
clang/lib/Format/UnwrappedLineParser.cpp
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -32,7 +32,7 @@
// Returns the next token in the token stream.
virtual FormatToken *getNextToken() = 0;
- // Returns the token precedint the token returned by the last call to
+ // Returns the token preceding the token returned by the last call to
// getNextToken() in the token stream, or nullptr if no such token exists.
virtual FormatToken *getPreviousToken() = 0;
@@ -246,8 +246,7 @@
}
FormatToken *getPreviousToken() override {
- assert(Position > 0);
- return Tokens[Position - 1];
+ return Position > 0 ? Tokens[Position - 1] : nullptr;
}
FormatToken *peekNextToken() override {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116318.396326.patch
Type: text/x-patch
Size: 837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211227/387752f2/attachment.bin>
More information about the cfe-commits
mailing list