[PATCH] D138371: [clang-format] Fix a crash due to dereferencing null MatchingParen
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 21 12:34:09 PST 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4daeb8c73354: [clang-format] Fix a crash due to dereferencing null MatchingParen (authored by owenpan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138371/new/
https://reviews.llvm.org/D138371
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25017,6 +25017,8 @@
"}",
Style);
+ verifyIncompleteFormat("class C final [[deprecated(l]] {});", Style);
+
// These tests are here to show a problem that may not be easily
// solved, our implementation to remove semicolons is only as good
// as our FunctionLBrace detection and this fails for empty braces
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2851,6 +2851,8 @@
return false;
} else if (isCppAttribute(IsCpp, *Next)) {
Next = Next->MatchingParen;
+ if (!Next)
+ return false;
} else if (Next->is(tok::l_paren)) {
break;
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138371.476974.patch
Type: text/x-patch
Size: 997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221121/df73c79c/attachment-0001.bin>
More information about the cfe-commits
mailing list