[all-commits] [llvm/llvm-project] 34d8cd: [NFC][CLANG] Fix issue with dereference null retur...
smanna12 via All-commits
all-commits at lists.llvm.org
Fri May 19 19:46:23 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 34d8cd153812c3e5e2db1a1e27f057db33b07b6e
https://github.com/llvm/llvm-project/commit/34d8cd153812c3e5e2db1a1e27f057db33b07b6e
Author: Manna, Soumi <soumi.manna at intel.com>
Date: 2023-05-19 (Fri, 19 May 2023)
Changed paths:
M clang/lib/AST/Decl.cpp
Log Message:
-----------
[NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool
Reported by Coverity:
In clang::FunctionDecl::isReplaceableGlobalAllocationFunction(std::optional<unsigned int> *, bool *): Return value of function which returns null is dereferenced without checking
if (!IsSizedDelete && !Ty.isNull() && Ty->isEnumeralType()) {
QualType T = Ty;
//Condition TD, taking false branch.
while (const auto *TD = T->getAs<TypedefType>())
T = TD->getDecl()->getUnderlyingType();
//returned_null: getAs returns nullptr (checked 95 out of 97 times).
//Dereference null return value (NULL_RETURNS)
// dereference: Dereferencing a pointer that might be nullptr T->getAs() when calling getDecl.
IdentifierInfo *II = T->getAs<EnumType>()->getDecl()->getIdentifier();
if (II && II->isStr("__hot_cold_t"))
Consume();
}
This patch uses castAs instead of getAs which will assert if the type doesn't match.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D150968
More information about the All-commits
mailing list