Whenever we emit a typo-correction diagnostic, also emit a note
pointing to the declaration that we found that has that name (if it is
unique).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92877 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3d2ee74..730375e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -943,7 +943,10 @@
<< SS.getRange()
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
R.getLookupName().getAsString());
-
+ if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
+ Diag(ND->getLocation(), diag::note_previous_decl)
+ << ND->getDeclName();
+
// Tell the callee to try to recover.
return false;
}
@@ -2400,6 +2403,9 @@
<< Name << DC << R.getLookupName() << SS.getRange()
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
R.getLookupName().getAsString());
+ if (NamedDecl *ND = R.getAsSingle<NamedDecl>())
+ SemaRef.Diag(ND->getLocation(), diag::note_previous_decl)
+ << ND->getDeclName();
return false;
} else {
R.clear();
@@ -2881,6 +2887,8 @@
<< IDecl->getDeclName() << MemberName << IV->getDeclName()
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
IV->getNameAsString());
+ Diag(IV->getLocation(), diag::note_previous_decl)
+ << IV->getDeclName();
}
}
@@ -3060,6 +3068,10 @@
<< MemberName << BaseType << Res.getLookupName()
<< CodeModificationHint::CreateReplacement(R.getNameLoc(),
Res.getLookupName().getAsString());
+ ObjCPropertyDecl *Property = Res.getAsSingle<ObjCPropertyDecl>();
+ Diag(Property->getLocation(), diag::note_previous_decl)
+ << Property->getDeclName();
+
return LookupMemberExpr(Res, BaseExpr, IsArrow, OpLoc, SS,
FirstQualifierInScope, ObjCImpDecl);
}