r221723 - Explicitly exclude keywords from the member validator.

Kaelyn Takata rikka at google.com
Tue Nov 11 15:00:40 PST 2014


Author: rikka
Date: Tue Nov 11 17:00:40 2014
New Revision: 221723

URL: http://llvm.org/viewvc/llvm-project?rev=221723&view=rev
Log:
Explicitly exclude keywords from the member validator.

Also simply and remove dead code from MemberExprTypoRecovery.

Modified:
    cfe/trunk/lib/Sema/SemaExprMember.cpp

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=221723&r1=221722&r2=221723&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Nov 11 17:00:40 2014
@@ -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<DeclRefExpr>(BaseExpr))
-      BaseType = DRE->getDecl()->getType();
-    else if (auto *CE = dyn_cast<CallExpr>(BaseExpr))
-      BaseType = CE->getCallReturnType();
-
     for (NamedDecl *ND : TC)
       R.addDecl(ND);
     R.resolveKind();





More information about the cfe-commits mailing list