[Macros] Requestify MacroExpansionExpr expansion

The request returns the expanded buffer ID even if it failed to
typecheck the expanded buffer.
This makes refactoring 'Expand Macro' work regardless of the
typechecking results.

rdar://108530760
This commit is contained in:
Rintaro Ishizaki
2023-04-26 16:43:27 -07:00
parent 2c08dc219a
commit 35db928e89
8 changed files with 126 additions and 61 deletions

View File

@@ -3930,6 +3930,26 @@ public:
void noteCycleStep(DiagnosticEngine &diags) const;
};
/// Expand a 'MacroExpansionExpr',
class ExpandMacroExpansionExprRequest
: public SimpleRequest<ExpandMacroExpansionExprRequest,
Optional<unsigned>(MacroExpansionExpr *),
RequestFlags::Cached> {
public:
using SimpleRequest::SimpleRequest;
private:
friend SimpleRequest;
Optional<unsigned>
evaluate(Evaluator &evaluator, MacroExpansionExpr *mee) const;
public:
bool isCached() const { return true; }
void diagnoseCycle(DiagnosticEngine &diags) const;
void noteCycleStep(DiagnosticEngine &diags) const;
};
/// Expand all accessor macros attached to the given declaration.
///
/// Produces the set of macro expansion buffer IDs.

View File

@@ -439,6 +439,9 @@ SWIFT_REQUEST(TypeChecker, ExternalMacroDefinitionRequest,
SWIFT_REQUEST(TypeChecker, ExpandMacroExpansionDeclRequest,
ArrayRef<Decl *>(MacroExpansionDecl *),
Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, ExpandMacroExpansionExprRequest,
ArrayRef<Decl *>(MacroExpansionExpr *),
Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, ExpandMemberAttributeMacros,
ArrayRef<unsigned>(Decl *),
Cached, NoLocationInfo)