Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -3060,7 +3060,7 @@ } else { if (auto *DD = dyn_cast(CurCodeDecl)) if (auto *TSI = DD->getTypeSourceInfo()) - if (auto FTL = TSI->getTypeLoc().castAs()) + if (auto FTL = TSI->getTypeLoc().getAs()) AttrLoc = FTL.getReturnLoc().findNullabilityLoc(); CheckKind = SanitizerKind::NullabilityReturn; Handler = SanitizerHandler::NullabilityReturn; Index: clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m =================================================================== --- /dev/null +++ clang/test/CodeGenObjC/ubsan-nullability-return-notypeloc.m @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s + +// CHECK-LABEL: define i8* @foo() +// CHECK: call i8* @helper() +// CHECK-NEXT: ret i8* + +#pragma clang assume_nonnull begin +__attribute__((ns_returns_retained)) id foo(void) { + extern id helper(void); + return helper(); +} +#pragma clang assume_nonnull end