Shih-wei Liao | f8fd82b | 2010-02-10 11:10:31 -0800 | [diff] [blame^] | 1 | //===---------------------------------------------------------------------===// |
| 2 | // Minor random things that can be improved |
| 3 | //===---------------------------------------------------------------------===// |
| 4 | |
| 5 | |
| 6 | Warn about "X && 0x1000" saying that the user may mean "X & 0x1000". |
| 7 | We should do this for any immediate except zero, so long as it doesn't come |
| 8 | from a macro expansion. Likewise for ||. |
| 9 | |
| 10 | //===---------------------------------------------------------------------===// |
| 11 | |
| 12 | Lexer-related diagnostics should point to the problematic character, not the |
| 13 | start of the token. For example: |
| 14 | |
| 15 | int y = 0000\ |
| 16 | 00080; |
| 17 | |
| 18 | diag.c:4:9: error: invalid digit '8' in octal constant |
| 19 | int y = 0000\ |
| 20 | ^ |
| 21 | |
| 22 | should be: |
| 23 | |
| 24 | diag.c:4:9: error: invalid digit '8' in octal constant |
| 25 | 00080; |
| 26 | ^ |
| 27 | |
| 28 | This specific diagnostic is implemented, but others should be updated. |
| 29 | |
| 30 | //===---------------------------------------------------------------------===// |
| 31 | |
| 32 | C++ (checker): For iterators, warn of the use of "iterator++" instead |
| 33 | of "++iterator" when when the value returned by operator++(int) is |
| 34 | ignored. |
| 35 | |
| 36 | //===---------------------------------------------------------------------===// |
| 37 | |
| 38 | We want to keep more source range information in Declarator to help |
| 39 | produce better diagnostics. Declarator::getSourceRange() should be |
| 40 | implemented to give a range for the whole declarator with all of its |
| 41 | specifiers, and DeclaratorChunk::ParamInfo should also have a source |
| 42 | range covering the whole parameter, so that an error message like this: |
| 43 | |
| 44 | overloaded-operator-decl.cpp:37:23: error: parameter of overloaded post-increment operator must have type 'int' (not 'float') |
| 45 | X operator++(X&, const float& f); |
| 46 | ^ |
| 47 | can be turned into something like this: |
| 48 | |
| 49 | overloaded-operator-decl.cpp:37:23: error: parameter of overloaded post-increment operator must have type 'int' (not 'float') |
| 50 | X operator++(X&, const float& f); |
| 51 | ^ ~~~~~~~~~~~~~~ |
| 52 | |
| 53 | //===---------------------------------------------------------------------===// |
| 54 | |
| 55 | For terminal output, we should consider limiting the amount of |
| 56 | diagnostic text we print once the first error has been |
| 57 | encountered. For example, once we have produced an error diagnostic, |
| 58 | we should only continue producing diagnostics until we have produced a |
| 59 | page full of results (say, 50 lines of text). Beyond that, (1) the |
| 60 | remaining errors are likely to be less interesting, and (2) the poor |
| 61 | user has to scroll his terminal to find out where things went wrong. |
| 62 | |
| 63 | //===---------------------------------------------------------------------===// |
| 64 | More ideas for code modification hints: |
| 65 | - 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). |
| 66 | - 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. |
| 67 | - Fix-it hints for the inclusion of headers when needed for particular features (e.g., <typeinfo> for typeid) |
| 68 | |
| 69 | //===---------------------------------------------------------------------===// |
| 70 | |
| 71 | Options to support: |
| 72 | -ftabstop=width |
| 73 | -fpreprocessed mode. |
| 74 | -nostdinc++ |
| 75 | -imultilib |