summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorKaelyn Uhrain <rikka@google.com>2013-09-26 19:10:29 +0000
committerKaelyn Uhrain <rikka@google.com>2013-09-26 19:10:29 +0000
commit95995be7a35167e404a844b7156448814c33d7ea (patch)
tree6cd450caf17e6d84ecc1248aa8e3cb4326b2f9bb /clang/test
parente228d1070909d55a253640a0c50046a969f0bff2 (diff)
downloadbcm5719-llvm-95995be7a35167e404a844b7156448814c33d7ea.tar.gz
bcm5719-llvm-95995be7a35167e404a844b7156448814c33d7ea.zip
Teach typo correction to look inside of classes like it does namespaces.
Unlike with namespaces, searching inside of classes requires also checking the access to correction candidates (i.e. don't suggest a correction to a private class member for a correction occurring outside that class and its methods or friends). Included is a small (one line) fix for a bug, that was uncovered while cleaning up the unit tests, where the decls from a TypoCorrection candidate were preserved in new TypoCorrection candidates that are derived (copied) from the old TypoCorrection--notably when creating a new candidate by changing the NestedNameSpecifier associated with the base idenitifer. llvm-svn: 191449
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp8
-rw-r--r--clang/test/CXX/class/class.nested.type/p1.cpp8
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp6
-rw-r--r--clang/test/FixIt/typo-using.cpp12
-rw-r--r--clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp8
-rw-r--r--clang/test/SemaCXX/typo-correction-pt2.cpp61
6 files changed, 82 insertions, 21 deletions
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
index df9a2cd14cd..e61df3e586a 100644
--- a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
@@ -5,7 +5,7 @@ namespace N {
X operator+(X, X);
- void f(X);
+ void f(X); // expected-note 2 {{'N::f' declared here}}
void g(X); // expected-note{{candidate function}}
void test_multiadd(X x) {
@@ -17,7 +17,7 @@ namespace M {
struct Y : N::X { };
}
-void f(); // expected-note 2 {{'f' declared here}}
+void f();
void test_operator_adl(N::X x, M::Y y) {
(void)(x + x);
@@ -27,8 +27,8 @@ void test_operator_adl(N::X x, M::Y y) {
void test_func_adl(N::X x, M::Y y) {
f(x);
f(y);
- (f)(x); // expected-error{{too many arguments to function call}}
- ::f(x); // expected-error{{too many arguments to function call}}
+ (f)(x); // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'N::f'?}}
+ ::f(x); // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'N::f'?}}
}
namespace N {
diff --git a/clang/test/CXX/class/class.nested.type/p1.cpp b/clang/test/CXX/class/class.nested.type/p1.cpp
index 4a04a448595..92956544123 100644
--- a/clang/test/CXX/class/class.nested.type/p1.cpp
+++ b/clang/test/CXX/class/class.nested.type/p1.cpp
@@ -2,12 +2,12 @@
class X {
public:
- typedef int I;
- class Y { };
+ typedef int I; // expected-note{{'X::I' declared here}}
+ class Y { }; // expected-note{{'X::Y' declared here}}
I a;
};
-I b; // expected-error{{unknown type name 'I'}}
-Y c; // expected-error{{unknown type name 'Y'}}
+I b; // expected-error{{unknown type name 'I'; did you mean 'X::I'?}}
+Y c; // expected-error{{unknown type name 'Y'; did you mean 'X::Y'?}}
X::Y d;
X::I e;
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
index 385e45dadfa..27ebb8e036f 100644
--- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
@@ -1,16 +1,16 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A {
- virtual void f(int a = 7);
+ virtual void f(int a = 7); // expected-note{{'A::f' declared here}}
};
struct B : public A {
- void f(int a); // expected-note{{'f' declared here}}
+ void f(int a);
};
void m() {
B* pb = new B;
A* pa = pb;
pa->f(); // OK, calls pa->B::f(7)
- pb->f(); // expected-error{{too few arguments}}
+ pb->f(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean 'A::f'?}}
}
diff --git a/clang/test/FixIt/typo-using.cpp b/clang/test/FixIt/typo-using.cpp
index 3644dea3b23..e676b1074f9 100644
--- a/clang/test/FixIt/typo-using.cpp
+++ b/clang/test/FixIt/typo-using.cpp
@@ -23,21 +23,21 @@ using N::FFG; // expected-error {{no member named 'FFG' in namespace 'using_sugg
}
namespace using_suggestion_ty_dropped_specifier {
-class AAA {}; // expected-note {{'::using_suggestion_ty_dropped_specifier::AAA' declared here}}
+class ABC {}; // expected-note {{'::using_suggestion_ty_dropped_specifier::ABC' declared here}}
namespace N { }
-using N::AAA; // expected-error {{no member named 'AAA' in namespace 'using_suggestion_ty_dropped_specifier::N'; did you mean '::using_suggestion_ty_dropped_specifier::AAA'?}}
+using N::ABC; // expected-error {{no member named 'ABC' in namespace 'using_suggestion_ty_dropped_specifier::N'; did you mean '::using_suggestion_ty_dropped_specifier::ABC'?}}
}
namespace using_suggestion_tyname_ty_dropped_specifier {
-class AAA {}; // expected-note {{'::using_suggestion_tyname_ty_dropped_specifier::AAA' declared here}}
+class BCD {}; // expected-note {{'::using_suggestion_tyname_ty_dropped_specifier::BCD' declared here}}
namespace N { }
-using typename N::AAA; // expected-error {{no member named 'AAA' in namespace 'using_suggestion_tyname_ty_dropped_specifier::N'; did you mean '::using_suggestion_tyname_ty_dropped_specifier::AAA'?}}
+using typename N::BCD; // expected-error {{no member named 'BCD' in namespace 'using_suggestion_tyname_ty_dropped_specifier::N'; did you mean '::using_suggestion_tyname_ty_dropped_specifier::BCD'?}}
}
namespace using_suggestion_val_dropped_specifier {
-void FFF() {} // expected-note {{'::using_suggestion_val_dropped_specifier::FFF' declared here}}
+void EFG() {} // expected-note {{'::using_suggestion_val_dropped_specifier::EFG' declared here}}
namespace N { }
-using N::FFF; // expected-error {{no member named 'FFF' in namespace 'using_suggestion_val_dropped_specifier::N'; did you mean '::using_suggestion_val_dropped_specifier::FFF'?}}
+using N::EFG; // expected-error {{no member named 'EFG' in namespace 'using_suggestion_val_dropped_specifier::N'; did you mean '::using_suggestion_val_dropped_specifier::EFG'?}}
}
namespace using_suggestion_member_ty {
diff --git a/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp b/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
index 40bcf45bca3..6195e039551 100644
--- a/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
+++ b/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
@@ -19,7 +19,7 @@ namespace fizbin {
// expected-note{{'fizbin::nested::lessFoobar' declared here}}
class dummy { // expected-note 2 {{'fizbin::dummy' declared here}}
public:
- static bool moreFoobar() { return false; } // expected-note{{'moreFoobar' declared here}}
+ static bool morebar() { return false; } // expected-note{{'morebar' declared here}}
};
}
void Check() { // expected-note{{'Check' declared here}}
@@ -29,9 +29,9 @@ void Check() { // expected-note{{'Check' declared here}}
if (lessFoobar()) Double(7); // expected-error{{use of undeclared identifier 'lessFoobar'; did you mean 'fizbin::nested::lessFoobar'?}}
if (baztool::toFoobar()) Double(7); // expected-error{{use of undeclared identifier 'baztool'; did you mean 'fizbin::baztool'?}}
if (nested::moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'nested'; did you mean 'fizbin::nested'?}}
- if (dummy::moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}}
- if (dummy::mreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}} \
- // expected-error{{no member named 'mreFoobar' in 'fizbin::dummy'; did you mean 'moreFoobar'?}}
+ if (dummy::morebar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}}
+ if (dummy::mrebar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}} \
+ // expected-error{{no member named 'mrebar' in 'fizbin::dummy'; did you mean 'morebar'?}}
if (moFoobin()) Double(7); // expected-error{{use of undeclared identifier 'moFoobin'}}
}
diff --git a/clang/test/SemaCXX/typo-correction-pt2.cpp b/clang/test/SemaCXX/typo-correction-pt2.cpp
index 06f69d7186b..f475b41a9f2 100644
--- a/clang/test/SemaCXX/typo-correction-pt2.cpp
+++ b/clang/test/SemaCXX/typo-correction-pt2.cpp
@@ -33,3 +33,64 @@ void test(Foo F, int num) {
F.B(num); // expected-error {{too many arguments to function call, expected 0, have 1; did you mean '::TemplateFunction::B'?}}
}
}
+namespace using_suggestion_val_dropped_specifier {
+void FFF() {} // expected-note {{'::using_suggestion_val_dropped_specifier::FFF' declared here}}
+namespace N { }
+using N::FFF; // expected-error {{no member named 'FFF' in namespace 'using_suggestion_val_dropped_specifier::N'; did you mean '::using_suggestion_val_dropped_specifier::FFF'?}}
+}
+
+namespace class_member_typo_corrections {
+class Outer {
+public:
+ class Inner {}; // expected-note {{'Outer::Inner' declared here}}
+ Inner MyMethod(Inner arg);
+};
+
+Inner Outer::MyMethod(Inner arg) { // expected-error {{unknown type name 'Inner'; did you mean 'Outer::Inner'?}}
+ // TODO: Recovery needs to be fixed/added for the typo-correction of the
+ // return type so the below error isn't still generated.
+ return Inner(); // expected-error {{no viable conversion from 'class_member_typo_corrections::Outer::Inner' to 'int'}}
+}
+
+class Result {
+public:
+ enum ResultType {
+ ENTITY, // expected-note {{'Result::ENTITY' declared here}}
+ PREDICATE, // expected-note {{'Result::PREDICATE' declared here}}
+ LITERAL // expected-note {{'Result::LITERAL' declared here}}
+ };
+
+ ResultType type();
+};
+
+void test() {
+ Result result_cell;
+ switch (result_cell.type()) {
+ case ENTITY: // expected-error {{use of undeclared identifier 'ENTITY'; did you mean 'Result::ENTITY'?}}
+ case LITERAL: // expected-error {{use of undeclared identifier 'LITERAL'; did you mean 'Result::LITERAL'?}}
+ case PREDICAT: // expected-error {{use of undeclared identifier 'PREDICAT'; did you mean 'Result::PREDICATE'?}}
+ break;
+ }
+}
+
+class Figure {
+ enum ResultType {
+ SQUARE,
+ TRIANGLE,
+ CIRCLE
+ };
+
+public:
+ ResultType type();
+};
+
+void testAccess() {
+ Figure obj;
+ switch (obj.type()) { // expected-warning {{enumeration values 'SQUARE', 'TRIANGLE', and 'CIRCLE' not handled in switch}}
+ case SQUARE: // expected-error-re {{use of undeclared identifier 'SQUARE'$}}
+ case TRIANGLE: // expected-error-re {{use of undeclared identifier 'TRIANGLE'$}}
+ case CIRCE: // expected-error-re {{use of undeclared identifier 'CIRCE'$}}
+ break;
+ }
+}
+}
OpenPOWER on IntegriCloud