]> granicus.if.org Git - clang/commitdiff
Fix two small bugs in typo correction. One assertion failure building member expressi...
authorNick Lewycky <nicholas@mxc.ca>
Sat, 13 Dec 2014 02:54:28 +0000 (02:54 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sat, 13 Dec 2014 02:54:28 +0000 (02:54 +0000)
The testcase shows a third bug with a FIXME in it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224183 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
lib/Sema/SemaExprCXX.cpp
test/SemaCXX/typo-correction-pt2.cpp

index ee8f4d9af672d8516b881a507d9214ed9157ff1b..a89036a98cb7c1e354a735c4ee2e053eeef1a044 100644 (file)
@@ -1366,7 +1366,9 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
                                               Idx.get(), RLoc);
       } else {
         (void)Actions.CorrectDelayedTyposInExpr(LHS);
+        (void)Actions.CorrectDelayedTyposInExpr(Idx);
         LHS = ExprError();
+        Idx = ExprError();
       }
 
       // Match the ']'.
index ad376f125421ec8924344c71bc3c4702bfcf96d7..1f9c1ea73cdde93c9a0f89f4f6a28a3c588fe5bc 100644 (file)
@@ -5961,9 +5961,10 @@ static ExprResult attemptRecovery(Sema &SemaRef,
     NewSS = *SS;
 
   if (auto *ND = TC.getCorrectionDecl()) {
+    R.setLookupName(ND->getDeclName());
     R.addDecl(ND);
     if (ND->isCXXClassMember()) {
-      // Figure out the correct naming class to ad to the LookupResult.
+      // Figure out the correct naming class to add to the LookupResult.
       CXXRecordDecl *Record = nullptr;
       if (auto *NNS = TC.getCorrectionSpecifier())
         Record = NNS->getAsType()->getAsCXXRecordDecl();
index 5d3f1236ac26dd8e2580c31b39cc243da06625d9..73c8cb5a5542839b728f3b82b1166625ff12be1c 100644 (file)
@@ -332,3 +332,27 @@ int test(Foo f) {
   return 0;
 }
 };
+
+namespace testMemberExprDeclarationNameInfo {
+  // The AST should only have the corrected name with no mention of 'data_'.
+  // FIXME: the second typo is being printed out with the location of the first
+  // because the TypoCorrection objects contain the SourceRange but the
+  // UnqualifiedTyposCorrected cache is keyed on IdentifierInfo.
+  void f(int);
+  struct S {
+    int data;  // expected-note 2{{'data' declared here}}
+    void m_fn1() {
+      data_[] =  // expected-error 2{{use of undeclared identifier 'data_'}}  expected-error {{expected expression}}
+          f(data_);
+    }
+  };
+}
+
+namespace testArraySubscriptIndex {
+  struct S {
+    int foodata;  // expected-note {{'foodata' declared here}}
+    void m_fn1() {
+      (+)[foodata_];  // expected-error{{expected expression}} expected-error {{use of undeclared identifier 'foodata_'; did you mean 'foodata'}}
+    }
+  };
+}