diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-31 05:20:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-31 05:20:13 +0000 |
commit | 598b08f8182e51759e1ebca4ecd560092890be65 (patch) | |
tree | 6ff03a77ab79a564e1944330488eba708960f2f8 /clang/test/FixIt/typo.cpp | |
parent | 5639af4eac2bb44aa96c7c3cd3cdef30f9c80590 (diff) | |
download | bcm5719-llvm-598b08f8182e51759e1ebca4ecd560092890be65.tar.gz bcm5719-llvm-598b08f8182e51759e1ebca4ecd560092890be65.zip |
Implement typo correction for id-expressions, e.g.,
typo.cpp:22:10: error: use of undeclared identifier 'radious'; did
you mean 'radius'?
return radious * pi;
^~~~~~~
radius
This was super-easy, since we already had decent recovery by looking
for names in dependent base classes.
llvm-svn: 92341
Diffstat (limited to 'clang/test/FixIt/typo.cpp')
-rw-r--r-- | clang/test/FixIt/typo.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/test/FixIt/typo.cpp b/clang/test/FixIt/typo.cpp index b884ffa7555..6c232f74038 100644 --- a/clang/test/FixIt/typo.cpp +++ b/clang/test/FixIt/typo.cpp @@ -1,7 +1,11 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -fixit -o - | %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ - namespace std { - template<typename T> class basic_string { }; + template<typename T> class basic_string { + int find(const char *substr); + static const int npos = -1; + }; + typedef basic_string<char> string; } @@ -13,3 +17,11 @@ using namespace std; otherstd::strng str1; // expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}} tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}} + +float area(float radius, float pi) { + return radious * pi; // expected-error{{use of undeclared identifier 'radious'; did you mean 'radius'?}} +} + +bool test_string(std::string s) { + return s.find("hello") == std::string::pos; // expected-error{{no member named 'pos' in 'class std::basic_string<char>'; did you mean 'npos'?}} +} |