[clang-tools-extra] [NFC] Fix potential nullptr dereference. (PR #138283)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 2 07:23:05 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Zahira Ammarguellat (zahiraam)
<details>
<summary>Changes</summary>
A `nullptr` dereference is detected by the code sanitizer. Adding an assert to make sure it's caught.
---
Full diff: https://github.com/llvm/llvm-project/pull/138283.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp (+1)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp
index 247d287be2b36..e90170a6591da 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantFunctionPtrDereferenceCheck.cpp
@@ -25,6 +25,7 @@ void RedundantFunctionPtrDereferenceCheck::registerMatchers(MatchFinder *Finder)
void RedundantFunctionPtrDereferenceCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Operator = Result.Nodes.getNodeAs<UnaryOperator>("op");
+ assert(Operator && "Operator is null");
diag(Operator->getOperatorLoc(),
"redundant repeated dereference of function pointer")
<< FixItHint::CreateRemoval(Operator->getOperatorLoc());
``````````
</details>
https://github.com/llvm/llvm-project/pull/138283
More information about the cfe-commits
mailing list