Skip to content

Commit fd42e95

Browse files
committed
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. llvm-svn: 104889
1 parent 6debf89 commit fd42e95

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2990,8 +2990,11 @@ void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
29902990
QualType ClassTy = Context.getTagDeclType(ClassDecl);
29912991
if (Context.getCanonicalType(ParamType).getUnqualifiedType() == ClassTy) {
29922992
SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
2993+
const char *ConstRef
2994+
= Constructor->getParamDecl(0)->getIdentifier() ? "const &"
2995+
: " const &";
29932996
Diag(ParamLoc, diag::err_constructor_byvalue_arg)
2994-
<< FixItHint::CreateInsertion(ParamLoc, " const &");
2997+
<< FixItHint::CreateInsertion(ParamLoc, ConstRef);
29952998

29962999
// FIXME: Rather that making the constructor invalid, we should endeavor
29973000
// to fix the type.

0 commit comments

Comments
 (0)