mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #36165 from ahoppen/pr/dont-ref-count-rawsyntax
[libSyntax] Don't reference count RawSyntax
This commit is contained in:
@@ -286,20 +286,19 @@ struct ByteBasedSourceRangeSet {
|
||||
|
||||
int getTokensFromFile(
|
||||
unsigned BufferID, LangOptions &LangOpts, SourceManager &SourceMgr,
|
||||
swift::DiagnosticEngine &Diags,
|
||||
std::vector<std::pair<RC<syntax::RawSyntax>,
|
||||
const RC<SyntaxArena> &Arena, swift::DiagnosticEngine &Diags,
|
||||
std::vector<std::pair<const syntax::RawSyntax *,
|
||||
syntax::AbsoluteOffsetPosition>> &Tokens) {
|
||||
Tokens = tokenizeWithTrivia(LangOpts, SourceMgr, BufferID,
|
||||
/*Offset=*/0, /*EndOffset=*/0,
|
||||
&Diags);
|
||||
Tokens = tokenizeWithTrivia(LangOpts, SourceMgr, BufferID, Arena,
|
||||
/*Offset=*/0, /*EndOffset=*/0, &Diags);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int getTokensFromFile(
|
||||
const StringRef InputFilename, LangOptions &LangOpts,
|
||||
SourceManager &SourceMgr, DiagnosticEngine &Diags,
|
||||
unsigned int &OutBufferID,
|
||||
std::vector<std::pair<RC<syntax::RawSyntax>,
|
||||
SourceManager &SourceMgr, const RC<SyntaxArena> &Arena,
|
||||
DiagnosticEngine &Diags, unsigned int &OutBufferID,
|
||||
std::vector<std::pair<const syntax::RawSyntax *,
|
||||
syntax::AbsoluteOffsetPosition>> &Tokens) {
|
||||
auto Buffer = llvm::MemoryBuffer::getFile(InputFilename);
|
||||
if (!Buffer) {
|
||||
@@ -309,7 +308,8 @@ int getTokensFromFile(
|
||||
}
|
||||
|
||||
OutBufferID = SourceMgr.addNewSourceBuffer(std::move(Buffer.get()));
|
||||
return getTokensFromFile(OutBufferID, LangOpts, SourceMgr, Diags, Tokens);
|
||||
return getTokensFromFile(OutBufferID, LangOpts, SourceMgr, Arena, Diags,
|
||||
Tokens);
|
||||
}
|
||||
|
||||
void anchorForGetMainExecutable() {}
|
||||
@@ -665,10 +665,12 @@ int doFullLexRoundTrip(const StringRef InputFilename) {
|
||||
Diags.addConsumer(DiagPrinter);
|
||||
|
||||
unsigned int BufferID;
|
||||
std::vector<std::pair<RC<syntax::RawSyntax>, syntax::AbsoluteOffsetPosition>>
|
||||
RC<SyntaxArena> Arena = SyntaxArena::make();
|
||||
std::vector<
|
||||
std::pair<const syntax::RawSyntax *, syntax::AbsoluteOffsetPosition>>
|
||||
Tokens;
|
||||
if (getTokensFromFile(InputFilename, LangOpts, SourceMgr, Diags, BufferID,
|
||||
Tokens) == EXIT_FAILURE) {
|
||||
if (getTokensFromFile(InputFilename, LangOpts, SourceMgr, Arena, Diags,
|
||||
BufferID, Tokens) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -687,9 +689,11 @@ int doDumpRawTokenSyntax(const StringRef InputFile) {
|
||||
Diags.addConsumer(DiagPrinter);
|
||||
|
||||
unsigned int BufferID;
|
||||
std::vector<std::pair<RC<syntax::RawSyntax>, syntax::AbsoluteOffsetPosition>>
|
||||
RC<SyntaxArena> Arena = SyntaxArena::make();
|
||||
std::vector<
|
||||
std::pair<const syntax::RawSyntax *, syntax::AbsoluteOffsetPosition>>
|
||||
Tokens;
|
||||
if (getTokensFromFile(InputFile, LangOpts, SourceMgr, Diags, BufferID,
|
||||
if (getTokensFromFile(InputFile, LangOpts, SourceMgr, Arena, Diags, BufferID,
|
||||
Tokens) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -729,7 +733,7 @@ int doSerializeRawTree(const char *MainExecutablePath,
|
||||
}
|
||||
|
||||
auto SerializeTree = [&ReusedNodeIds](llvm::raw_ostream &os,
|
||||
RC<RawSyntax> Root,
|
||||
const RawSyntax *Root,
|
||||
SyntaxParsingCache *SyntaxCache) {
|
||||
swift::json::Output::UserInfoMap JsonUserInfo;
|
||||
JsonUserInfo[swift::json::OmitNodesUserInfoKey] = &ReusedNodeIds;
|
||||
|
||||
Reference in New Issue
Block a user