[clang] f0f4452 - [clang][sema] Sema::CheckFreeArguments - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 12 03:19:02 PST 2022
Author: Simon Pilgrim
Date: 2022-02-12T11:17:02Z
New Revision: f0f4452ed488bc7d9c3b9693dc110f1107921a08
URL: https://github.com/llvm/llvm-project/commit/f0f4452ed488bc7d9c3b9693dc110f1107921a08
DIFF: https://github.com/llvm/llvm-project/commit/f0f4452ed488bc7d9c3b9693dc110f1107921a08.diff
LOG: [clang][sema] Sema::CheckFreeArguments - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr
Added:
Modified:
clang/lib/Sema/SemaChecking.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 575181a6b61c..c422981a1a2e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11310,7 +11310,7 @@ void CheckFreeArgumentsCast(Sema &S, const std::string &CalleeName,
/// Alerts the user that they are attempting to free a non-malloc'd object.
void Sema::CheckFreeArguments(const CallExpr *E) {
const std::string CalleeName =
- dyn_cast<FunctionDecl>(E->getCalleeDecl())->getQualifiedNameAsString();
+ cast<FunctionDecl>(E->getCalleeDecl())->getQualifiedNameAsString();
{ // Prefer something that doesn't involve a cast to make things simpler.
const Expr *Arg = E->getArg(0)->IgnoreParenCasts();
More information about the cfe-commits
mailing list