Explicitly exclude keywords from the member validator.
authorKaelyn Takata <rikka@google.com>
Tue, 11 Nov 2014 23:00:40 +0000 (23:00 +0000)
committerKaelyn Takata <rikka@google.com>
Tue, 11 Nov 2014 23:00:40 +0000 (23:00 +0000)
Also simply and remove dead code from MemberExprTypoRecovery.

llvm-svn: 221723

clang/lib/Sema/SemaExprMember.cpp

index 1f17441..f773321 100644 (file)
@@ -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();