diff options
author | Vedant Kumar <vsk@apple.com> | 2020-02-10 13:10:47 -0800 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2020-02-10 14:10:06 -0800 |
commit | 8b81ebfe7eba089ed2016d523cc5ee9d05e957a7 (patch) | |
tree | b17dbe5a463c053f41365de7c68c811e299ee0d2 /clang/lib/CodeGen/CGCall.cpp | |
parent | 7683a084de6bd2637f2351f53389df8b610566cf (diff) | |
download | llvm-8b81ebfe7eba089ed2016d523cc5ee9d05e957a7.zip llvm-8b81ebfe7eba089ed2016d523cc5ee9d05e957a7.tar.gz llvm-8b81ebfe7eba089ed2016d523cc5ee9d05e957a7.tar.bz2 |
[ubsan] Null-check and adjust TypeLoc before using it
Null-check and adjut a TypeLoc before casting it to a FunctionTypeLoc.
This fixes a crash in -fsanitize=nullability-return, and also makes the
location of the nonnull type available when the return type is adjusted.
rdar://59263039
Differential Revision: https://reviews.llvm.org/D74355
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 9ef2a3b..e6cb4a1 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3060,7 +3060,7 @@ void CodeGenFunction::EmitReturnValueCheck(llvm::Value *RV) { } else { if (auto *DD = dyn_cast<DeclaratorDecl>(CurCodeDecl)) if (auto *TSI = DD->getTypeSourceInfo()) - if (auto FTL = TSI->getTypeLoc().castAs<FunctionTypeLoc>()) + if (auto FTL = TSI->getTypeLoc().getAsAdjusted<FunctionTypeLoc>()) AttrLoc = FTL.getReturnLoc().findNullabilityLoc(); CheckKind = SanitizerKind::NullabilityReturn; Handler = SanitizerHandler::NullabilityReturn; |