This patch improves the 'expected identifier' errors that are presented when a C++ keyword is used as an identifier in Objective-C++ by mentioning that this is a C++ keyword in the diagnostic message. It also improves the error recovery: the parser will treat the C++ keywords as identifiers to prevent unrelated parsing errors.
Details
- Reviewers
bruno manmanren - Commits
- rGf127821140b1: [Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are used as…
rC299950: [Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are used
rL299950: [Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are used
Diff Detail
- Repository
- rL LLVM
Event Timeline
Cheers,
Manman
include/clang/Basic/DiagnosticParseKinds.td | ||
---|---|---|
442 ↗ | (On Diff #77482) | This name is a little misleading. It sounds like we are expecting a keyword :] |
include/clang/Parse/Parser.h | ||
798 ↗ | (On Diff #77482) | --> if the next token is a C++ (if to is) |
801 ↗ | (On Diff #77482) | Same here. The function name is kind of misleading. |
lib/Parse/ParseDecl.cpp | ||
5405 ↗ | (On Diff #77482) | Does C++ have the same issue? Or is this only needed for Objective-C++? |
lib/Parse/ParseObjc.cpp | ||
153 ↗ | (On Diff #77482) | Are we doing this for all occurrences of "isNot(token::identifier)"? |
Addressed review comments by renaming the diagnostic and simplifying the name and the use of the expectIdentifier method.
lib/Parse/ParseDecl.cpp | ||
---|---|---|
5405 ↗ | (On Diff #77482) | I suppose it kinda does have it as well, but Objective-C++ has worse error recovery for Objective-C declarations in this case, so it's more important for it. I wouldn't mind adding a similar diagnostic for C++ though, but I think that should be done in a separate patch. |