1 //===- PreprocessorLexer.cpp - C Language Family Lexer --------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the PreprocessorLexer and Token interfaces.
11 //===----------------------------------------------------------------------===//
13 #include "clang/Lex/PreprocessorLexer.h"
14 #include "clang/Basic/SourceManager.h"
15 #include "clang/Lex/Preprocessor.h"
16 #include "clang/Lex/Token.h"
19 using namespace clang
;
21 void PreprocessorLexer::anchor() {}
23 PreprocessorLexer::PreprocessorLexer(Preprocessor
*pp
, FileID fid
)
26 InitialNumSLocEntries
= pp
->getSourceManager().local_sloc_entry_size();
29 /// After the preprocessor has parsed a \#include, lex and
30 /// (potentially) macro expand the filename.
31 void PreprocessorLexer::LexIncludeFilename(Token
&FilenameTok
) {
32 assert(ParsingFilename
== false && "reentered LexIncludeFilename");
34 // We are now parsing a filename!
35 ParsingFilename
= true;
39 IndirectLex(FilenameTok
);
43 // We should have obtained the filename now.
44 ParsingFilename
= false;
47 /// getFileEntry - Return the FileEntry corresponding to this FileID. Like
48 /// getFileID(), this only works for lexers with attached preprocessors.
49 OptionalFileEntryRef
PreprocessorLexer::getFileEntry() const {
50 return PP
->getSourceManager().getFileEntryRefForID(getFileID());