r227278 - Use the real CXXScopeSpec when setting the correction SourceRange.

Kaelyn Takata rikka at google.com
Tue Jan 27 16:46:10 PST 2015


Author: rikka
Date: Tue Jan 27 18:46:09 2015
New Revision: 227278

URL: http://llvm.org/viewvc/llvm-project?rev=227278&view=rev
Log:
Use the real CXXScopeSpec when setting the correction SourceRange.

Otherwise, in the most important case and the only case where SS and
TempSS are different (which is when the CXXScopeSpec should be dropped,
and TempSS is NULL) the wrong SourceRange will be used in the fixit for
the typo correction. Fixes the remaining issue in PR20626.

Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/test/FixIt/typo-location-bugs.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=227278&r1=227277&r2=227278&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Jan 27 18:46:09 2015
@@ -3587,7 +3587,7 @@ retry_lookup:
         QualifiedResults.push_back(Candidate);
       break;
     }
-    Candidate.setCorrectionRange(TempSS, Result.getLookupNameInfo());
+    Candidate.setCorrectionRange(SS.get(), Result.getLookupNameInfo());
     return true;
   }
   return false;

Modified: cfe/trunk/test/FixIt/typo-location-bugs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/typo-location-bugs.cpp?rev=227278&r1=227277&r2=227278&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/typo-location-bugs.cpp (original)
+++ cfe/trunk/test/FixIt/typo-location-bugs.cpp Tue Jan 27 18:46:09 2015
@@ -34,3 +34,16 @@ void test(B b) {
   b.f(1);  // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'A::f'?}}
 }
 }
+
+namespace PR20626 {
+class A {
+public:
+  void Foo(){};  // expected-note{{'Foo' declared here}}
+};
+class B {};
+class C : public A, public B {
+  void Run() {
+    B::Foo();  // expected-error{{no member named 'Foo' in 'PR20626::B'; did you mean simply 'Foo'?}}
+  }
+};
+}





More information about the cfe-commits mailing list