summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-10-11 22:55:07 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-10-11 22:55:07 +0000
commitc2ff8e125a1182631931ec42bc49f34a9481b8ca (patch)
treeb4ab1d62cf4bb5328b19887b154eeaa5c1205d2c /clang/lib/Sema/SemaExpr.cpp
parentcdb8ef593b0f13b53e5a63af314328590fb79afc (diff)
downloadbcm5719-llvm-c2ff8e125a1182631931ec42bc49f34a9481b8ca.tar.gz
bcm5719-llvm-c2ff8e125a1182631931ec42bc49f34a9481b8ca.zip
Provide a fixit when taking the address of an unqualified member function.
This only applies if the type has a name. (we could potentially do something crazy with decltype in C++11 to qualify members of unnamed types but that seems excessive) It might be nice to also suggest a fixit for "&this->i", "&foo->i", and "&foo.i" but those expressions produce 'bound' member functions that have a different AST representation & make error recovery a little trickier. Left as future work. llvm-svn: 165763
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 669d8356f5b..74ee8700124 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8056,8 +8056,16 @@ static QualType CheckAddressOfOperand(Sema &S, ExprResult &OrigOp,
// The method was named without a qualifier.
} else if (!DRE->getQualifier()) {
- S.Diag(OpLoc, diag::err_unqualified_pointer_member_function)
- << op->getSourceRange();
+ if (MD->getParent()->getName().empty())
+ S.Diag(OpLoc, diag::err_unqualified_pointer_member_function)
+ << op->getSourceRange();
+ else {
+ SmallString<32> Str;
+ StringRef Qual = (MD->getParent()->getName() + "::").toStringRef(Str);
+ S.Diag(OpLoc, diag::err_unqualified_pointer_member_function)
+ << op->getSourceRange()
+ << FixItHint::CreateInsertion(op->getSourceRange().getBegin(), Qual);
+ }
}
return S.Context.getMemberPointerType(op->getType(),
OpenPOWER on IntegriCloud