[clang] c61299e - [SemaOverload] Use castAs<> instead of getAs<> to avoid dereference of nullptr
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 11 02:31:39 PST 2022
Author: Simon Pilgrim
Date: 2022-01-11T10:31:25Z
New Revision: c61299e2b30627f327f5a9a198ad030092534496
URL: https://github.com/llvm/llvm-project/commit/c61299e2b30627f327f5a9a198ad030092534496
DIFF: https://github.com/llvm/llvm-project/commit/c61299e2b30627f327f5a9a198ad030092534496.diff
LOG: [SemaOverload] Use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointer is always dereferenced inside BuildSimilarlyQualifiedPointerType, so assert the cast is correct instead of returning nullptr
Added:
Modified:
clang/lib/Sema/SemaOverload.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 7b503103006d5..041fcee023a5b 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2405,9 +2405,8 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
if (FromType->isObjCObjectPointerType() && ToPointeeType->isVoidType() &&
!getLangOpts().ObjCAutoRefCount) {
ConvertedType = BuildSimilarlyQualifiedPointerType(
- FromType->getAs<ObjCObjectPointerType>(),
- ToPointeeType,
- ToType, Context);
+ FromType->castAs<ObjCObjectPointerType>(), ToPointeeType, ToType,
+ Context);
return true;
}
const PointerType *FromTypePtr = FromType->getAs<PointerType>();
More information about the cfe-commits
mailing list