[cfe-commits] r158231 - in /cfe/trunk: lib/Sema/SemaLookup.cpp test/SemaCXX/typo-correction.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Jun 8 14:35:43 PDT 2012
Author: rsmith
Date: Fri Jun 8 16:35:42 2012
New Revision: 158231
URL: http://llvm.org/viewvc/llvm-project?rev=158231&view=rev
Log:
PR13051: Only suggest the 'template' and 'operator' keywords when performing
typo-correction after a scope specifier.
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/SemaCXX/typo-correction.cpp
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=158231&r1=158230&r2=158231&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Jun 8 16:35:42 2012
@@ -3533,7 +3533,16 @@
/// \brief Add keywords to the consumer as possible typo corrections.
static void AddKeywordsToConsumer(Sema &SemaRef,
TypoCorrectionConsumer &Consumer,
- Scope *S, CorrectionCandidateCallback &CCC) {
+ Scope *S, CorrectionCandidateCallback &CCC,
+ bool AfterNestedNameSpecifier) {
+ if (AfterNestedNameSpecifier) {
+ // For 'X::', we know exactly which keywords can appear next.
+ Consumer.addKeywordResult("template");
+ if (CCC.WantExpressionKeywords)
+ Consumer.addKeywordResult("operator");
+ return;
+ }
+
if (CCC.WantObjCSuper)
Consumer.addKeywordResult("super");
@@ -3823,7 +3832,7 @@
}
}
- AddKeywordsToConsumer(*this, Consumer, S, CCC);
+ AddKeywordsToConsumer(*this, Consumer, S, CCC, SS && SS->isNotEmpty());
// If we haven't found anything, we're done.
if (Consumer.empty()) {
Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=158231&r1=158230&r2=158231&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Fri Jun 8 16:35:42 2012
@@ -206,3 +206,16 @@
namespace bazquux { struct Thing {}; }
void f() { Thing t; } // expected-error{{unknown type name 'Thing'}}
}
+
+namespace PR13051 {
+ template<typename T> struct S {
+ template<typename U> void f();
+ operator bool() const;
+ };
+
+ void f() {
+ f(&S<int>::tempalte f<int>); // expected-error{{did you mean 'template'?}}
+ f(&S<int>::opeartor bool); // expected-error{{did you mean 'operator'?}}
+ f(&S<int>::foo); // expected-error-re{{no member named 'foo' in 'PR13051::S<int>'$}}
+ }
+}
More information about the cfe-commits
mailing list