diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-10-30 00:23:06 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-10-30 00:23:06 +0000 |
commit | 5ef9e33137443ef85eaba34e4293c3b95db8c40c (patch) | |
tree | 6dbf68a77d84e90e9e40dcdfee9229eec8d3fbb8 /clang/lib/Lex | |
parent | 6a16b2f10ca4aa2afa400efd0dbac2dba9534bd3 (diff) | |
download | bcm5719-llvm-5ef9e33137443ef85eaba34e4293c3b95db8c40c.tar.gz bcm5719-llvm-5ef9e33137443ef85eaba34e4293c3b95db8c40c.zip |
Make the deserialization of macro definitions lazy, so that we can
load identifiers without loading their corresponding macro
definitions. This is likely to improve PCH performance slightly, and
reduces deserialization stack depth considerably when using
preprocessor metaprogramming.
llvm-svn: 117750
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 68fc56f7b78..a9f4cacf6ce 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -20,12 +20,27 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/CodeCompletionHandler.h" +#include "clang/Lex/ExternalPreprocessorSource.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/raw_ostream.h" #include <cstdio> #include <ctime> using namespace clang; +MacroInfo *Preprocessor::getInfoForMacro(IdentifierInfo *II) const { + assert(II->hasMacroDefinition() && "Identifier is not a macro!"); + + llvm::DenseMap<IdentifierInfo*, MacroInfo*>::const_iterator Pos + = Macros.find(II); + if (Pos == Macros.end()) { + // Load this macro from the external source. + getExternalSource()->LoadMacroDefinition(II); + Pos = Macros.find(II); + } + assert(Pos != Macros.end() && "Identifier macro info is missing!"); + return Pos->second; +} + /// setMacroInfo - Specify a macro for this identifier. /// void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI) { |