Shih-wei Liao | f8fd82b | 2010-02-10 11:10:31 -0800 | [diff] [blame^] | 1 | //===--- PreprocessorLexer.cpp - C Language Family Lexer ------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the PreprocessorLexer and Token interfaces. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 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; |
| 19 | |
| 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!"); |
| 26 | |
| 27 | // We are now parsing a filename! |
| 28 | ParsingFilename = true; |
| 29 | |
| 30 | // Lex the filename. |
| 31 | IndirectLex(FilenameTok); |
| 32 | |
| 33 | // We should have obtained the filename now. |
| 34 | ParsingFilename = false; |
| 35 | |
| 36 | // No filename? |
| 37 | if (FilenameTok.is(tok::eom)) |
| 38 | PP->Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); |
| 39 | } |
| 40 | |
| 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()); |
| 45 | } |