Skip to content

Commit b1d2d7c

Browse files
authored
[Clang][Parse][NFC] Use llvm::function_ref<> instead of std::optional<llvm::function_ref<>> (#142906)
There is no need to distinguish between null `optional` and null `function_ref` in this case.
1 parent bf53a49 commit b1d2d7c

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,8 +2598,7 @@ class Parser : public CodeCompletionHandler {
25982598
void ParseTypeQualifierListOpt(
25992599
DeclSpec &DS, unsigned AttrReqs = AR_AllAttributesParsed,
26002600
bool AtomicOrPtrauthAllowed = true, bool IdentifierRequired = false,
2601-
std::optional<llvm::function_ref<void()>> CodeCompletionHandler =
2602-
std::nullopt);
2601+
llvm::function_ref<void()> CodeCompletionHandler = {});
26032602

26042603
/// ParseDirectDeclarator
26052604
/// \verbatim

clang/lib/Parse/ParseDecl.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6124,8 +6124,7 @@ bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide,
61246124

61256125
void Parser::ParseTypeQualifierListOpt(
61266126
DeclSpec &DS, unsigned AttrReqs, bool AtomicOrPtrauthAllowed,
6127-
bool IdentifierRequired,
6128-
std::optional<llvm::function_ref<void()>> CodeCompletionHandler) {
6127+
bool IdentifierRequired, llvm::function_ref<void()> CodeCompletionHandler) {
61296128
if ((AttrReqs & AR_CXX11AttributesParsed) &&
61306129
isAllowedCXX11AttributeSpecifier()) {
61316130
ParsedAttributes Attrs(AttrFactory);
@@ -6145,7 +6144,7 @@ void Parser::ParseTypeQualifierListOpt(
61456144
case tok::code_completion:
61466145
cutOffParsing();
61476146
if (CodeCompletionHandler)
6148-
(*CodeCompletionHandler)();
6147+
CodeCompletionHandler();
61496148
else
61506149
Actions.CodeCompletion().CodeCompleteTypeQualifiers(DS);
61516150
return;
@@ -7236,9 +7235,9 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
72367235
ParseTypeQualifierListOpt(
72377236
DS, AR_NoAttributesParsed,
72387237
/*AtomicOrPtrauthAllowed=*/false,
7239-
/*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
7238+
/*IdentifierRequired=*/false, [&]() {
72407239
Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D);
7241-
}));
7240+
});
72427241
if (!DS.getSourceRange().getEnd().isInvalid()) {
72437242
EndLoc = DS.getSourceRange().getEnd();
72447243
}

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,9 +2649,9 @@ void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
26492649
// handled by the caller. Diagnose everything else.
26502650
ParseTypeQualifierListOpt(
26512651
DS, AR_NoAttributesParsed, /*AtomicOrPtrauthAllowed=*/false,
2652-
/*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
2652+
/*IdentifierRequired=*/false, [&]() {
26532653
Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2654-
}));
2654+
});
26552655
D.ExtendWithDeclSpec(DS);
26562656

26572657
if (D.isFunctionDeclarator()) {

0 commit comments

Comments
 (0)