[PATCH] Replaced bool parameters in SkipUntil function with single bit-based parameter.
Richard Smith
richard at metafoo.co.uk
Wed Nov 6 21:01:05 PST 2013
================
Comment at: lib/Parse/ParseCXXInlineMethods.cpp:76
@@ -75,3 +75,3 @@
if (!FnD) {
- SkipUntil(tok::semi);
+ SkipUntil(tok::semi, StopAtSemi);
return 0;
----------------
Remove the `StopAtSemi` here, and on all other calls that are passed `tok::semi`: it's meaningless in that case.
================
Comment at: lib/Parse/ParseDecl.cpp:1628
@@ -1622,3 +1627,3 @@
Diag(Tok, diag::err_function_definition_not_allowed);
- SkipUntil(tok::r_brace, true, true);
+ SkipUntil(tok::r_brace, StopAtSemi | DontConsume);
}
----------------
Hm, this looks bogus (both before and after this change). This should instead be:
ConsumeBrace();
SkipUntil(tok::r_brace);
================
Comment at: lib/Parse/ParseDecl.cpp:2307
@@ -2301,3 +2306,3 @@
if (ArgExpr.isInvalid()) {
- SkipUntil(tok::r_paren);
+ SkipUntil(tok::r_paren, StopAtSemi);
return;
----------------
Should be `T.skipToEnd();`
================
Comment at: include/clang/Parse/Parser.h:755-762
@@ -746,12 +754,10 @@
/// returns false.
- bool SkipUntil(tok::TokenKind T, bool StopAtSemi = true,
- bool DontConsume = false, bool StopAtCodeCompletion = false) {
- return SkipUntil(llvm::makeArrayRef(T), StopAtSemi, DontConsume,
- StopAtCodeCompletion);
+ bool SkipUntil(tok::TokenKind T, unsigned Flags = 0) {
+ return SkipUntil(llvm::makeArrayRef(T), Flags);
}
- bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, bool StopAtSemi = true,
- bool DontConsume = false, bool StopAtCodeCompletion = false) {
+ bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2,
+ unsigned Flags = 0) {
tok::TokenKind TokArray[] = {T1, T2};
- return SkipUntil(TokArray, StopAtSemi, DontConsume,StopAtCodeCompletion);
+ return SkipUntil(TokArray, Flags);
}
bool SkipUntil(tok::TokenKind T1, tok::TokenKind T2, tok::TokenKind T3,
----------------
This is a somewhat scary overload set.
unsigned Tok = thing ? tok::foo : tok::bar;
SkipUntil(tok::baz, Tok);
... will call the first overload. Oops.
Please add
LLVM_CONSTEXPR SkipUntilFlags operator|(SkipUntilFlags L, SkipUntilFlags R) {
return SkipUntilFlags(int(L) | int(R));
}
and make these functions take `SkipUntilFlags` not `unsigned`.
http://llvm-reviews.chandlerc.com/D2108
More information about the cfe-commits
mailing list