summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2014-04-04 22:16:30 +0000
committerKaelyn Takata <rikka@google.com>2014-04-04 22:16:30 +0000
commitfb271f0cabbeb2d44772dcd7f07d2df6b9cec772 (patch)
tree0badcf3c62017d841b22d72c608044f817201017 /clang/lib/Sema/SemaLookup.cpp
parent99ed6dfa00fc1182efef430c53d1eadd519ef5c7 (diff)
downloadbcm5719-llvm-fb271f0cabbeb2d44772dcd7f07d2df6b9cec772.tar.gz
bcm5719-llvm-fb271f0cabbeb2d44772dcd7f07d2df6b9cec772.zip
Try harder about not suggesting methods as corrections when they
obviously won't work. Specifically, don't suggest methods (static or not) from unrelated classes when the expression is a method call through a specific object. llvm-svn: 205653
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index ac6fb25caee..39a1ceaa57e 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -4511,10 +4511,9 @@ bool CorrectionCandidateCallback::ValidateCandidate(const TypoCorrection &candid
FunctionCallFilterCCC::FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs,
bool HasExplicitTemplateArgs,
- bool AllowNonStaticMethods)
+ MemberExpr *ME)
: NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
- AllowNonStaticMethods(AllowNonStaticMethods),
- CurContext(SemaRef.CurContext) {
+ CurContext(SemaRef.CurContext), MemberFn(ME) {
WantTypeSpecifiers = SemaRef.getLangOpts().CPlusPlus;
WantRemainingKeywords = false;
}
@@ -4550,13 +4549,16 @@ bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) {
FD->getMinRequiredArguments() <= NumArgs))
continue;
- // If the current candidate is a non-static C++ method and non-static
- // methods are being excluded, then skip the candidate unless the current
- // DeclContext is a method in the same class or a descendent class of the
- // candidate's parent class.
+ // If the current candidate is a non-static C++ method, skip the candidate
+ // unless the method being corrected--or the current DeclContext, if the
+ // function being corrected is not a method--is a method in the same class
+ // or a descendent class of the candidate's parent class.
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
- if (!AllowNonStaticMethods && !MD->isStatic()) {
- CXXMethodDecl *CurMD = dyn_cast_or_null<CXXMethodDecl>(CurContext);
+ if (MemberFn || !MD->isStatic()) {
+ CXXMethodDecl *CurMD =
+ MemberFn
+ ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->getMemberDecl())
+ : dyn_cast_or_null<CXXMethodDecl>(CurContext);
CXXRecordDecl *CurRD =
CurMD ? CurMD->getParent()->getCanonicalDecl() : 0;
CXXRecordDecl *RD = MD->getParent()->getCanonicalDecl();
OpenPOWER on IntegriCloud