[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

@@ -8622,11 +8622,9 @@ bool RefactoringActionAddAsyncWrapper::performChange() {
/// expression.
static Optional<unsigned> getMacroExpansionBuffer(
SourceManager &sourceMgr, MacroExpansionExpr *expansion) {
if (auto rewritten = expansion->getRewritten()) {
return sourceMgr.findBufferContainingLoc(rewritten->getStartLoc());
}
return None;
return evaluateOrDefault(
expansion->getDeclContext()->getASTContext().evaluator,
ExpandMacroExpansionExprRequest{expansion}, {});
}
/// Retrieve the macro expansion buffer for the given macro expansion