This is an archive of the discontinued LLVM Phabricator instance.

[clang][lex] Add TryGrowLexerBuffer/SourceFileGrower
Needs ReviewPublic

Authored by sunho on Feb 2 2023, 12:44 AM.

Details

Reviewers
v.g.vassilev
Summary

Add TryGrowLexerBuffer to Lexer and SourceFileGrower to Preprocessor that can be used to grow the source code buffer when Lexer reaches the eof of the buffer.

Since clang-repl receive source code incrementally line by line, we need to grow source code buffer. This change adds the interfaces to Lexer/Preprocessor in order to accommodate this need. If SourceFileGrower interface is registered to Preprocessor, it will call TryGrowFile method when Lexer reached eof. Inside this method, the user can grow the file and return true to request Lexer to continue the lexing from the last point.

When Lexer reaches eof it will call TryGrowLexerBuffer callback specified in the constructor to try growing buffer and if it got new buffer, it will continue the lexing from the last point. Preprocessor registers TryGrowLexerBuffer callback in order to implement handling of SourceFileGrower.

Note that practically all the code changes will not affect the AOT clang world since they are all disabled when Preprocessor doesn't have SourceFileGrower instance.

The debian failure is due to some clang-format issue we seems to be unrelatd to this change.

Diff Detail

Event Timeline

sunho created this revision.Feb 2 2023, 12:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 12:44 AM
sunho retitled this revision from asdfasdf to [clang][lex] Add TryExpandBuffer callback.Feb 2 2023, 12:48 AM
sunho edited the summary of this revision. (Show Details)Feb 2 2023, 12:51 AM
sunho retitled this revision from [clang][lex] Add TryExpandBuffer callback to [clang][lex] Add TryGrowLexerBuffer/SourceFileGrower.Feb 6 2023, 3:00 AM
sunho edited the summary of this revision. (Show Details)
sunho edited the summary of this revision. (Show Details)
sunho edited the summary of this revision. (Show Details)
sunho edited the summary of this revision. (Show Details)Feb 6 2023, 3:02 AM
sunho published this revision for review.Feb 6 2023, 3:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2023, 3:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
sunho edited the summary of this revision. (Show Details)Feb 6 2023, 3:27 AM