[clang] aa1e15d - TokenAnnotator.cpp - remove useless pointer null test. NFCI.
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 16 04:35:34 PDT 2020
Author: Simon Pilgrim
Date: 2020-09-16T12:30:24+01:00
New Revision: aa1e15dda9e5941611f2183ba34087c2d02beb1a
URL: https://github.com/llvm/llvm-project/commit/aa1e15dda9e5941611f2183ba34087c2d02beb1a
DIFF: https://github.com/llvm/llvm-project/commit/aa1e15dda9e5941611f2183ba34087c2d02beb1a.diff
LOG: TokenAnnotator.cpp - remove useless pointer null test. NFCI.
We dereference the Left pointer throughout the parseParens() function apart from this single case - just add an non-null assertion and drop the check.
Fixes clang static analayzer null dereference warning.
Added:
Modified:
clang/lib/Format/TokenAnnotator.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 841f0b41e9a7f..2fa3b28f3a390 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -198,8 +198,8 @@ class AnnotatingParser {
if (!CurrentToken)
return false;
FormatToken *Left = CurrentToken->Previous;
- FormatToken *PrevNonComment =
- Left ? Left->getPreviousNonComment() : nullptr;
+ assert(Left && "Unknown previous token");
+ FormatToken *PrevNonComment = Left->getPreviousNonComment();
Left->ParentBracket = Contexts.back().ContextKind;
ScopedContextCreator ContextCreator(*this, tok::l_paren, 1);
More information about the cfe-commits
mailing list