diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-09 22:27:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-09 22:27:44 +0000 |
commit | 2cf2634ffdb4f7c8d46cef3f8e60a55993f1c57a (patch) | |
tree | c9a3838dd8bb8eda8c958dfd28ef7f74c61a66f2 /lib/Sema/SemaLookup.cpp | |
parent | 8d7f5481a0eeb4c0508202a4bd2b754cfa93c4fe (diff) |
Implementation of pre-compiled headers (PCH) based on lazy
de-serialization of abstract syntax trees.
PCH support serializes the contents of the abstract syntax tree (AST)
to a bitstream. When the PCH file is read, declarations are serialized
as-needed. For example, a declaration of a variable "x" will be
deserialized only when its VarDecl can be found by a client, e.g.,
based on name lookup for "x" or traversing the entire contents of the
owner of "x".
This commit provides the framework for serialization and (lazy)
deserialization, along with support for variable and typedef
declarations (along with several kinds of types). More
declarations/types, along with important auxiliary structures (source
manager, preprocessor, etc.), will follow.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 0b11d9cf68..cd82507005 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -878,6 +878,17 @@ Sema::LookupName(Scope *S, DeclarationName Name, LookupNameKind NameKind, // We have a single lookup result. return LookupResult::CreateLookupResult(Context, *I); } + + /// If the context has an external AST source attached, look at + /// translation unit scope. + if (Context.getExternalSource()) { + DeclContext::lookup_iterator I, E; + for (llvm::tie(I, E) + = Context.getTranslationUnitDecl()->lookup(Context, Name); + I != E; ++I) + if (isAcceptableLookupResult(*I, NameKind, IDNS)) + return LookupResult::CreateLookupResult(Context, I, E); + } } else { // Perform C++ unqualified name lookup. std::pair<bool, LookupResult> MaybeResult = |