vsapsai added a comment.

Correcting typo in Sema::ActOnMemberAccessExpr is an interesting idea and it 
almost works. After such change there is a single failure in 
clang/test/SemaCXX/typo-correction-cxx11.cpp

  void run(A *annotations) {
    map new_annotations;
  
    auto &annotation = *annotations;
    auto new_it = new_annotations.find(5);
    auto &new_anotation = new_it.second;  // expected-note {{'new_anotation' 
declared here}}
    new_annotation->Swap(&annotation);  // expected-error {{use of undeclared 
identifier 'new_annotation'; did you mean 'new_anotation'?}}
  }

because we don't mention `did you mean 'new_anotation'?` anymore. I haven't 
investigated in depth what's causing it but my guess is that general typo 
correction doesn't suggest replacement due to ambiguity between new_anotation 
and new_annotations, and prevents member-specific typo correction from handling 
it.

I think having CXXDependentScopeMemberExpr for an ObjC property should be fine 
as we are dealing with invalid code and all typos are already type-dependent 
and instantiation-dependent though it doesn't apply to ObjC.

I agree that my fix isn't specific to the code triggering the assertion. But 
broader fix can be useful as it covers more cases. After checking SemaExpr.cpp 
and its multiple CorrectDelayedTyposInExpr, CorrectTypo, CorrectTypoDelayed I 
have an impression that typo correction absent in Sema::BuildBinOp is an 
omission worth fixing.


https://reviews.llvm.org/D37322



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to