Skip to content

Commit 1f8e53e

Browse files
committed
[Macros] Use buffer mangling scheme for freestanding macros
1 parent 3b6a9c7 commit 1f8e53e

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

lib/Sema/TypeCheckMacros.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -650,24 +650,9 @@ bool swift::expandFreestandingDeclarationMacro(
650650
// Figure out a reasonable name for the macro expansion buffer.
651651
std::string bufferName;
652652
{
653-
llvm::raw_string_ostream out(bufferName);
654-
655-
out << "macro:" << macro->getName().getBaseName();
656-
if (auto bufferID = sourceFile->getBufferID()) {
657-
unsigned startLine, startColumn;
658-
std::tie(startLine, startColumn) =
659-
sourceMgr.getLineAndColumnInBuffer(med->getStartLoc(), *bufferID);
660-
661-
SourceLoc endLoc =
662-
Lexer::getLocForEndOfToken(sourceMgr, med->getEndLoc());
663-
unsigned endLine, endColumn;
664-
std::tie(endLine, endColumn) =
665-
sourceMgr.getLineAndColumnInBuffer(endLoc, *bufferID);
666-
667-
out << ":" << sourceMgr.getIdentifierForBuffer(*bufferID) << ":"
668-
<< startLine << ":" << startColumn
669-
<< "-" << endLine << ":" << endColumn;
670-
}
653+
Mangle::ASTMangler mangler;
654+
bufferName = adjustMacroExpansionBufferName(
655+
mangler.mangleMacroExpansion(med));
671656
}
672657

673658
// Dump macro expansions to standard output, if requested.

0 commit comments

Comments
 (0)