PreprocessorLexer.cpp revision 221345
1238730Sdelphij//===--- PreprocessorLexer.cpp - C Language Family Lexer ------------------===// 2293190Sdelphij// 3238730Sdelphij// The LLVM Compiler Infrastructure 4238730Sdelphij// 5238730Sdelphij// This file is distributed under the University of Illinois Open Source 6238730Sdelphij// License. See LICENSE.TXT for details. 7238730Sdelphij// 8238730Sdelphij//===----------------------------------------------------------------------===// 9195902Sdelphij// 10237613Sdelphij// This file implements the PreprocessorLexer and Token interfaces. 11237613Sdelphij// 12237613Sdelphij//===----------------------------------------------------------------------===// 13237613Sdelphij 14237613Sdelphij#include "clang/Lex/PreprocessorLexer.h" 15237613Sdelphij#include "clang/Lex/Preprocessor.h" 16237613Sdelphij#include "clang/Lex/LexDiagnostic.h" 17195902Sdelphij#include "clang/Basic/SourceManager.h" 18195902Sdelphijusing namespace clang; 19195902Sdelphij 20195941Sdelphij/// LexIncludeFilename - After the preprocessor has parsed a #include, lex and 21195941Sdelphij/// (potentially) macro expand the filename. 22195902Sdelphijvoid PreprocessorLexer::LexIncludeFilename(Token &FilenameTok) { 23195902Sdelphij assert(ParsingPreprocessorDirective && 24195902Sdelphij ParsingFilename == false && 25195902Sdelphij "Must be in a preprocessing directive!"); 26195902Sdelphij 27195902Sdelphij // We are now parsing a filename! 28195902Sdelphij ParsingFilename = true; 29195902Sdelphij 30195902Sdelphij // Lex the filename. 31195902Sdelphij IndirectLex(FilenameTok); 32195902Sdelphij 33195902Sdelphij // We should have obtained the filename now. 34195902Sdelphij ParsingFilename = false; 35195902Sdelphij 36195902Sdelphij // No filename? 37195902Sdelphij if (FilenameTok.is(tok::eod)) 38195902Sdelphij PP->Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); 39195902Sdelphij} 40195902Sdelphij 41195902Sdelphij/// getFileEntry - Return the FileEntry corresponding to this FileID. Like 42195902Sdelphij/// getFileID(), this only works for lexers with attached preprocessors. 43195902Sdelphijconst FileEntry *PreprocessorLexer::getFileEntry() const { 44195902Sdelphij return PP->getSourceManager().getFileEntryForID(getFileID()); 45195902Sdelphij} 46195902Sdelphij