summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2014-12-13 02:54:28 +0000
committerNick Lewycky <nicholas@mxc.ca>2014-12-13 02:54:28 +0000
commit01ad4ae72b375ffd6ee1a44240c7a55498ccef8b (patch)
treeef6d4254ad8db0fe9f003edf343be1329440b2e6
parent035b964d728f8ea973c08603597051c50333cc99 (diff)
downloadbcm5719-llvm-01ad4ae72b375ffd6ee1a44240c7a55498ccef8b.tar.gz
bcm5719-llvm-01ad4ae72b375ffd6ee1a44240c7a55498ccef8b.zip
Fix two small bugs in typo correction. One assertion failure building member expressions because the lookup finds a different name than the original, fixed by updating the LookupResult's name with the name of the found decl. Second is that we also diagnose delayed typo exprs in the index of an array subscript expression.
The testcase shows a third bug with a FIXME in it. llvm-svn: 224183
-rw-r--r--clang/lib/Parse/ParseExpr.cpp2
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp3
-rw-r--r--clang/test/SemaCXX/typo-correction-pt2.cpp24
3 files changed, 28 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index ee8f4d9af67..a89036a98cb 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -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 ']'.
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index ad376f12542..1f9c1ea73cd 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -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();
diff --git a/clang/test/SemaCXX/typo-correction-pt2.cpp b/clang/test/SemaCXX/typo-correction-pt2.cpp
index 5d3f1236ac2..73c8cb5a554 100644
--- a/clang/test/SemaCXX/typo-correction-pt2.cpp
+++ b/clang/test/SemaCXX/typo-correction-pt2.cpp
@@ -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'}}
+ }
+ };
+}
OpenPOWER on IntegriCloud