Change the Lexer ctor used to lex _Pragma directives into a static factory
method. This lets us clean up the interface and make it more obvious that
this method is *really really* _Pragma specific.
Note that _Pragma handling uglifies the Lexer in the critical path. It would
be very interesting to consider making _Pragma remapping be a new special
lexer class of its own.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62425 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index 8603016..3f5a5a9 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -157,19 +157,12 @@
// Plop the string (including the newline and trailing null) into a buffer
// where we can lex it.
SourceLocation TokLoc = CreateString(&StrVal[0], StrVal.size(), StrLoc);
- const char *StrData = SourceMgr.getCharacterData(TokLoc);
// Make and enter a lexer object so that we lex and expand the tokens just
// like any others.
- Lexer *TL = new Lexer(TokLoc, *this,
- StrData, StrData+StrVal.size()-1 /* no null */);
-
- // Ensure that the lexer thinks it is inside a directive, so that end \n will
- // return an EOM token.
- TL->ParsingPreprocessorDirective = true;
-
- // This lexer really is for _Pragma.
- TL->Is_PragmaLexer = true;
+ Lexer *TL = Lexer::Create_PragmaLexer(TokLoc,
+ // do not include the null in the count.
+ StrVal.size()-1, *this);
EnterSourceFileWithLexer(TL, 0);