Tweak the fix-it for a copy constructor declared to take its argument

by-value. We now only prepend a space if it is needed. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104889 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2010-05-27 21:28:21 +00:00
Родитель 690c2e22d4
Коммит aeb4a28256
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -2990,8 +2990,11 @@ void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
QualType ClassTy = Context.getTagDeclType(ClassDecl);
if (Context.getCanonicalType(ParamType).getUnqualifiedType() == ClassTy) {
SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
const char *ConstRef
= Constructor->getParamDecl(0)->getIdentifier() ? "const &"
: " const &";
Diag(ParamLoc, diag::err_constructor_byvalue_arg)
<< FixItHint::CreateInsertion(ParamLoc, " const &");
<< FixItHint::CreateInsertion(ParamLoc, ConstRef);
// FIXME: Rather that making the constructor invalid, we should endeavor
// to fix the type.