Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===---------------------------------------------------------------------===// |
| 2 | // Minor random things that can be improved |
| 3 | //===---------------------------------------------------------------------===// |
Steve Naroff | 3981bf7 | 2008-03-18 20:05:01 +0000 | [diff] [blame] | 4 | |
Chris Lattner | cd09847 | 2007-10-10 18:08:07 +0000 | [diff] [blame] | 5 | Warn about "X && 0x1000" saying that the user may mean "X & 0x1000". |
Chris Lattner | 507cc6c | 2007-10-11 16:06:02 +0000 | [diff] [blame] | 6 | We should do this for any immediate except zero, so long as it doesn't come |
| 7 | from a macro expansion. Likewise for ||. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 8 | |
| 9 | //===---------------------------------------------------------------------===// |
| 10 | |
| 11 | Lexer-related diagnostics should point to the problematic character, not the |
| 12 | start of the token. For example: |
| 13 | |
| 14 | int y = 0000\ |
| 15 | 00080; |
| 16 | |
| 17 | diag.c:4:9: error: invalid digit '8' in octal constant |
| 18 | int y = 0000\ |
| 19 | ^ |
| 20 | |
| 21 | should be: |
| 22 | |
| 23 | diag.c:4:9: error: invalid digit '8' in octal constant |
| 24 | 00080; |
| 25 | ^ |
| 26 | |
Chris Lattner | 136f93a | 2007-07-16 06:55:01 +0000 | [diff] [blame] | 27 | This specific diagnostic is implemented, but others should be updated. |
| 28 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 29 | //===---------------------------------------------------------------------===// |
| 30 | |
Ted Kremenek | dbff47f | 2007-10-10 18:52:22 +0000 | [diff] [blame] | 31 | C++ (checker): For iterators, warn of the use of "iterator++" instead |
| 32 | of "++iterator" when when the value returned by operator++(int) is |
| 33 | ignored. |
Douglas Gregor | a26877f | 2008-11-17 17:14:10 +0000 | [diff] [blame] | 34 | |
| 35 | //===---------------------------------------------------------------------===// |
| 36 | |
| 37 | We want to keep more source range information in Declarator to help |
| 38 | produce better diagnostics. Declarator::getSourceRange() should be |
| 39 | implemented to give a range for the whole declarator with all of its |
| 40 | specifiers, and DeclaratorChunk::ParamInfo should also have a source |
| 41 | range covering the whole parameter, so that an error message like this: |
| 42 | |
| 43 | overloaded-operator-decl.cpp:37:23: error: parameter of overloaded post-increment operator must have type 'int' (not 'float') |
| 44 | X operator++(X&, const float& f); |
| 45 | ^ |
| 46 | can be turned into something like this: |
| 47 | |
| 48 | overloaded-operator-decl.cpp:37:23: error: parameter of overloaded post-increment operator must have type 'int' (not 'float') |
| 49 | X operator++(X&, const float& f); |
| 50 | ^ ~~~~~~~~~~~~~~ |
| 51 | |
Douglas Gregor | 20bcd55 | 2009-02-04 13:07:56 +0000 | [diff] [blame] | 52 | //===---------------------------------------------------------------------===// |
| 53 | |
| 54 | For terminal output, we should consider limiting the amount of |
| 55 | diagnostic text we print once the first error has been |
| 56 | encountered. For example, once we have produced an error diagnostic, |
| 57 | we should only continue producing diagnostics until we have produced a |
| 58 | page full of results (say, 50 lines of text). Beyond that, (1) the |
| 59 | remaining errors are likely to be less interesting, and (2) the poor |
| 60 | user has to scroll his terminal to find out where things went wrong. |
Douglas Gregor | a26877f | 2008-11-17 17:14:10 +0000 | [diff] [blame] | 61 | |
Douglas Gregor | a3a8351 | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 62 | //===---------------------------------------------------------------------===// |
| 63 | More ideas for code modification hints: |
| 64 | - If no member of a given name is found in a class/struct, search through the names of entities that do exist in the class and suggest the closest candidate. e.g., if I write "DS.setTypeSpecType", it would suggest "DS.SetTypeSpecType" (edit distance = 1). |
| 65 | - If a class member is defined out-of-line but isn't in the class declaration (and there are no close matches!), provide the option to add an in-class declaration. |
| 66 | - Fix-it hints for the inclusion of headers when needed for particular features (e.g., <typeinfo> for typeid) |
Daniel Dunbar | 9af8695 | 2009-11-10 16:23:44 +0000 | [diff] [blame] | 67 | |
| 68 | //===---------------------------------------------------------------------===// |
| 69 | |
| 70 | Options to support: |
Daniel Dunbar | 9af8695 | 2009-11-10 16:23:44 +0000 | [diff] [blame] | 71 | -ftabstop=width |
| 72 | -fpreprocessed mode. |
| 73 | -nostdinc++ |
| 74 | -imultilib |
Marshall Clow | 72a2eb6 | 2011-01-04 19:19:20 +0000 | [diff] [blame^] | 75 | |