[clang] 4e77868 - [SemaDecl] Use castAs<> instead of getAs<> to avoid dereference of nullptr
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 10 08:31:20 PST 2022
Author: Simon Pilgrim
Date: 2022-01-10T16:31:08Z
New Revision: 4e77868c7c4ba79ed025b87f84ce66fc8dca25d6
URL: https://github.com/llvm/llvm-project/commit/4e77868c7c4ba79ed025b87f84ce66fc8dca25d6
DIFF: https://github.com/llvm/llvm-project/commit/4e77868c7c4ba79ed025b87f84ce66fc8dca25d6.diff
LOG: [SemaDecl] Use castAs<> instead of getAs<> to avoid dereference of nullptr
This will assert the cast is correct instead of returning nullptr
Added:
Modified:
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d39d010f5eae4..1e6d4fd04604e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9921,7 +9921,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
<< NewFD;
// Turn this into a variadic function with no parameters.
- const FunctionType *FT = NewFD->getType()->getAs<FunctionType>();
+ const auto *FT = NewFD->getType()->castAs<FunctionType>();
FunctionProtoType::ExtProtoInfo EPI(
Context.getDefaultCallingConvention(true, false));
EPI.Variadic = true;
More information about the cfe-commits
mailing list