From: Kaelyn Takata Date: Tue, 11 Nov 2014 23:00:40 +0000 (+0000) Subject: Explicitly exclude keywords from the member validator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35fad28c765980e390a533e690eb88539d5dd912;p=clang Explicitly exclude keywords from the member validator. Also simply and remove dead code from MemberExprTypoRecovery. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221723 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index 1f17441286..f77332114c 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/lib/Sema/SemaExprMember.cpp @@ -539,7 +539,15 @@ namespace { class RecordMemberExprValidatorCCC : public CorrectionCandidateCallback { public: explicit RecordMemberExprValidatorCCC(const RecordType *RTy) - : Record(RTy->getDecl()) {} + : Record(RTy->getDecl()) { + // Don't add bare keywords to the consumer since they will always fail + // validation by virtue of not being associated with any decls. + WantTypeSpecifiers = false; + WantExpressionKeywords = false; + WantCXXNamedCasts = false; + WantFunctionLikeCasts = false; + WantRemainingKeywords = false; + } bool ValidateCandidate(const TypoCorrection &candidate) override { NamedDecl *ND = candidate.getCorrectionDecl(); @@ -1214,9 +1222,6 @@ public: OpLoc(OpLoc), IsArrow(IsArrow) {} ExprResult operator()(Sema &SemaRef, TypoExpr *TE, TypoCorrection TC) { - if (TC.isKeyword()) - return ExprError(); - LookupResult R(SemaRef, TC.getCorrection(), TC.getCorrectionRange().getBegin(), SemaRef.getTypoExprState(TE) @@ -1224,12 +1229,6 @@ public: .getLookupKind()); R.suppressDiagnostics(); - QualType BaseType; - if (auto *DRE = dyn_cast(BaseExpr)) - BaseType = DRE->getDecl()->getType(); - else if (auto *CE = dyn_cast(BaseExpr)) - BaseType = CE->getCallReturnType(); - for (NamedDecl *ND : TC) R.addDecl(ND); R.resolveKind();