When checking for nonnull parameter attributes, also check the ParmVarDecl since the attribute may reside there, instead of just on the FunctionDecl. Fixes PR21668.
llvm-svn: 224039
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 8e55925..57fc14e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6766,7 +6766,8 @@
}
if (!AttrNonNull.empty())
for (unsigned i = 0; i < NumArgs; ++i)
- if (FD->getParamDecl(i) == PV && AttrNonNull[i]) {
+ if (FD->getParamDecl(i) == PV &&
+ (AttrNonNull[i] || PV->hasAttr<NonNullAttr>())) {
std::string Str;
llvm::raw_string_ostream S(Str);
E->printPretty(S, nullptr, getPrintingPolicy());