clang 20.0.0git
PreprocessorLexer.cpp
Go to the documentation of this file.
1//===- PreprocessorLexer.cpp - C Language Family Lexer --------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the PreprocessorLexer and Token interfaces.
10//
11//===----------------------------------------------------------------------===//
12
17#include "clang/Lex/Token.h"
18#include <cassert>
19
20using namespace clang;
21
22void PreprocessorLexer::anchor() {}
23
25 : PP(pp), FID(fid) {
26 if (pp)
28}
29
30/// After the preprocessor has parsed a \#include, lex and
31/// (potentially) macro expand the filename.
33 assert(ParsingFilename == false && "reentered LexIncludeFilename");
34
35 // We are now parsing a filename!
36 ParsingFilename = true;
37
38 // Lex the filename.
39 if (LexingRawMode)
40 IndirectLex(FilenameTok);
41 else
42 PP->Lex(FilenameTok);
43
44 // We should have obtained the filename now.
45 ParsingFilename = false;
46}
47
48/// getFileEntry - Return the FileEntry corresponding to this FileID. Like
49/// getFileID(), this only works for lexers with attached preprocessors.
52}
Defines the PreprocessorLexer interface.
Defines the clang::Preprocessor interface.
Defines the SourceManager interface.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
virtual void IndirectLex(Token &Result)=0
bool LexingRawMode
True if in raw mode.
bool ParsingFilename
True after #include; turns <xx> or "xxx" into a tok::header_name token.
OptionalFileEntryRef getFileEntry() const
getFileEntry - Return the FileEntry corresponding to this FileID.
void LexIncludeFilename(Token &FilenameTok)
Lex a token, producing a header-name token if possible.
unsigned InitialNumSLocEntries
Number of SLocEntries before lexing the file.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:137
void Lex(Token &Result)
Lex the next token for this preprocessor.
SourceManager & getSourceManager() const
OptionalFileEntryRef getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
unsigned local_sloc_entry_size() const
Get the number of local SLocEntries we have.
Token - This structure provides full information about a lexed token.
Definition: Token.h:36
The JSON file list parser is used to communicate input to InstallAPI.