[clang] f8c7457 - [NFC] Avoid potential null dereference. (#126872)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 12 09:36:06 PST 2025
Author: schittir
Date: 2025-02-12T09:36:02-08:00
New Revision: f8c7457c79eece1bd1b7f15e7679517c7c63ad89
URL: https://github.com/llvm/llvm-project/commit/f8c7457c79eece1bd1b7f15e7679517c7c63ad89
DIFF: https://github.com/llvm/llvm-project/commit/f8c7457c79eece1bd1b7f15e7679517c7c63ad89.diff
LOG: [NFC] Avoid potential null dereference. (#126872)
Add a null check.
Added:
Modified:
clang/lib/Format/UnwrappedLineFormatter.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 46545aa1f4c07..a5b30c85974c7 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1596,7 +1596,7 @@ static auto computeNewlines(const AnnotatedLine &Line,
if (Line.startsWith(TT_NamespaceRBrace)) {
if (Style.WrapNamespaceBodyWithEmptyLines == FormatStyle::WNBWELS_Never)
Newlines = 1;
- else if (!PreviousLine->startsWith(TT_NamespaceRBrace))
+ else if (PreviousLine && !PreviousLine->startsWith(TT_NamespaceRBrace))
Newlines = std::max(Newlines, 2u);
}
}
More information about the cfe-commits
mailing list