Ted Kremenek | ab91b70 | 2008-11-12 22:43:05 +0000 | [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/Basic/Diagnostic.h" |
| 17 | #include "clang/Basic/SourceManager.h" |
| 18 | |
| 19 | using namespace clang; |
| 20 | |
Ted Kremenek | 2c71d0f | 2008-11-12 22:48:57 +0000 | [diff] [blame] | 21 | PreprocessorLexer::~PreprocessorLexer() {} |
| 22 | |
Ted Kremenek | d6a2e7d | 2008-11-12 23:13:54 +0000 | [diff] [blame] | 23 | void PreprocessorLexer::Diag(SourceLocation Loc, unsigned DiagID, |
| 24 | const std::string &Msg) const { |
| 25 | if (LexingRawMode && Diagnostic::isBuiltinNoteWarningOrExtension(DiagID)) |
| 26 | return; |
| 27 | PP->Diag(Loc, DiagID, Msg); |
| 28 | } |
| 29 | |
Ted Kremenek | ab91b70 | 2008-11-12 22:43:05 +0000 | [diff] [blame] | 30 | /// LexIncludeFilename - After the preprocessor has parsed a #include, lex and |
| 31 | /// (potentially) macro expand the filename. |
| 32 | void PreprocessorLexer::LexIncludeFilename(Token &FilenameTok) { |
| 33 | assert(ParsingPreprocessorDirective && |
| 34 | ParsingFilename == false && |
| 35 | "Must be in a preprocessing directive!"); |
| 36 | |
| 37 | // We are now parsing a filename! |
| 38 | ParsingFilename = true; |
| 39 | |
| 40 | // Lex the filename. |
| 41 | IndirectLex(FilenameTok); |
| 42 | |
| 43 | // We should have obtained the filename now. |
| 44 | ParsingFilename = false; |
| 45 | |
| 46 | // No filename? |
| 47 | if (FilenameTok.is(tok::eom)) |
| 48 | Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename); |
| 49 | } |