Path: blob/main/contrib/llvm-project/clang/lib/Lex/PreprocessorLexer.cpp
35233 views
//===- PreprocessorLexer.cpp - C Language Family Lexer --------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements the PreprocessorLexer and Token interfaces.9//10//===----------------------------------------------------------------------===//1112#include "clang/Lex/PreprocessorLexer.h"13#include "clang/Basic/SourceManager.h"14#include "clang/Lex/LexDiagnostic.h"15#include "clang/Lex/Preprocessor.h"16#include "clang/Lex/Token.h"17#include <cassert>1819using namespace clang;2021void PreprocessorLexer::anchor() {}2223PreprocessorLexer::PreprocessorLexer(Preprocessor *pp, FileID fid)24: PP(pp), FID(fid) {25if (pp)26InitialNumSLocEntries = pp->getSourceManager().local_sloc_entry_size();27}2829/// After the preprocessor has parsed a \#include, lex and30/// (potentially) macro expand the filename.31void PreprocessorLexer::LexIncludeFilename(Token &FilenameTok) {32assert(ParsingFilename == false && "reentered LexIncludeFilename");3334// We are now parsing a filename!35ParsingFilename = true;3637// Lex the filename.38if (LexingRawMode)39IndirectLex(FilenameTok);40else41PP->Lex(FilenameTok);4243// We should have obtained the filename now.44ParsingFilename = false;45}4647/// getFileEntry - Return the FileEntry corresponding to this FileID. Like48/// getFileID(), this only works for lexers with attached preprocessors.49OptionalFileEntryRef PreprocessorLexer::getFileEntry() const {50return PP->getSourceManager().getFileEntryRefForID(getFileID());51}525354