Commit Graph

269 Commits

Author SHA1 Message Date
Douglas Gregor 598b08f818 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
2009-12-31 05:20:13 +00:00
Douglas Gregor 2d435306e5 Typo correction for type names when they appear in declarations, e.g., given
tring str2;

we produce the following diagnostic + fix-it:

typo.cpp:15:1: error: unknown type name 'tring'; did you mean 'string'?
  tring str2;
  ^~~~~
  string


To make this really useful, we'll need to introduce typo correction in
many more places (wherever we do name lookup), and implement
declaration-vs-expression heuristics that cope with typos
better. However, for now this will handle the simple cases where we
already get good "unknown type name" diagnostics.

The LookupVisibleDecls functions are intended to be used by code
completion as well as typo correction; that refactoring will happen
later.

llvm-svn: 92308
2009-12-30 17:04:44 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Fariborz Jahanian a01b67d7b0 Make tests use the new clang -cc1 flag.
llvm-svn: 91303
2009-12-14 18:00:56 +00:00
Douglas Gregor d0c22e0d10 Implement conversion from a switch condition with class type to an
integral or enumeration type (vi user-defined conversions). Fixes PR5518.

llvm-svn: 89655
2009-11-23 13:46:08 +00:00
Daniel Dunbar f6e32e4abe Drop unnecessary #include.
llvm-svn: 89154
2009-11-17 22:25:16 +00:00
Daniel Dunbar cf5be70032 Improve test to make sure -fixit is really working.
llvm-svn: 88801
2009-11-14 19:25:21 +00:00
Daniel Dunbar 6c39d457fa Update FixIt tests to make it more obvious they use a separate mode.
llvm-svn: 88758
2009-11-14 04:39:42 +00:00
Anders Carlsson ace5d07e50 When trying to assign a regular string literal to an Objective-C 'id' type or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example:
@class NSString;

@interface Test
+ (void)test:(NSString *)string;
@end

void g(NSString *a);

void f() {
  NSString *a = "Foo";
  g("Foo");
  [Test test:"Foo"];
}

will produce

t.m:10:17: warning: incompatible pointer types initializing 'char [4]', expected 'NSString *'
  NSString *a = "Foo";
                ^~~~~
                @
t.m:11:5: warning: incompatible pointer types passing 'char [4]', expected 'NSString *'
  g("Foo");
    ^~~~~
    @
t.m:12:14: warning: incompatible pointer types sending 'char [4]', expected 'NSString *'
  [Test test:"Foo"];
             ^~~~~
             @
3 diagnostics generated.

llvm-svn: 86665
2009-11-10 04:46:30 +00:00
Anders Carlsson 0b8ea554e5 If a function with a default argument is redefined and the new function also has a defualt argument then add a fixit hint that removes the default argument. Fixes PR5444.
llvm-svn: 86659
2009-11-10 03:24:44 +00:00
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Douglas Gregor d82ae38d53 Rework the fix-it hint for code like
get_origin->x

where get_origin is actually a function and the user has forgotten the
parentheses. Instead of giving a lame note for the fix-it, give a
full-fledge error, early, then build the call expression to try to
recover. 

llvm-svn: 86238
2009-11-06 06:30:47 +00:00
Fariborz Jahanian 59f64202d6 Add 'fixit' hint on mis-use of pointer-to-member
binary operators.

llvm-svn: 85153
2009-10-26 20:45:27 +00:00
Daniel Dunbar f39ea8535b Update test case; I'm confused why this wasn't failing on the buildbot
though?

llvm-svn: 71955
2009-05-16 19:30:01 +00:00
Douglas Gregor 7a5bc76b81 Fixed the Fix-It hints for comparison against a string literal. Thanks, Chris!
llvm-svn: 68454
2009-04-06 18:45:53 +00:00
Chris Lattner 3a4e43107b add fixit advice to an archiac ObjC issue.
llvm-svn: 68395
2009-04-03 18:38:42 +00:00
Mike Stump 898840f98c Move the rest of the fixit tests to the FixIt area.
llvm-svn: 68349
2009-04-02 23:44:32 +00:00
Douglas Gregor 9c0d38a7a0 Add a new command-line option "-fixit-at=file:line:column" that only
applies fix-its to error messages that occur at that specific location
in the program. 

llvm-svn: 68342
2009-04-02 19:05:20 +00:00
Douglas Gregor 68bc53967e Move the fix-it tests into their own subdirectory
llvm-svn: 68325
2009-04-02 17:19:13 +00:00