[cfe-commits] r59185 - in /cfe/trunk: include/clang/Lex/Lexer.h lib/Lex/PreprocessorLexer.cpp
Ted Kremenek
kremenek at apple.com
Wed Nov 12 14:43:12 PST 2008
Author: kremenek
Date: Wed Nov 12 16:43:05 2008
New Revision: 59185
URL: http://llvm.org/viewvc/llvm-project?rev=59185&view=rev
Log:
Move LexIncludeFilename from Lexer to PreprocessorLexer.
PreprocessorLexer now has a virtual method "IndirectLex" which allows it to call the lex method of its subclasses. This is not for performance intensive operations.
Added:
cfe/trunk/lib/Lex/PreprocessorLexer.cpp
Modified:
cfe/trunk/include/clang/Lex/Lexer.h
Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=59185&r1=59184&r2=59185&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Wed Nov 12 16:43:05 2008
@@ -115,6 +115,10 @@
LexTokenInternal(Result);
}
+ /// IndirectLex - An indirect call to 'Lex' that can be invoked via
+ /// the PreprocessorLexer interface.
+ void IndirectLex(Token &Result) { Lex(Result); }
+
/// LexFromRawLexer - Lex a token from a designated raw lexer (one with no
/// associated preprocessor object. Return true if the 'next character to
/// read' pointer points and the end of the lexer buffer, false otherwise.
@@ -331,11 +335,6 @@
bool SkipBCPLComment (Token &Result, const char *CurPtr);
bool SkipBlockComment (Token &Result, const char *CurPtr);
bool SaveBCPLComment (Token &Result, const char *CurPtr);
-
- /// LexIncludeFilename - After the preprocessor has parsed a #include, lex and
- /// (potentially) macro expand the filename. If the sequence parsed is not
- /// lexically legal, emit a diagnostic and return a result EOM token.
- void LexIncludeFilename(Token &Result);
};
Added: cfe/trunk/lib/Lex/PreprocessorLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PreprocessorLexer.cpp?rev=59185&view=auto
==============================================================================
--- cfe/trunk/lib/Lex/PreprocessorLexer.cpp (added)
+++ cfe/trunk/lib/Lex/PreprocessorLexer.cpp Wed Nov 12 16:43:05 2008
@@ -0,0 +1,40 @@
+//===--- PreprocessorLexer.cpp - C Language Family Lexer ------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the PreprocessorLexer and Token interfaces.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Lex/PreprocessorLexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+using namespace clang;
+
+/// LexIncludeFilename - After the preprocessor has parsed a #include, lex and
+/// (potentially) macro expand the filename.
+void PreprocessorLexer::LexIncludeFilename(Token &FilenameTok) {
+ assert(ParsingPreprocessorDirective &&
+ ParsingFilename == false &&
+ "Must be in a preprocessing directive!");
+
+ // We are now parsing a filename!
+ ParsingFilename = true;
+
+ // Lex the filename.
+ IndirectLex(FilenameTok);
+
+ // We should have obtained the filename now.
+ ParsingFilename = false;
+
+ // No filename?
+ if (FilenameTok.is(tok::eom))
+ Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+}
More information about the cfe-commits
mailing list