================
@@ -236,26 +236,29 @@ void Lexer::resetExtendedTokenMode() {
SetCommentRetentionState(PP->getCommentRetentionState());
}
-/// Create_PragmaLexer: Lexer constructor - Create a new lexer object for
-/// _Pragma expansion. This has a variety of magic semantics that this method
-/// sets up.
+/// CreateScratchLexer: Lexer constructor - Create a new lexer object that
+/// places 'Code' in the scratch buffer and lexes from it.
///
-/// On entrance to this routine, TokStartLoc is a macro location which has a
-/// spelling loc that indicates the bytes to be lexed for the token and an
-/// expansion location that indicates where all lexed tokens should be
-/// "expanded from".
+/// This is used to implement _Pragma as well as string injection.
///
/// TODO: It would really be nice to make _Pragma just be a wrapper around a
/// normal lexer that remaps tokens as they fly by. This would require making
/// Preprocessor::Lex virtual. Given that, we could just dump in a magic lexer
/// interface that could handle this stuff. This would pull GetMappedTokenLoc
/// out of the critical path of the lexer!
///
-std::unique_ptr<Lexer> Lexer::Create_PragmaLexer(
- SourceLocation SpellingLoc, SourceLocation ExpansionLocStart,
- SourceLocation ExpansionLocEnd, unsigned TokLen, Preprocessor &PP) {
+std::unique_ptr<Lexer>
+Lexer::CreateScratchLexer(StringRef Code, SourceLocation ExpansionLocStart,
+ SourceLocation ExpansionLocEnd, Preprocessor &PP) {
SourceManager &SM = PP.getSourceManager();
+ // Plop the string into a buffer where we can lex it.
----------------
Sirraide wrote:
Correction: `Preprocessor::CreateString` has a comment with the same wording,
and that’s from _two_ decades ago actually
https://github.com/llvm/llvm-project/pull/208877
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits