1 //===--- PreprocessorLexer.cpp - C Language Family Lexer ------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the PreprocessorLexer and Token interfaces.
12 //===----------------------------------------------------------------------===//
14 #include "clang/Lex/PreprocessorLexer.h"
15 #include "clang/Lex/Preprocessor.h"
16 #include "clang/Lex/LexDiagnostic.h"
17 #include "clang/Basic/SourceManager.h"
18 using namespace clang;
20 /// LexIncludeFilename - After the preprocessor has parsed a #include, lex and
21 /// (potentially) macro expand the filename.
22 void PreprocessorLexer::LexIncludeFilename(Token &FilenameTok) {
23 assert(ParsingPreprocessorDirective &&
24 ParsingFilename == false &&
25 "Must be in a preprocessing directive!");
27 // We are now parsing a filename!
28 ParsingFilename = true;
31 IndirectLex(FilenameTok);
33 // We should have obtained the filename now.
34 ParsingFilename = false;
37 if (FilenameTok.is(tok::eod))
38 PP->Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
41 /// getFileEntry - Return the FileEntry corresponding to this FileID. Like
42 /// getFileID(), this only works for lexers with attached preprocessors.
43 const FileEntry *PreprocessorLexer::getFileEntry() const {
44 return PP->getSourceManager().getFileEntryForID(getFileID());