Use the source location of the parameter, when it makes sense, for diagnostics in HandleCleanupAttr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121013 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index c429fd3..d53fd68 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1417,24 +1417,26 @@
// FIXME: The lookup source location should be in the attribute, not the
// start of the attribute.
NamedDecl *CleanupDecl
- = S.LookupSingleName(S.TUScope, Attr.getParameterName(), Attr.getLoc(),
- Sema::LookupOrdinaryName);
+ = S.LookupSingleName(S.TUScope, Attr.getParameterName(),
+ Attr.getParameterLoc(), Sema::LookupOrdinaryName);
if (!CleanupDecl) {
- S.Diag(Attr.getLoc(), diag::err_attribute_cleanup_arg_not_found) <<
+ S.Diag(Attr.getParameterLoc(), diag::err_attribute_cleanup_arg_not_found) <<
Attr.getParameterName();
return;
}
FunctionDecl *FD = dyn_cast<FunctionDecl>(CleanupDecl);
if (!FD) {
- S.Diag(Attr.getLoc(), diag::err_attribute_cleanup_arg_not_function) <<
- Attr.getParameterName();
+ S.Diag(Attr.getParameterLoc(),
+ diag::err_attribute_cleanup_arg_not_function)
+ << Attr.getParameterName();
return;
}
if (FD->getNumParams() != 1) {
- S.Diag(Attr.getLoc(), diag::err_attribute_cleanup_func_must_take_one_arg) <<
- Attr.getParameterName();
+ S.Diag(Attr.getParameterLoc(),
+ diag::err_attribute_cleanup_func_must_take_one_arg)
+ << Attr.getParameterName();
return;
}
@@ -1443,7 +1445,7 @@
QualType Ty = S.Context.getPointerType(VD->getType());
QualType ParamTy = FD->getParamDecl(0)->getType();
if (S.CheckAssignmentConstraints(ParamTy, Ty) != Sema::Compatible) {
- S.Diag(Attr.getLoc(),
+ S.Diag(Attr.getParameterLoc(),
diag::err_attribute_cleanup_func_arg_incompatible_type) <<
Attr.getParameterName() << ParamTy << Ty;
return;