Skip to content

Commit

Permalink
Avoid implicit fallthrough in some Parser switches
Browse files Browse the repository at this point in the history
Summary:
There were a couple parser switch statements that we didn't really need
implicit fallthrough in, and in the TS case it was suboptimal code.

These code paths aren't really exercised right now.

Reviewed By: neildhar

Differential Revision: D58824704

fbshipit-source-id: ded892c0f1ad01e6ce6348c1d5ee303c7a963e68
  • Loading branch information
avp authored and facebook-github-bot committed Jun 20, 2024
1 parent 372c2cc commit 7d95429
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/Parser/JSParserImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3943,6 +3943,7 @@ Optional<ESTree::Node *> JSParserImpl::parseUnaryExpression() {
getPrevTokenEndLoc(),
new (context_) ESTree::TSTypeAssertionNode(*optType, *optExpr));
}
break;
#endif

case TokenKind::identifier:
Expand All @@ -3957,12 +3958,13 @@ Optional<ESTree::Node *> JSParserImpl::parseUnaryExpression() {
getPrevTokenEndLoc(),
new (context_) ESTree::AwaitExpressionNode(optExpr.getValue()));
}
// Fall-through to default for all other identifiers.
LLVM_FALLTHROUGH;
// Default for all other identifiers.
break;

default:
return parsePostfixExpression();
break;
}
return parsePostfixExpression();
}

namespace {
Expand Down
3 changes: 2 additions & 1 deletion lib/Parser/rust-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ enum class DiagKind : uint32_t {
DiagKind toDiagKind(llvh::SourceMgr::DiagKind k) {
switch (k) {
default:
assert(false);
assert(false && "Invalid DiagKind");
[[fallthrough]];
case llvh::SourceMgr::DK_Error:
return DiagKind::Error;
case llvh::SourceMgr::DK_Warning:
Expand Down

0 comments on commit 7d95429

Please sign in to comment.