[cfe-commits] r59574 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Lex/PPDirectives.cpp lib/Lex/PPLexerChange.cpp
Ted Kremenek
kremenek at apple.com
Tue Nov 18 16:46:18 PST 2008
Author: kremenek
Date: Tue Nov 18 18:46:18 2008
New Revision: 59574
URL: http://llvm.org/viewvc/llvm-project?rev=59574&view=rev
Log:
- Move static function IsNonPragmaNonMacroLexer into Preprocessor.h.
- Add variants of IsNonPragmaNonMacroLexer to accept an IncludeMacroStack entry
(simplifies some uses).
- Use IsNonPragmaNonMacroLexer in Preprocessor::LookupFile.
Performance testing of -Eonly on Cocoa.h shows no performance regression because
of this patch.
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/PPLexerChange.cpp
Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=59574&r1=59573&r2=59574&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Tue Nov 18 18:46:18 2008
@@ -598,6 +598,23 @@
bool isAngled, const DirectoryLookup *FromDir,
const DirectoryLookup *&CurDir);
+
+ static bool IsNonPragmaNonMacroLexer(const Lexer* L,
+ const PreprocessorLexer* P) {
+ if (L)
+ return !L->isPragmaLexer();
+ else
+ return P != 0;
+ }
+
+ static bool IsNonPragmaNonMacroLexer(const IncludeStackInfo& I) {
+ return IsNonPragmaNonMacroLexer(I.TheLexer, I.ThePPLexer);
+ }
+
+ bool IsNonPragmaNonMacroLexer() const {
+ return IsNonPragmaNonMacroLexer(CurLexer.get(), CurPPLexer);
+ }
+
//===--------------------------------------------------------------------===//
// Caching stuff.
void CachingLex(Token &Result);
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=59574&r1=59573&r2=59574&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Nov 18 18:46:18 2008
@@ -317,7 +317,7 @@
// Otherwise, see if this is a subframework header. If so, this is relative
// to one of the headers on the #include stack. Walk the list of the current
// headers on the #include stack and pass them to HeaderInfo.
- if (CurLexer && !CurLexer->Is_PragmaLexer) {
+ if (IsNonPragmaNonMacroLexer()) {
if ((CurFileEnt = SourceMgr.getFileEntryForLoc(CurLexer->getFileLoc())))
if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart, FilenameEnd,
CurFileEnt)))
@@ -326,7 +326,7 @@
for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
IncludeStackInfo &ISEntry = IncludeMacroStack[e-i-1];
- if (ISEntry.TheLexer && !ISEntry.TheLexer->Is_PragmaLexer) {
+ if (IsNonPragmaNonMacroLexer(ISEntry)) {
if ((CurFileEnt =
SourceMgr.getFileEntryForLoc(ISEntry.TheLexer->getFileLoc())))
if ((FE = HeaderInfo.LookupSubframeworkHeader(FilenameStart,
Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=59574&r1=59573&r2=59574&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Tue Nov 18 18:46:18 2008
@@ -25,28 +25,19 @@
// Miscellaneous Methods.
//===----------------------------------------------------------------------===//
-static inline bool IsNonPragmaNonMacroLexer(const Lexer* L,
- const PreprocessorLexer* P) {
- if (L)
- return !L->isPragmaLexer();
- else
- return P != 0;
-}
-
/// isInPrimaryFile - Return true if we're in the top-level file, not in a
/// #include. This looks through macro expansions and active _Pragma lexers.
bool Preprocessor::isInPrimaryFile() const {
- if (IsNonPragmaNonMacroLexer(CurLexer.get(), CurPPLexer))
+ if (IsNonPragmaNonMacroLexer())
return IncludeMacroStack.empty();
// If there are any stacked lexers, we're in a #include.
- assert(IsNonPragmaNonMacroLexer(IncludeMacroStack[0].TheLexer,
- IncludeMacroStack[0].ThePPLexer) &&
+ assert(IsNonPragmaNonMacroLexer(IncludeMacroStack[0]) &&
"Top level include stack isn't our primary lexer?");
for (unsigned i = 1, e = IncludeMacroStack.size(); i != e; ++i)
- if (IsNonPragmaNonMacroLexer(IncludeMacroStack[i].TheLexer,
- IncludeMacroStack[i].ThePPLexer))
+ if (IsNonPragmaNonMacroLexer(IncludeMacroStack[i]))
return false;
+
return true;
}
@@ -91,7 +82,7 @@
const DirectoryLookup *CurDir) {
// Add the current lexer to the include stack.
- if (CurLexer || CurTokenLexer)
+ if (CurPPLexer || CurTokenLexer)
PushIncludeMacroStack();
CurLexer.reset(TheLexer);
More information about the cfe-commits
mailing list